undelfs.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  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. if ((retval = ext2fs_open_inode_scan (fs, 0, &scan)))
  178. {
  179. message (D_ERROR, undelfserr, _(" open_inode_scan: %d "), retval);
  180. goto free_block_buf;
  181. }
  182. if ((retval = ext2fs_get_next_inode (scan, &ino, &inode)))
  183. {
  184. message (D_ERROR, undelfserr, _(" while starting inode scan %d "), retval);
  185. goto error_out;
  186. }
  187. count = 0;
  188. while (ino)
  189. {
  190. if ((count++ % 1024) == 0)
  191. print_vfs_message (_("undelfs: loading deleted files information %d inodes"), count);
  192. if (inode.i_dtime == 0)
  193. goto next;
  194. if (S_ISDIR (inode.i_mode))
  195. goto next;
  196. lsd.inode = ino;
  197. lsd.num_blocks = 0;
  198. lsd.free_blocks = 0;
  199. lsd.bad_blocks = 0;
  200. retval = ext2fs_block_iterate (fs, ino, 0, block_buf, undelfs_lsdel_proc, &lsd);
  201. if (retval)
  202. {
  203. message (D_ERROR, undelfserr, _(" while calling ext2_block_iterate %d "), retval);
  204. goto next;
  205. }
  206. if (lsd.free_blocks && !lsd.bad_blocks)
  207. {
  208. if (num_delarray >= max_delarray)
  209. {
  210. struct deleted_info *delarray_new = g_try_realloc (delarray,
  211. sizeof (struct deleted_info) *
  212. (max_delarray + 50));
  213. if (!delarray_new)
  214. {
  215. message (D_ERROR, undelfserr, _(" no more memory while reallocating array "));
  216. goto error_out;
  217. }
  218. delarray = delarray_new;
  219. max_delarray += 50;
  220. }
  221. delarray[num_delarray].ino = ino;
  222. delarray[num_delarray].mode = inode.i_mode;
  223. delarray[num_delarray].uid = inode.i_uid;
  224. delarray[num_delarray].gid = inode.i_gid;
  225. delarray[num_delarray].size = inode.i_size;
  226. delarray[num_delarray].dtime = inode.i_dtime;
  227. delarray[num_delarray].num_blocks = lsd.num_blocks;
  228. delarray[num_delarray].free_blocks = lsd.free_blocks;
  229. num_delarray++;
  230. }
  231. next:
  232. retval = ext2fs_get_next_inode (scan, &ino, &inode);
  233. if (retval)
  234. {
  235. message (D_ERROR, undelfserr, _(" while doing inode scan %d "), retval);
  236. goto error_out;
  237. }
  238. }
  239. readdir_ptr = READDIR_PTR_INIT;
  240. ext2fs_close_inode_scan (scan);
  241. return 1;
  242. error_out:
  243. ext2fs_close_inode_scan (scan);
  244. free_block_buf:
  245. g_free (block_buf);
  246. block_buf = NULL;
  247. free_delarray:
  248. g_free (delarray);
  249. delarray = NULL;
  250. return 0;
  251. }
  252. /*
  253. * This function overrides com_err() from libcom_err library.
  254. * It is used in libext2fs to report errors.
  255. */
  256. void
  257. com_err (const char *whoami, long err_code, const char *fmt, ...)
  258. {
  259. va_list ap;
  260. char *str;
  261. va_start (ap, fmt);
  262. str = g_strdup_vprintf (fmt, ap);
  263. va_end (ap);
  264. message (D_ERROR, _(" Ext2lib error "), " %s (%s: %ld) ", str, whoami, err_code);
  265. g_free (str);
  266. }
  267. static void *
  268. undelfs_opendir (struct vfs_class *me, const char *dirname)
  269. {
  270. char *file, *f;
  271. undelfs_get_path (dirname, &file, &f);
  272. if (!file)
  273. return 0;
  274. /* We don't use the file name */
  275. g_free (f);
  276. if (!ext2_fname || strcmp (ext2_fname, file))
  277. {
  278. undelfs_shutdown ();
  279. ext2_fname = file;
  280. }
  281. else
  282. {
  283. /* To avoid expensive re-scannings */
  284. readdir_ptr = READDIR_PTR_INIT;
  285. g_free (file);
  286. return fs;
  287. }
  288. if (ext2fs_open (ext2_fname, 0, 0, 0, unix_io_manager, &fs))
  289. {
  290. message (D_ERROR, undelfserr, _(" Cannot open file %s "), ext2_fname);
  291. return 0;
  292. }
  293. print_vfs_message (_("undelfs: reading inode bitmap..."));
  294. if (ext2fs_read_inode_bitmap (fs))
  295. {
  296. message (D_ERROR, undelfserr, _(" Cannot load inode bitmap from: \n %s \n"), ext2_fname);
  297. goto quit_opendir;
  298. }
  299. print_vfs_message (_("undelfs: reading block bitmap..."));
  300. if (ext2fs_read_block_bitmap (fs))
  301. {
  302. message (D_ERROR, undelfserr, _(" Cannot load block bitmap from: \n %s \n"), ext2_fname);
  303. goto quit_opendir;
  304. }
  305. /* Now load the deleted information */
  306. if (!undelfs_loaddel ())
  307. goto quit_opendir;
  308. print_vfs_message (_("%s: done."), me->name);
  309. return fs;
  310. quit_opendir:
  311. print_vfs_message (_("%s: failure"), me->name);
  312. ext2fs_close (fs);
  313. fs = NULL;
  314. return 0;
  315. }
  316. static void *
  317. undelfs_readdir (void *vfs_info)
  318. {
  319. static union vfs_dirent undelfs_readdir_data;
  320. static char *const dirent_dest = undelfs_readdir_data.dent.d_name;
  321. if (vfs_info != fs)
  322. {
  323. message (D_ERROR, undelfserr, _(" vfs_info is not fs! "));
  324. return NULL;
  325. }
  326. if (readdir_ptr == num_delarray)
  327. return NULL;
  328. if (readdir_ptr < 0)
  329. strcpy (dirent_dest, readdir_ptr == -2 ? "." : "..");
  330. else
  331. g_snprintf (dirent_dest, MC_MAXPATHLEN, "%ld:%d",
  332. (long) delarray[readdir_ptr].ino, delarray[readdir_ptr].num_blocks);
  333. readdir_ptr++;
  334. compute_namelen (&undelfs_readdir_data.dent);
  335. return &undelfs_readdir_data;
  336. }
  337. static int
  338. undelfs_closedir (void *vfs_info)
  339. {
  340. (void) vfs_info;
  341. return 0;
  342. }
  343. typedef struct
  344. {
  345. int f_index; /* file index into delarray */
  346. char *buf;
  347. int error_code; /* */
  348. int pos; /* file position */
  349. int current; /* used to determine current position in itereate */
  350. int finished;
  351. ext2_ino_t inode;
  352. int bytes_read;
  353. long size;
  354. /* Used by undelfs_read: */
  355. char *dest_buffer; /* destination buffer */
  356. int count; /* bytes to read */
  357. } undelfs_file;
  358. /* We do not support lseek */
  359. static void *
  360. undelfs_open (struct vfs_class *me, const char *fname, int flags, int mode)
  361. {
  362. char *file, *f;
  363. ext2_ino_t inode, i;
  364. undelfs_file *p = NULL;
  365. (void) me;
  366. (void) flags;
  367. (void) mode;
  368. /* Only allow reads on this file system */
  369. undelfs_get_path (fname, &file, &f);
  370. if (!file)
  371. return 0;
  372. if (!ext2_fname || strcmp (ext2_fname, file))
  373. {
  374. message (D_ERROR, undelfserr, _(" You have to chdir to extract files first "));
  375. g_free (file);
  376. g_free (f);
  377. return 0;
  378. }
  379. inode = atol (f);
  380. /* Search the file into delarray */
  381. for (i = 0; i < (ext2_ino_t) num_delarray; i++)
  382. {
  383. if (inode != delarray[i].ino)
  384. continue;
  385. /* Found: setup all the structures needed by read */
  386. p = (undelfs_file *) g_try_malloc (((gsize) sizeof (undelfs_file)));
  387. if (!p)
  388. {
  389. g_free (file);
  390. g_free (f);
  391. return 0;
  392. }
  393. p->buf = g_try_malloc (fs->blocksize);
  394. if (!p->buf)
  395. {
  396. g_free (p);
  397. g_free (file);
  398. g_free (f);
  399. return 0;
  400. }
  401. p->inode = inode;
  402. p->finished = 0;
  403. p->f_index = i;
  404. p->error_code = 0;
  405. p->pos = 0;
  406. p->size = delarray[i].size;
  407. }
  408. g_free (file);
  409. g_free (f);
  410. undelfs_usage++;
  411. return p;
  412. }
  413. static int
  414. undelfs_close (void *vfs_info)
  415. {
  416. undelfs_file *p = vfs_info;
  417. g_free (p->buf);
  418. g_free (p);
  419. undelfs_usage--;
  420. return 0;
  421. }
  422. static int
  423. undelfs_dump_read (ext2_filsys param_fs, blk_t * blocknr, int blockcnt, void *private)
  424. {
  425. int copy_count;
  426. undelfs_file *p = (undelfs_file *) private;
  427. if (blockcnt < 0)
  428. return 0;
  429. if (*blocknr)
  430. {
  431. p->error_code = io_channel_read_blk (param_fs->io, *blocknr, 1, p->buf);
  432. if (p->error_code)
  433. return BLOCK_ABORT;
  434. }
  435. else
  436. memset (p->buf, 0, param_fs->blocksize);
  437. if (p->pos + p->count < p->current)
  438. {
  439. p->finished = 1;
  440. return BLOCK_ABORT;
  441. }
  442. if ((size_t) p->pos > p->current + param_fs->blocksize)
  443. {
  444. p->current += param_fs->blocksize;
  445. return 0; /* we have not arrived yet */
  446. }
  447. /* Now, we know we have to extract some data */
  448. if (p->pos >= p->current)
  449. {
  450. /* First case: starting pointer inside this block */
  451. if ((size_t) (p->pos + p->count) <= p->current + param_fs->blocksize)
  452. {
  453. /* Fully contained */
  454. copy_count = p->count;
  455. p->finished = p->count;
  456. }
  457. else
  458. {
  459. /* Still some more data */
  460. copy_count = param_fs->blocksize - (p->pos - p->current);
  461. }
  462. memcpy (p->dest_buffer, p->buf + (p->pos - p->current), copy_count);
  463. }
  464. else
  465. {
  466. /* Second case: we already have passed p->pos */
  467. if ((size_t) (p->pos + p->count) < p->current + param_fs->blocksize)
  468. {
  469. copy_count = (p->pos + p->count) - p->current;
  470. p->finished = p->count;
  471. }
  472. else
  473. {
  474. copy_count = param_fs->blocksize;
  475. }
  476. memcpy (p->dest_buffer, p->buf, copy_count);
  477. }
  478. p->dest_buffer += copy_count;
  479. p->current += param_fs->blocksize;
  480. if (p->finished)
  481. {
  482. return BLOCK_ABORT;
  483. }
  484. return 0;
  485. }
  486. static ssize_t
  487. undelfs_read (void *vfs_info, char *buffer, int count)
  488. {
  489. undelfs_file *p = vfs_info;
  490. int retval;
  491. p->dest_buffer = buffer;
  492. p->current = 0;
  493. p->finished = 0;
  494. p->count = count;
  495. if (p->pos + p->count > p->size)
  496. {
  497. p->count = p->size - p->pos;
  498. }
  499. retval = ext2fs_block_iterate (fs, p->inode, 0, NULL, undelfs_dump_read, p);
  500. if (retval)
  501. {
  502. message (D_ERROR, undelfserr, _(" while iterating over blocks "));
  503. return -1;
  504. }
  505. if (p->error_code && !p->finished)
  506. return 0;
  507. p->pos = p->pos + (p->dest_buffer - buffer);
  508. return p->dest_buffer - buffer;
  509. }
  510. static long
  511. undelfs_getindex (char *path)
  512. {
  513. ext2_ino_t inode = atol (path);
  514. int i;
  515. for (i = 0; i < num_delarray; i++)
  516. {
  517. if (delarray[i].ino == inode)
  518. return i;
  519. }
  520. return -1;
  521. }
  522. static int
  523. undelfs_stat_int (int inode_index, struct stat *buf)
  524. {
  525. buf->st_dev = 0;
  526. buf->st_ino = delarray[inode_index].ino;
  527. buf->st_mode = delarray[inode_index].mode;
  528. buf->st_nlink = 1;
  529. buf->st_uid = delarray[inode_index].uid;
  530. buf->st_gid = delarray[inode_index].gid;
  531. buf->st_size = delarray[inode_index].size;
  532. buf->st_atime = delarray[inode_index].dtime;
  533. buf->st_ctime = delarray[inode_index].dtime;
  534. buf->st_mtime = delarray[inode_index].dtime;
  535. return 0;
  536. }
  537. static int
  538. undelfs_lstat (struct vfs_class *me, const char *path, struct stat *buf)
  539. {
  540. int inode_index;
  541. char *file, *f;
  542. (void) me;
  543. undelfs_get_path (path, &file, &f);
  544. if (!file)
  545. return 0;
  546. /* When called from save_cwd_stats we get an incorrect file and f here:
  547. e.g. incorrect correct
  548. path = "undel:/dev/sda1" path="undel:/dev/sda1/401:1"
  549. file = "/dev" file="/dev/sda1"
  550. f = "sda1" f ="401:1"
  551. If the first char in f is no digit -> return error */
  552. if (!isdigit (*f))
  553. {
  554. g_free (file);
  555. g_free (f);
  556. return -1;
  557. }
  558. if (!ext2_fname || strcmp (ext2_fname, file))
  559. {
  560. message (D_ERROR, undelfserr, _(" You have to chdir to extract files first "));
  561. g_free (file);
  562. g_free (f);
  563. return 0;
  564. }
  565. inode_index = undelfs_getindex (f);
  566. g_free (file);
  567. g_free (f);
  568. if (inode_index == -1)
  569. return -1;
  570. return undelfs_stat_int (inode_index, buf);
  571. }
  572. #define undelfs_stat undelfs_lstat
  573. static int
  574. undelfs_fstat (void *vfs_info, struct stat *buf)
  575. {
  576. undelfs_file *p = vfs_info;
  577. return undelfs_stat_int (p->f_index, buf);
  578. }
  579. static int
  580. undelfs_chdir (struct vfs_class *me, const char *path)
  581. {
  582. char *file, *f;
  583. int fd;
  584. (void) me;
  585. undelfs_get_path (path, &file, &f);
  586. if (!file)
  587. return -1;
  588. /* We may use access because ext2 file systems are local */
  589. /* this could be fixed by making an ext2fs io manager to use */
  590. /* our vfs, but that is left as an excercise for the reader */
  591. if ((fd = open (file, O_RDONLY)) == -1)
  592. {
  593. message (D_ERROR, undelfserr, _(" Cannot open file %s "), file);
  594. g_free (f);
  595. g_free (file);
  596. return -1;
  597. }
  598. close (fd);
  599. g_free (f);
  600. g_free (file);
  601. return 0;
  602. }
  603. /* this has to stay here for now: vfs layer does not know how to emulate it */
  604. static off_t
  605. undelfs_lseek (void *vfs_info, off_t offset, int whence)
  606. {
  607. (void) vfs_info;
  608. (void) offset;
  609. (void) whence;
  610. return -1;
  611. }
  612. static vfsid
  613. undelfs_getid (struct vfs_class *me, const char *path)
  614. {
  615. char *fname, *fsname;
  616. (void) me;
  617. undelfs_get_path (path, &fsname, &fname);
  618. if (!fsname)
  619. return NULL;
  620. g_free (fname);
  621. g_free (fsname);
  622. return (vfsid) fs;
  623. }
  624. static int
  625. undelfs_nothingisopen (vfsid id)
  626. {
  627. (void) id;
  628. return !undelfs_usage;
  629. }
  630. static void
  631. undelfs_free (vfsid id)
  632. {
  633. (void) id;
  634. undelfs_shutdown ();
  635. }
  636. #ifdef ENABLE_NLS
  637. static int
  638. undelfs_init (struct vfs_class *me)
  639. {
  640. (void) me;
  641. undelfserr = _(undelfserr);
  642. return 1;
  643. }
  644. #else
  645. #define undelfs_init NULL
  646. #endif
  647. void
  648. init_undelfs (void)
  649. {
  650. vfs_undelfs_ops.name = "undelfs";
  651. vfs_undelfs_ops.prefix = "undel:";
  652. vfs_undelfs_ops.init = undelfs_init;
  653. vfs_undelfs_ops.open = undelfs_open;
  654. vfs_undelfs_ops.close = undelfs_close;
  655. vfs_undelfs_ops.read = undelfs_read;
  656. vfs_undelfs_ops.opendir = undelfs_opendir;
  657. vfs_undelfs_ops.readdir = undelfs_readdir;
  658. vfs_undelfs_ops.closedir = undelfs_closedir;
  659. vfs_undelfs_ops.stat = undelfs_stat;
  660. vfs_undelfs_ops.lstat = undelfs_lstat;
  661. vfs_undelfs_ops.fstat = undelfs_fstat;
  662. vfs_undelfs_ops.chdir = undelfs_chdir;
  663. vfs_undelfs_ops.lseek = undelfs_lseek;
  664. vfs_undelfs_ops.getid = undelfs_getid;
  665. vfs_undelfs_ops.nothingisopen = undelfs_nothingisopen;
  666. vfs_undelfs_ops.free = undelfs_free;
  667. vfs_register_class (&vfs_undelfs_ops);
  668. }