undelfs.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. /* UnDel File System: Midnight Commander file system.
  2. This file system is intended to be used together with the
  3. ext2fs library to recover files from ext2fs file systems.
  4. Parts of this program were taken from the lsdel.c and dump.c files
  5. written by Ted Ts'o (tytso@mit.edu) for the ext2fs package.
  6. Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
  7. 2005, 2007 Free Software Foundation, Inc.
  8. Written by: 1995 Miguel de Icaza.
  9. 1997 Norbert Warmuth.
  10. 2000 Pavel Machek
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU Library General Public License
  13. as published by the Free Software Foundation; either version 2 of
  14. the License, or (at your option) any later version.
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU Library General Public License for more details.
  19. You should have received a copy of the GNU Library General Public
  20. License along with this program; if not, write to the Free Software
  21. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  22. /**
  23. * \file
  24. * \brief Source: UnDel File System
  25. *
  26. * Assumptions:
  27. *
  28. * 1. We don't handle directories (thus undelfs_get_path is easy to write).
  29. * 2. Files are on the local file system (we do not support vfs files
  30. * because we would have to provide an io_manager for the ext2fs tools,
  31. * and I don't think it would be too useful to undelete files
  32. */
  33. #include <config.h>
  34. #include <errno.h>
  35. #include <stdio.h>
  36. #include <stdlib.h>
  37. #include <fcntl.h>
  38. #ifdef HAVE_EXT2FS_EXT2_FS_H
  39. #include <ext2fs/ext2_fs.h>
  40. #else
  41. /* asm/types.h defines its own umode_t */
  42. #undef umode_t
  43. #include <linux/ext2_fs.h>
  44. #endif
  45. #include <ext2fs/ext2fs.h>
  46. #include <ctype.h>
  47. #include "lib/global.h"
  48. #include "src/wtools.h" /* message() */
  49. #include "src/main.h" /* print_vfs_message */
  50. #include "utilvfs.h"
  51. #include "vfs.h"
  52. #include "vfs-impl.h"
  53. struct deleted_info
  54. {
  55. ext2_ino_t ino;
  56. unsigned short mode;
  57. unsigned short uid;
  58. unsigned short gid;
  59. unsigned long size;
  60. time_t dtime;
  61. int num_blocks;
  62. int free_blocks;
  63. };
  64. struct lsdel_struct
  65. {
  66. ext2_ino_t inode;
  67. int num_blocks;
  68. int free_blocks;
  69. int bad_blocks;
  70. };
  71. /* We only allow one opened ext2fs */
  72. static char *ext2_fname;
  73. static ext2_filsys fs = NULL;
  74. static struct lsdel_struct lsd;
  75. static struct deleted_info *delarray;
  76. static int num_delarray, max_delarray;
  77. static char *block_buf;
  78. static const char *undelfserr = N_("undelfs: error");
  79. static int readdir_ptr;
  80. static int undelfs_usage;
  81. static struct vfs_class vfs_undelfs_ops;
  82. /* To generate the . and .. entries use -2 */
  83. #define READDIR_PTR_INIT 0
  84. static void
  85. undelfs_shutdown (void)
  86. {
  87. if (fs)
  88. ext2fs_close (fs);
  89. fs = NULL;
  90. g_free (ext2_fname);
  91. ext2_fname = NULL;
  92. g_free (delarray);
  93. delarray = NULL;
  94. g_free (block_buf);
  95. block_buf = NULL;
  96. }
  97. static void
  98. undelfs_get_path (const char *dirname, char **fsname, char **file)
  99. {
  100. const char *p;
  101. /* To look like filesystem, we have virtual directories
  102. /#undel:XXX, which have no subdirectories. XXX is replaced with
  103. hda5, sdb8 etc, which is assumed to live under /dev.
  104. -- pavel@ucw.cz */
  105. *fsname = NULL;
  106. if (strncmp (dirname, "/#undel:", 8))
  107. return;
  108. dirname += 8;
  109. /* Since we don't allow subdirectories, it's easy to get a filename,
  110. * just scan backwards for a slash */
  111. if (*dirname == 0)
  112. return;
  113. p = dirname + strlen (dirname);
  114. #if 0
  115. /* Strip trailing ./
  116. */
  117. if (p - dirname > 2 && *(p - 1) == '/' && *(p - 2) == '.')
  118. *(p = p - 2) = 0;
  119. #endif
  120. while (p > dirname)
  121. {
  122. if (*p == '/')
  123. {
  124. char *tmp;
  125. *file = g_strdup (p + 1);
  126. tmp = g_strndup (dirname, p - dirname);
  127. *fsname = g_strconcat ("/dev/", tmp, (char *) NULL);
  128. g_free (tmp);
  129. return;
  130. }
  131. p--;
  132. }
  133. *file = g_strdup ("");
  134. *fsname = g_strconcat ("/dev/", dirname, (char *) NULL);
  135. return;
  136. }
  137. static int
  138. undelfs_lsdel_proc (ext2_filsys _fs, blk_t * block_nr, int blockcnt, void *private)
  139. {
  140. struct lsdel_struct *_lsd = (struct lsdel_struct *) private;
  141. (void) blockcnt;
  142. _lsd->num_blocks++;
  143. if (*block_nr < _fs->super->s_first_data_block || *block_nr >= _fs->super->s_blocks_count)
  144. {
  145. _lsd->bad_blocks++;
  146. return BLOCK_ABORT;
  147. }
  148. if (!ext2fs_test_block_bitmap (_fs->block_map, *block_nr))
  149. _lsd->free_blocks++;
  150. return 0;
  151. }
  152. /*
  153. * Load information about deleted files.
  154. * Don't abort if there is not enough memory - load as much as we can.
  155. */
  156. static int
  157. undelfs_loaddel (void)
  158. {
  159. int retval, count;
  160. ext2_ino_t ino;
  161. struct ext2_inode inode;
  162. ext2_inode_scan scan;
  163. max_delarray = 100;
  164. num_delarray = 0;
  165. delarray = g_try_malloc (sizeof (struct deleted_info) * max_delarray);
  166. if (!delarray)
  167. {
  168. message (D_ERROR, undelfserr, _("not enough memory"));
  169. return 0;
  170. }
  171. block_buf = g_try_malloc (fs->blocksize * 3);
  172. if (!block_buf)
  173. {
  174. message (D_ERROR, undelfserr, _("while allocating block buffer"));
  175. goto free_delarray;
  176. }
  177. retval = ext2fs_open_inode_scan (fs, 0, &scan);
  178. if (retval != 0)
  179. {
  180. message (D_ERROR, undelfserr, _("open_inode_scan: %d"), retval);
  181. goto free_block_buf;
  182. }
  183. retval = ext2fs_get_next_inode (scan, &ino, &inode);
  184. if (retval != 0)
  185. {
  186. message (D_ERROR, undelfserr, _("while starting inode scan %d"), retval);
  187. goto error_out;
  188. }
  189. count = 0;
  190. while (ino)
  191. {
  192. if ((count++ % 1024) == 0)
  193. print_vfs_message (_("undelfs: loading deleted files information %d inodes"), count);
  194. if (inode.i_dtime == 0)
  195. goto next;
  196. if (S_ISDIR (inode.i_mode))
  197. goto next;
  198. lsd.inode = ino;
  199. lsd.num_blocks = 0;
  200. lsd.free_blocks = 0;
  201. lsd.bad_blocks = 0;
  202. retval = ext2fs_block_iterate (fs, ino, 0, block_buf, undelfs_lsdel_proc, &lsd);
  203. if (retval)
  204. {
  205. message (D_ERROR, undelfserr, _("while calling ext2_block_iterate %d"), retval);
  206. goto next;
  207. }
  208. if (lsd.free_blocks && !lsd.bad_blocks)
  209. {
  210. if (num_delarray >= max_delarray)
  211. {
  212. struct deleted_info *delarray_new = g_try_realloc (delarray,
  213. sizeof (struct deleted_info) *
  214. (max_delarray + 50));
  215. if (!delarray_new)
  216. {
  217. message (D_ERROR, undelfserr, _("no more memory while reallocating array"));
  218. goto error_out;
  219. }
  220. delarray = delarray_new;
  221. max_delarray += 50;
  222. }
  223. delarray[num_delarray].ino = ino;
  224. delarray[num_delarray].mode = inode.i_mode;
  225. delarray[num_delarray].uid = inode.i_uid;
  226. delarray[num_delarray].gid = inode.i_gid;
  227. delarray[num_delarray].size = inode.i_size;
  228. delarray[num_delarray].dtime = inode.i_dtime;
  229. delarray[num_delarray].num_blocks = lsd.num_blocks;
  230. delarray[num_delarray].free_blocks = lsd.free_blocks;
  231. num_delarray++;
  232. }
  233. next:
  234. retval = ext2fs_get_next_inode (scan, &ino, &inode);
  235. if (retval)
  236. {
  237. message (D_ERROR, undelfserr, _("while doing inode scan %d"), retval);
  238. goto error_out;
  239. }
  240. }
  241. readdir_ptr = READDIR_PTR_INIT;
  242. ext2fs_close_inode_scan (scan);
  243. return 1;
  244. error_out:
  245. ext2fs_close_inode_scan (scan);
  246. free_block_buf:
  247. g_free (block_buf);
  248. block_buf = NULL;
  249. free_delarray:
  250. g_free (delarray);
  251. delarray = NULL;
  252. return 0;
  253. }
  254. /*
  255. * This function overrides com_err() from libcom_err library.
  256. * It is used in libext2fs to report errors.
  257. */
  258. void
  259. com_err (const char *whoami, long err_code, const char *fmt, ...)
  260. {
  261. va_list ap;
  262. char *str;
  263. va_start (ap, fmt);
  264. str = g_strdup_vprintf (fmt, ap);
  265. va_end (ap);
  266. message (D_ERROR, _("Ext2lib error"), "%s (%s: %ld)", str, whoami, err_code);
  267. g_free (str);
  268. }
  269. static void *
  270. undelfs_opendir (struct vfs_class *me, const char *dirname)
  271. {
  272. char *file, *f;
  273. undelfs_get_path (dirname, &file, &f);
  274. if (!file)
  275. return 0;
  276. /* We don't use the file name */
  277. g_free (f);
  278. if (!ext2_fname || strcmp (ext2_fname, file))
  279. {
  280. undelfs_shutdown ();
  281. ext2_fname = file;
  282. }
  283. else
  284. {
  285. /* To avoid expensive re-scannings */
  286. readdir_ptr = READDIR_PTR_INIT;
  287. g_free (file);
  288. return fs;
  289. }
  290. if (ext2fs_open (ext2_fname, 0, 0, 0, unix_io_manager, &fs))
  291. {
  292. message (D_ERROR, undelfserr, _("Cannot open file %s"), ext2_fname);
  293. return 0;
  294. }
  295. print_vfs_message (_("undelfs: reading inode bitmap..."));
  296. if (ext2fs_read_inode_bitmap (fs))
  297. {
  298. message (D_ERROR, undelfserr, _("Cannot load inode bitmap from:\n%s"), ext2_fname);
  299. goto quit_opendir;
  300. }
  301. print_vfs_message (_("undelfs: reading block bitmap..."));
  302. if (ext2fs_read_block_bitmap (fs))
  303. {
  304. message (D_ERROR, undelfserr, _("Cannot load block bitmap from:\n%s"), ext2_fname);
  305. goto quit_opendir;
  306. }
  307. /* Now load the deleted information */
  308. if (!undelfs_loaddel ())
  309. goto quit_opendir;
  310. print_vfs_message (_("%s: done."), me->name);
  311. return fs;
  312. quit_opendir:
  313. print_vfs_message (_("%s: failure"), me->name);
  314. ext2fs_close (fs);
  315. fs = NULL;
  316. return 0;
  317. }
  318. static void *
  319. undelfs_readdir (void *vfs_info)
  320. {
  321. static union vfs_dirent undelfs_readdir_data;
  322. static char *const dirent_dest = undelfs_readdir_data.dent.d_name;
  323. if (vfs_info != fs)
  324. {
  325. message (D_ERROR, undelfserr, _("vfs_info is not fs!"));
  326. return NULL;
  327. }
  328. if (readdir_ptr == num_delarray)
  329. return NULL;
  330. if (readdir_ptr < 0)
  331. strcpy (dirent_dest, readdir_ptr == -2 ? "." : "..");
  332. else
  333. g_snprintf (dirent_dest, MC_MAXPATHLEN, "%ld:%d",
  334. (long) delarray[readdir_ptr].ino, delarray[readdir_ptr].num_blocks);
  335. readdir_ptr++;
  336. compute_namelen (&undelfs_readdir_data.dent);
  337. return &undelfs_readdir_data;
  338. }
  339. static int
  340. undelfs_closedir (void *vfs_info)
  341. {
  342. (void) vfs_info;
  343. return 0;
  344. }
  345. typedef struct
  346. {
  347. int f_index; /* file index into delarray */
  348. char *buf;
  349. int error_code; /* */
  350. int pos; /* file position */
  351. int current; /* used to determine current position in itereate */
  352. int finished;
  353. ext2_ino_t inode;
  354. int bytes_read;
  355. long size;
  356. /* Used by undelfs_read: */
  357. char *dest_buffer; /* destination buffer */
  358. int count; /* bytes to read */
  359. } undelfs_file;
  360. /* We do not support lseek */
  361. static void *
  362. undelfs_open (struct vfs_class *me, const char *fname, int flags, int mode)
  363. {
  364. char *file, *f;
  365. ext2_ino_t inode, i;
  366. undelfs_file *p = NULL;
  367. (void) me;
  368. (void) flags;
  369. (void) mode;
  370. /* Only allow reads on this file system */
  371. undelfs_get_path (fname, &file, &f);
  372. if (!file)
  373. return 0;
  374. if (!ext2_fname || strcmp (ext2_fname, file))
  375. {
  376. message (D_ERROR, undelfserr, _("You have to chdir to extract files first"));
  377. g_free (file);
  378. g_free (f);
  379. return 0;
  380. }
  381. inode = atol (f);
  382. /* Search the file into delarray */
  383. for (i = 0; i < (ext2_ino_t) num_delarray; i++)
  384. {
  385. if (inode != delarray[i].ino)
  386. continue;
  387. /* Found: setup all the structures needed by read */
  388. p = (undelfs_file *) g_try_malloc (((gsize) sizeof (undelfs_file)));
  389. if (!p)
  390. {
  391. g_free (file);
  392. g_free (f);
  393. return 0;
  394. }
  395. p->buf = g_try_malloc (fs->blocksize);
  396. if (!p->buf)
  397. {
  398. g_free (p);
  399. g_free (file);
  400. g_free (f);
  401. return 0;
  402. }
  403. p->inode = inode;
  404. p->finished = 0;
  405. p->f_index = i;
  406. p->error_code = 0;
  407. p->pos = 0;
  408. p->size = delarray[i].size;
  409. }
  410. g_free (file);
  411. g_free (f);
  412. undelfs_usage++;
  413. return p;
  414. }
  415. static int
  416. undelfs_close (void *vfs_info)
  417. {
  418. undelfs_file *p = vfs_info;
  419. g_free (p->buf);
  420. g_free (p);
  421. undelfs_usage--;
  422. return 0;
  423. }
  424. static int
  425. undelfs_dump_read (ext2_filsys param_fs, blk_t * blocknr, int blockcnt, void *private)
  426. {
  427. int copy_count;
  428. undelfs_file *p = (undelfs_file *) private;
  429. if (blockcnt < 0)
  430. return 0;
  431. if (*blocknr)
  432. {
  433. p->error_code = io_channel_read_blk (param_fs->io, *blocknr, 1, p->buf);
  434. if (p->error_code)
  435. return BLOCK_ABORT;
  436. }
  437. else
  438. memset (p->buf, 0, param_fs->blocksize);
  439. if (p->pos + p->count < p->current)
  440. {
  441. p->finished = 1;
  442. return BLOCK_ABORT;
  443. }
  444. if ((size_t) p->pos > p->current + param_fs->blocksize)
  445. {
  446. p->current += param_fs->blocksize;
  447. return 0; /* we have not arrived yet */
  448. }
  449. /* Now, we know we have to extract some data */
  450. if (p->pos >= p->current)
  451. {
  452. /* First case: starting pointer inside this block */
  453. if ((size_t) (p->pos + p->count) <= p->current + param_fs->blocksize)
  454. {
  455. /* Fully contained */
  456. copy_count = p->count;
  457. p->finished = p->count;
  458. }
  459. else
  460. {
  461. /* Still some more data */
  462. copy_count = param_fs->blocksize - (p->pos - p->current);
  463. }
  464. memcpy (p->dest_buffer, p->buf + (p->pos - p->current), copy_count);
  465. }
  466. else
  467. {
  468. /* Second case: we already have passed p->pos */
  469. if ((size_t) (p->pos + p->count) < p->current + param_fs->blocksize)
  470. {
  471. copy_count = (p->pos + p->count) - p->current;
  472. p->finished = p->count;
  473. }
  474. else
  475. {
  476. copy_count = param_fs->blocksize;
  477. }
  478. memcpy (p->dest_buffer, p->buf, copy_count);
  479. }
  480. p->dest_buffer += copy_count;
  481. p->current += param_fs->blocksize;
  482. if (p->finished)
  483. {
  484. return BLOCK_ABORT;
  485. }
  486. return 0;
  487. }
  488. static ssize_t
  489. undelfs_read (void *vfs_info, char *buffer, int count)
  490. {
  491. undelfs_file *p = vfs_info;
  492. int retval;
  493. p->dest_buffer = buffer;
  494. p->current = 0;
  495. p->finished = 0;
  496. p->count = count;
  497. if (p->pos + p->count > p->size)
  498. {
  499. p->count = p->size - p->pos;
  500. }
  501. retval = ext2fs_block_iterate (fs, p->inode, 0, NULL, undelfs_dump_read, p);
  502. if (retval)
  503. {
  504. message (D_ERROR, undelfserr, _("while iterating over blocks"));
  505. return -1;
  506. }
  507. if (p->error_code && !p->finished)
  508. return 0;
  509. p->pos = p->pos + (p->dest_buffer - buffer);
  510. return p->dest_buffer - buffer;
  511. }
  512. static long
  513. undelfs_getindex (char *path)
  514. {
  515. ext2_ino_t inode = atol (path);
  516. int i;
  517. for (i = 0; i < num_delarray; i++)
  518. {
  519. if (delarray[i].ino == inode)
  520. return i;
  521. }
  522. return -1;
  523. }
  524. static int
  525. undelfs_stat_int (int inode_index, struct stat *buf)
  526. {
  527. buf->st_dev = 0;
  528. buf->st_ino = delarray[inode_index].ino;
  529. buf->st_mode = delarray[inode_index].mode;
  530. buf->st_nlink = 1;
  531. buf->st_uid = delarray[inode_index].uid;
  532. buf->st_gid = delarray[inode_index].gid;
  533. buf->st_size = delarray[inode_index].size;
  534. buf->st_atime = delarray[inode_index].dtime;
  535. buf->st_ctime = delarray[inode_index].dtime;
  536. buf->st_mtime = delarray[inode_index].dtime;
  537. return 0;
  538. }
  539. static int
  540. undelfs_lstat (struct vfs_class *me, const char *path, struct stat *buf)
  541. {
  542. int inode_index;
  543. char *file, *f;
  544. (void) me;
  545. undelfs_get_path (path, &file, &f);
  546. if (!file)
  547. return 0;
  548. /* When called from save_cwd_stats we get an incorrect file and f here:
  549. e.g. incorrect correct
  550. path = "undel:/dev/sda1" path="undel:/dev/sda1/401:1"
  551. file = "/dev" file="/dev/sda1"
  552. f = "sda1" f ="401:1"
  553. If the first char in f is no digit -> return error */
  554. if (!isdigit (*f))
  555. {
  556. g_free (file);
  557. g_free (f);
  558. return -1;
  559. }
  560. if (!ext2_fname || strcmp (ext2_fname, file))
  561. {
  562. message (D_ERROR, undelfserr, _("You have to chdir to extract files first"));
  563. g_free (file);
  564. g_free (f);
  565. return 0;
  566. }
  567. inode_index = undelfs_getindex (f);
  568. g_free (file);
  569. g_free (f);
  570. if (inode_index == -1)
  571. return -1;
  572. return undelfs_stat_int (inode_index, buf);
  573. }
  574. #define undelfs_stat undelfs_lstat
  575. static int
  576. undelfs_fstat (void *vfs_info, struct stat *buf)
  577. {
  578. undelfs_file *p = vfs_info;
  579. return undelfs_stat_int (p->f_index, buf);
  580. }
  581. static int
  582. undelfs_chdir (struct vfs_class *me, const char *path)
  583. {
  584. char *file, *f;
  585. int fd;
  586. (void) me;
  587. undelfs_get_path (path, &file, &f);
  588. if (!file)
  589. return -1;
  590. /* We may use access because ext2 file systems are local */
  591. /* this could be fixed by making an ext2fs io manager to use */
  592. /* our vfs, but that is left as an excercise for the reader */
  593. fd = open (file, O_RDONLY);
  594. if (fd == -1)
  595. {
  596. message (D_ERROR, undelfserr, _("Cannot open file \"%s\""), file);
  597. g_free (f);
  598. g_free (file);
  599. return -1;
  600. }
  601. close (fd);
  602. g_free (f);
  603. g_free (file);
  604. return 0;
  605. }
  606. /* this has to stay here for now: vfs layer does not know how to emulate it */
  607. static off_t
  608. undelfs_lseek (void *vfs_info, off_t offset, int whence)
  609. {
  610. (void) vfs_info;
  611. (void) offset;
  612. (void) whence;
  613. return -1;
  614. }
  615. static vfsid
  616. undelfs_getid (struct vfs_class *me, const char *path)
  617. {
  618. char *fname, *fsname;
  619. (void) me;
  620. undelfs_get_path (path, &fsname, &fname);
  621. if (!fsname)
  622. return NULL;
  623. g_free (fname);
  624. g_free (fsname);
  625. return (vfsid) fs;
  626. }
  627. static int
  628. undelfs_nothingisopen (vfsid id)
  629. {
  630. (void) id;
  631. return !undelfs_usage;
  632. }
  633. static void
  634. undelfs_free (vfsid id)
  635. {
  636. (void) id;
  637. undelfs_shutdown ();
  638. }
  639. #ifdef ENABLE_NLS
  640. static int
  641. undelfs_init (struct vfs_class *me)
  642. {
  643. (void) me;
  644. undelfserr = _(undelfserr);
  645. return 1;
  646. }
  647. #else
  648. #define undelfs_init NULL
  649. #endif
  650. void
  651. init_undelfs (void)
  652. {
  653. vfs_undelfs_ops.name = "undelfs";
  654. vfs_undelfs_ops.prefix = "undel:";
  655. vfs_undelfs_ops.init = undelfs_init;
  656. vfs_undelfs_ops.open = undelfs_open;
  657. vfs_undelfs_ops.close = undelfs_close;
  658. vfs_undelfs_ops.read = undelfs_read;
  659. vfs_undelfs_ops.opendir = undelfs_opendir;
  660. vfs_undelfs_ops.readdir = undelfs_readdir;
  661. vfs_undelfs_ops.closedir = undelfs_closedir;
  662. vfs_undelfs_ops.stat = undelfs_stat;
  663. vfs_undelfs_ops.lstat = undelfs_lstat;
  664. vfs_undelfs_ops.fstat = undelfs_fstat;
  665. vfs_undelfs_ops.chdir = undelfs_chdir;
  666. vfs_undelfs_ops.lseek = undelfs_lseek;
  667. vfs_undelfs_ops.getid = undelfs_getid;
  668. vfs_undelfs_ops.nothingisopen = undelfs_nothingisopen;
  669. vfs_undelfs_ops.free = undelfs_free;
  670. vfs_register_class (&vfs_undelfs_ops);
  671. }