extfs.c 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420
  1. /* Virtual File System: External file system.
  2. Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
  3. 2006, 2007 Free Software Foundation, Inc.
  4. Written by: 1995 Jakub Jelinek
  5. Rewritten by: 1998 Pavel Machek
  6. Additional changes by: 1999 Andrew T. Veliath
  7. This program is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU Library General Public License
  9. as published by the Free Software Foundation; either version 2 of
  10. the License, or (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU Library General Public License for more details.
  15. You should have received a copy of the GNU Library General Public
  16. License along with this program; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  18. /* Namespace: init_extfs */
  19. #include <config.h>
  20. #include <stdio.h>
  21. #include <ctype.h>
  22. #include <string.h>
  23. #include <stdlib.h>
  24. #include <sys/types.h>
  25. #include <sys/stat.h>
  26. #include <unistd.h>
  27. #include <signal.h>
  28. #ifdef HAVE_SYS_WAIT_H
  29. #include <sys/wait.h>
  30. #endif
  31. #include <errno.h>
  32. #include "../src/global.h"
  33. #include "../src/tty.h" /* enable/disable interrupt key */
  34. #include "../src/wtools.h" /* message() */
  35. #include "../src/main.h" /* print_vfs_message */
  36. #include "utilvfs.h"
  37. #include "../src/execute.h" /* For shell_execute */
  38. #include "vfs.h"
  39. #include "vfs-impl.h"
  40. #include "gc.h" /* vfs_rmstamp */
  41. #undef ERRNOR
  42. #define ERRNOR(x,y) do { my_errno = x; return y; } while(0)
  43. struct inode {
  44. nlink_t nlink;
  45. struct entry *first_in_subdir; /* only used if this is a directory */
  46. struct entry *last_in_subdir;
  47. ino_t inode; /* This is inode # */
  48. dev_t dev; /* This is an internal identification of the extfs archive */
  49. struct archive *archive; /* And this is an archive structure */
  50. dev_t rdev;
  51. mode_t mode;
  52. uid_t uid;
  53. gid_t gid;
  54. off_t size;
  55. time_t mtime;
  56. char *linkname;
  57. time_t atime;
  58. time_t ctime;
  59. char *local_filename;
  60. };
  61. struct entry {
  62. struct entry *next_in_dir;
  63. struct entry *dir;
  64. char *name;
  65. struct inode *inode;
  66. };
  67. struct pseudofile {
  68. struct archive *archive;
  69. unsigned int has_changed:1;
  70. int local_handle;
  71. struct entry *entry;
  72. };
  73. struct archive {
  74. int fstype;
  75. char *name;
  76. char *local_name;
  77. struct stat local_stat;
  78. dev_t rdev;
  79. int fd_usage;
  80. ino_t inode_counter;
  81. struct entry *root_entry;
  82. struct archive *next;
  83. };
  84. static struct entry *extfs_find_entry (struct entry *dir, char *name,
  85. int make_dirs, int make_file);
  86. static int extfs_which (struct vfs_class *me, const char *path);
  87. static void extfs_remove_entry (struct entry *e);
  88. static void extfs_free (vfsid id);
  89. static void extfs_free_entry (struct entry *e);
  90. static struct vfs_class vfs_extfs_ops;
  91. static struct archive *first_archive = NULL;
  92. static int my_errno = 0;
  93. #define MAXEXTFS 32
  94. static char *extfs_prefixes [MAXEXTFS];
  95. static char extfs_need_archive [MAXEXTFS];
  96. static int extfs_no = 0;
  97. static void
  98. extfs_fill_names (struct vfs_class *me, fill_names_f func)
  99. {
  100. struct archive *a = first_archive;
  101. char *name;
  102. (void) me;
  103. while (a) {
  104. name =
  105. g_strconcat (a->name ? a->name : "", "#",
  106. extfs_prefixes[a->fstype], (char *) NULL);
  107. (*func) (name);
  108. g_free (name);
  109. a = a->next;
  110. }
  111. }
  112. static void extfs_make_dots (struct entry *ent)
  113. {
  114. struct entry *entry = g_new (struct entry, 1);
  115. struct entry *parentry = ent->dir;
  116. struct inode *inode = ent->inode, *parent;
  117. parent = (parentry != NULL) ? parentry->inode : NULL;
  118. entry->name = g_strdup (".");
  119. entry->inode = inode;
  120. entry->dir = ent;
  121. inode->local_filename = NULL;
  122. inode->first_in_subdir = entry;
  123. inode->nlink++;
  124. entry->next_in_dir = g_new (struct entry, 1);
  125. entry = entry->next_in_dir;
  126. entry->name = g_strdup ("..");
  127. inode->last_in_subdir = entry;
  128. entry->next_in_dir = NULL;
  129. if (parent != NULL) {
  130. entry->inode = parent;
  131. entry->dir = parentry;
  132. parent->nlink++;
  133. } else {
  134. entry->inode = inode;
  135. entry->dir = ent;
  136. inode->nlink++;
  137. }
  138. }
  139. static struct entry *extfs_generate_entry (struct archive *archive,
  140. const char *name, struct entry *parentry, mode_t mode)
  141. {
  142. mode_t myumask;
  143. struct inode *inode, *parent;
  144. struct entry *entry;
  145. parent = (parentry != NULL) ? parentry->inode : NULL;
  146. entry = g_new (struct entry, 1);
  147. entry->name = g_strdup (name);
  148. entry->next_in_dir = NULL;
  149. entry->dir = parentry;
  150. if (parent != NULL) {
  151. parent->last_in_subdir->next_in_dir = entry;
  152. parent->last_in_subdir = entry;
  153. }
  154. inode = g_new (struct inode, 1);
  155. entry->inode = inode;
  156. inode->local_filename = NULL;
  157. inode->linkname = NULL;
  158. inode->last_in_subdir = NULL;
  159. inode->inode = (archive->inode_counter)++;
  160. inode->dev = archive->rdev;
  161. inode->archive = archive;
  162. myumask = umask (022);
  163. umask (myumask);
  164. inode->mode = mode & ~myumask;
  165. mode = inode->mode;
  166. inode->rdev = 0;
  167. inode->uid = getuid ();
  168. inode->gid = getgid ();
  169. inode->size = 0;
  170. inode->mtime = time (NULL);
  171. inode->atime = inode->mtime;
  172. inode->ctime = inode->mtime;
  173. inode->nlink = 1;
  174. if (S_ISDIR (mode))
  175. extfs_make_dots (entry);
  176. return entry;
  177. }
  178. #if 0
  179. static void extfs_free_entries (struct entry *entry)
  180. {
  181. (void) entry;
  182. return;
  183. }
  184. #endif
  185. static void extfs_free_archive (struct archive *archive)
  186. {
  187. extfs_free_entry (archive->root_entry);
  188. if (archive->local_name != NULL) {
  189. struct stat my;
  190. mc_stat (archive->local_name, &my);
  191. mc_ungetlocalcopy (archive->name, archive->local_name,
  192. archive->local_stat.st_mtime != my.st_mtime);
  193. g_free(archive->local_name);
  194. }
  195. g_free (archive->name);
  196. g_free (archive);
  197. }
  198. static FILE *
  199. extfs_open_archive (int fstype, const char *name, struct archive **pparc)
  200. {
  201. static dev_t archive_counter = 0;
  202. FILE *result;
  203. mode_t mode;
  204. char *cmd;
  205. char *mc_extfsdir;
  206. struct stat mystat;
  207. struct archive *current_archive;
  208. struct entry *root_entry;
  209. char *local_name = NULL, *tmp = 0;
  210. int uses_archive = extfs_need_archive[fstype];
  211. if (uses_archive) {
  212. if (mc_stat (name, &mystat) == -1)
  213. return NULL;
  214. if (!vfs_file_is_local (name)) {
  215. local_name = mc_getlocalcopy (name);
  216. if (local_name == NULL)
  217. return NULL;
  218. }
  219. tmp = name_quote (name, 0);
  220. }
  221. mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR);
  222. cmd =
  223. g_strconcat (mc_extfsdir, extfs_prefixes[fstype], " list ",
  224. local_name ? local_name : tmp, (char *) NULL);
  225. g_free (tmp);
  226. g_free (mc_extfsdir);
  227. open_error_pipe ();
  228. result = popen (cmd, "r");
  229. g_free (cmd);
  230. if (result == NULL) {
  231. close_error_pipe (1, NULL);
  232. if (local_name) {
  233. mc_ungetlocalcopy (name, local_name, 0);
  234. g_free(local_name);
  235. }
  236. return NULL;
  237. }
  238. #ifdef ___QNXNTO__
  239. setvbuf (result, NULL, _IONBF, 0);
  240. #endif
  241. current_archive = g_new (struct archive, 1);
  242. current_archive->fstype = fstype;
  243. current_archive->name = name ? g_strdup (name) : NULL;
  244. current_archive->local_name = local_name;
  245. if (local_name != NULL)
  246. mc_stat (local_name, &current_archive->local_stat);
  247. current_archive->inode_counter = 0;
  248. current_archive->fd_usage = 0;
  249. current_archive->rdev = archive_counter++;
  250. current_archive->next = first_archive;
  251. first_archive = current_archive;
  252. mode = mystat.st_mode & 07777;
  253. if (mode & 0400)
  254. mode |= 0100;
  255. if (mode & 0040)
  256. mode |= 0010;
  257. if (mode & 0004)
  258. mode |= 0001;
  259. mode |= S_IFDIR;
  260. root_entry = extfs_generate_entry (current_archive, "/", NULL, mode);
  261. root_entry->inode->uid = mystat.st_uid;
  262. root_entry->inode->gid = mystat.st_gid;
  263. root_entry->inode->atime = mystat.st_atime;
  264. root_entry->inode->ctime = mystat.st_ctime;
  265. root_entry->inode->mtime = mystat.st_mtime;
  266. current_archive->root_entry = root_entry;
  267. *pparc = current_archive;
  268. return result;
  269. }
  270. /*
  271. * Main loop for reading an archive.
  272. * Return 0 on success, -1 on error.
  273. */
  274. static int
  275. extfs_read_archive (int fstype, const char *name, struct archive **pparc)
  276. {
  277. FILE *extfsd;
  278. char *buffer;
  279. struct archive *current_archive;
  280. char *current_file_name, *current_link_name;
  281. if ((extfsd =
  282. extfs_open_archive (fstype, name, &current_archive)) == NULL) {
  283. message (1, MSG_ERROR, _("Cannot open %s archive\n%s"),
  284. extfs_prefixes[fstype], name);
  285. return -1;
  286. }
  287. buffer = g_malloc (4096);
  288. while (fgets (buffer, 4096, extfsd) != NULL) {
  289. struct stat hstat;
  290. current_link_name = NULL;
  291. if (vfs_parse_ls_lga
  292. (buffer, &hstat, &current_file_name, &current_link_name)) {
  293. struct entry *entry, *pent;
  294. struct inode *inode;
  295. char *p, *q, *cfn = current_file_name;
  296. if (*cfn) {
  297. if (*cfn == '/')
  298. cfn++;
  299. p = strchr (cfn, 0);
  300. if (p != cfn && *(p - 1) == '/')
  301. *(p - 1) = 0;
  302. p = strrchr (cfn, '/');
  303. if (p == NULL) {
  304. p = cfn;
  305. q = strchr (cfn, 0);
  306. } else {
  307. *(p++) = 0;
  308. q = cfn;
  309. }
  310. if (S_ISDIR (hstat.st_mode)
  311. && (!strcmp (p, ".") || !strcmp (p, "..")))
  312. goto read_extfs_continue;
  313. pent =
  314. extfs_find_entry (current_archive->root_entry, q, 1,
  315. 0);
  316. if (pent == NULL) {
  317. /* FIXME: Should clean everything one day */
  318. g_free (buffer);
  319. pclose (extfsd);
  320. close_error_pipe (1, _("Inconsistent extfs archive"));
  321. return -1;
  322. }
  323. entry = g_new (struct entry, 1);
  324. entry->name = g_strdup (p);
  325. entry->next_in_dir = NULL;
  326. entry->dir = pent;
  327. if (pent->inode->last_in_subdir) {
  328. pent->inode->last_in_subdir->next_in_dir = entry;
  329. pent->inode->last_in_subdir = entry;
  330. }
  331. if (!S_ISLNK (hstat.st_mode) && current_link_name != NULL) {
  332. pent =
  333. extfs_find_entry (current_archive->root_entry,
  334. current_link_name, 0, 0);
  335. if (pent == NULL) {
  336. /* FIXME: Should clean everything one day */
  337. g_free (buffer);
  338. pclose (extfsd);
  339. close_error_pipe (1,
  340. _("Inconsistent extfs archive"));
  341. return -1;
  342. } else {
  343. entry->inode = pent->inode;
  344. pent->inode->nlink++;
  345. }
  346. } else {
  347. inode = g_new (struct inode, 1);
  348. entry->inode = inode;
  349. inode->local_filename = NULL;
  350. inode->inode = (current_archive->inode_counter)++;
  351. inode->nlink = 1;
  352. inode->dev = current_archive->rdev;
  353. inode->archive = current_archive;
  354. inode->mode = hstat.st_mode;
  355. #ifdef HAVE_STRUCT_STAT_ST_RDEV
  356. inode->rdev = hstat.st_rdev;
  357. #else
  358. inode->rdev = 0;
  359. #endif
  360. inode->uid = hstat.st_uid;
  361. inode->gid = hstat.st_gid;
  362. inode->size = hstat.st_size;
  363. inode->mtime = hstat.st_mtime;
  364. inode->atime = hstat.st_atime;
  365. inode->ctime = hstat.st_ctime;
  366. inode->first_in_subdir = NULL;
  367. inode->last_in_subdir = NULL;
  368. if (current_link_name != NULL
  369. && S_ISLNK (hstat.st_mode)) {
  370. inode->linkname = current_link_name;
  371. current_link_name = NULL;
  372. } else {
  373. if (S_ISLNK (hstat.st_mode))
  374. inode->mode &= ~S_IFLNK; /* You *DON'T* want to do this always */
  375. inode->linkname = NULL;
  376. }
  377. if (S_ISDIR (hstat.st_mode))
  378. extfs_make_dots (entry);
  379. }
  380. }
  381. read_extfs_continue:
  382. g_free (current_file_name);
  383. g_free (current_link_name);
  384. }
  385. }
  386. g_free (buffer);
  387. /* Check if extfs 'list' returned 0 */
  388. if (pclose (extfsd) != 0) {
  389. extfs_free (current_archive);
  390. close_error_pipe (1, _("Inconsistent extfs archive"));
  391. return -1;
  392. }
  393. close_error_pipe (1, NULL);
  394. *pparc = current_archive;
  395. return 0;
  396. }
  397. /*
  398. * Dissect the path and create corresponding superblock. Note that inname
  399. * can be changed and the result may point inside the original string.
  400. */
  401. static char *
  402. extfs_get_path_mangle (struct vfs_class *me, char *inname, struct archive **archive,
  403. int do_not_open)
  404. {
  405. char *local, *op;
  406. const char *archive_name;
  407. int result = -1;
  408. struct archive *parc;
  409. int fstype;
  410. archive_name = inname;
  411. vfs_split (inname, &local, &op);
  412. fstype = extfs_which (me, op);
  413. if (fstype == -1)
  414. return NULL;
  415. if (!local)
  416. local = inname + strlen (inname);
  417. /*
  418. * All filesystems should have some local archive, at least
  419. * it can be '/'.
  420. */
  421. for (parc = first_archive; parc != NULL; parc = parc->next)
  422. if (parc->name) {
  423. if (!strcmp (parc->name, archive_name)) {
  424. vfs_stamp (&vfs_extfs_ops, (vfsid) parc);
  425. goto return_success;
  426. }
  427. }
  428. result =
  429. do_not_open ? -1 : extfs_read_archive (fstype, archive_name,
  430. &parc);
  431. if (result == -1)
  432. ERRNOR (EIO, NULL);
  433. return_success:
  434. *archive = parc;
  435. return local;
  436. }
  437. /*
  438. * Dissect the path and create corresponding superblock.
  439. * The result should be freed.
  440. */
  441. static char *
  442. extfs_get_path (struct vfs_class *me, const char *inname, struct archive **archive,
  443. int do_not_open)
  444. {
  445. char *buf = g_strdup (inname);
  446. char *res = extfs_get_path_mangle (me, buf, archive, do_not_open);
  447. char *res2 = NULL;
  448. if (res)
  449. res2 = g_strdup (res);
  450. g_free (buf);
  451. return res2;
  452. }
  453. /* Return allocated path (without leading slash) inside the archive */
  454. static char *extfs_get_path_from_entry (struct entry *entry)
  455. {
  456. struct list {
  457. struct list *next;
  458. char *name;
  459. } *head, *p;
  460. char *localpath;
  461. size_t len;
  462. for (len = 0, head = 0; entry->dir; entry = entry->dir) {
  463. p = g_new (struct list, 1);
  464. p->next = head;
  465. p->name = entry->name;
  466. head = p;
  467. len += strlen (entry->name) + 1;
  468. }
  469. if (len == 0)
  470. return g_strdup ("");
  471. localpath = g_malloc (len);
  472. *localpath = '\0';
  473. while (head) {
  474. strcat (localpath, head->name);
  475. if (head->next)
  476. strcat (localpath, "/");
  477. p = head;
  478. head = head->next;
  479. g_free (p);
  480. }
  481. return (localpath);
  482. }
  483. struct loop_protect {
  484. struct entry *entry;
  485. struct loop_protect *next;
  486. };
  487. static int errloop;
  488. static int notadir;
  489. static struct entry *
  490. extfs_find_entry_int (struct entry *dir, char *name,
  491. struct loop_protect *list, int make_dirs, int make_file);
  492. static struct entry *
  493. extfs_resolve_symlinks_int (struct entry *entry,
  494. struct loop_protect *list)
  495. {
  496. struct entry *pent;
  497. struct loop_protect *looping;
  498. if (!S_ISLNK (entry->inode->mode))
  499. return entry;
  500. for (looping = list; looping != NULL; looping = looping->next)
  501. if (entry == looping->entry) { /* Here we protect us against symlink looping */
  502. errloop = 1;
  503. return NULL;
  504. }
  505. looping = g_new (struct loop_protect, 1);
  506. looping->entry = entry;
  507. looping->next = list;
  508. pent = extfs_find_entry_int (entry->dir, entry->inode->linkname, looping, 0, 0);
  509. g_free (looping);
  510. if (pent == NULL)
  511. my_errno = ENOENT;
  512. return pent;
  513. }
  514. static struct entry *extfs_resolve_symlinks (struct entry *entry)
  515. {
  516. struct entry *res;
  517. errloop = 0;
  518. notadir = 0;
  519. res = extfs_resolve_symlinks_int (entry, NULL);
  520. if (res == NULL) {
  521. if (errloop)
  522. my_errno = ELOOP;
  523. else if (notadir)
  524. my_errno = ENOTDIR;
  525. }
  526. return res;
  527. }
  528. static const char *
  529. extfs_get_archive_name (struct archive *archive)
  530. {
  531. const char *archive_name;
  532. if (archive->local_name)
  533. archive_name = archive->local_name;
  534. else
  535. archive_name = archive->name;
  536. if (!archive_name || !*archive_name)
  537. return "no_archive_name";
  538. else
  539. return archive_name;
  540. }
  541. /* Don't pass localname as NULL */
  542. static int
  543. extfs_cmd (const char *extfs_cmd, struct archive *archive,
  544. struct entry *entry, const char *localname)
  545. {
  546. char *file;
  547. char *quoted_file;
  548. char *quoted_localname;
  549. char *archive_name;
  550. char *mc_extfsdir;
  551. char *cmd;
  552. int retval;
  553. file = extfs_get_path_from_entry (entry);
  554. quoted_file = name_quote (file, 0);
  555. g_free (file);
  556. archive_name = name_quote (extfs_get_archive_name (archive), 0);
  557. quoted_localname = name_quote (localname, 0);
  558. mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR);
  559. cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype],
  560. extfs_cmd, archive_name, " ", quoted_file, " ",
  561. quoted_localname, (char *) NULL);
  562. g_free (quoted_file);
  563. g_free (quoted_localname);
  564. g_free (mc_extfsdir);
  565. g_free (archive_name);
  566. open_error_pipe ();
  567. retval = my_system (EXECUTE_AS_SHELL, shell, cmd);
  568. g_free (cmd);
  569. close_error_pipe (1, NULL);
  570. return retval;
  571. }
  572. static void
  573. extfs_run (struct vfs_class *me, const char *file)
  574. {
  575. struct archive *archive = NULL;
  576. char *p, *q, *archive_name, *mc_extfsdir;
  577. char *cmd;
  578. if ((p = extfs_get_path (me, file, &archive, 0)) == NULL)
  579. return;
  580. q = name_quote (p, 0);
  581. g_free (p);
  582. archive_name = name_quote (extfs_get_archive_name (archive), 0);
  583. mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR);
  584. cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype],
  585. " run ", archive_name, " ", q, (char *) NULL);
  586. g_free (mc_extfsdir);
  587. g_free (archive_name);
  588. g_free (q);
  589. shell_execute (cmd, 0);
  590. g_free (cmd);
  591. }
  592. static void *
  593. extfs_open (struct vfs_class *me, const char *file, int flags, int mode)
  594. {
  595. struct pseudofile *extfs_info;
  596. struct archive *archive = NULL;
  597. char *q;
  598. struct entry *entry;
  599. int local_handle;
  600. int created = 0;
  601. if ((q = extfs_get_path (me, file, &archive, 0)) == NULL)
  602. return NULL;
  603. entry = extfs_find_entry (archive->root_entry, q, 0, 0);
  604. if (entry == NULL && (flags & O_CREAT)) {
  605. /* Create new entry */
  606. entry = extfs_find_entry (archive->root_entry, q, 0, 1);
  607. created = (entry != NULL);
  608. }
  609. g_free (q);
  610. if (entry == NULL)
  611. return NULL;
  612. if ((entry = extfs_resolve_symlinks (entry)) == NULL)
  613. return NULL;
  614. if (S_ISDIR (entry->inode->mode))
  615. ERRNOR (EISDIR, NULL);
  616. if (entry->inode->local_filename == NULL) {
  617. char *local_filename;
  618. local_handle = vfs_mkstemps (&local_filename, "extfs", entry->name);
  619. if (local_handle == -1)
  620. return NULL;
  621. close (local_handle);
  622. if (!created && !(flags & O_TRUNC)
  623. && extfs_cmd (" copyout ", archive, entry, local_filename)) {
  624. unlink (local_filename);
  625. free (local_filename);
  626. my_errno = EIO;
  627. return NULL;
  628. }
  629. entry->inode->local_filename = local_filename;
  630. }
  631. local_handle =
  632. open (entry->inode->local_filename, NO_LINEAR (flags), mode);
  633. if (local_handle == -1)
  634. ERRNOR (EIO, NULL);
  635. extfs_info = g_new (struct pseudofile, 1);
  636. extfs_info->archive = archive;
  637. extfs_info->entry = entry;
  638. extfs_info->has_changed = created;
  639. extfs_info->local_handle = local_handle;
  640. /* i.e. we had no open files and now we have one */
  641. vfs_rmstamp (&vfs_extfs_ops, (vfsid) archive);
  642. archive->fd_usage++;
  643. return extfs_info;
  644. }
  645. static int extfs_read (void *data, char *buffer, int count)
  646. {
  647. struct pseudofile *file = (struct pseudofile *)data;
  648. return read (file->local_handle, buffer, count);
  649. }
  650. static int
  651. extfs_close (void *data)
  652. {
  653. struct pseudofile *file;
  654. int errno_code = 0;
  655. file = (struct pseudofile *) data;
  656. close (file->local_handle);
  657. /* Commit the file if it has changed */
  658. if (file->has_changed) {
  659. if (extfs_cmd
  660. (" copyin ", file->archive, file->entry,
  661. file->entry->inode->local_filename))
  662. errno_code = EIO;
  663. {
  664. struct stat file_status;
  665. if (stat (file->entry->inode->local_filename, &file_status) !=
  666. 0)
  667. errno_code = EIO;
  668. else
  669. file->entry->inode->size = file_status.st_size;
  670. }
  671. file->entry->inode->mtime = time (NULL);
  672. }
  673. file->archive->fd_usage--;
  674. if (!file->archive->fd_usage)
  675. vfs_stamp_create (&vfs_extfs_ops, file->archive);
  676. g_free (data);
  677. if (errno_code)
  678. ERRNOR (EIO, -1);
  679. return 0;
  680. }
  681. #define RECORDSIZE 512
  682. static struct entry*
  683. extfs_find_entry_int (struct entry *dir, char *name,
  684. struct loop_protect *list, int make_dirs, int make_file)
  685. {
  686. struct entry *pent, *pdir;
  687. char *p, *q, *name_end;
  688. char c;
  689. if (*name == '/') { /* Handle absolute paths */
  690. name++;
  691. dir = dir->inode->archive->root_entry;
  692. }
  693. pent = dir;
  694. p = name;
  695. name_end = name + strlen (name);
  696. q = strchr (p, '/');
  697. c = '/';
  698. if (!q)
  699. q = strchr (p, 0);
  700. for (; pent != NULL && c && *p; ){
  701. c = *q;
  702. *q = 0;
  703. if (strcmp (p, ".")){
  704. if (!strcmp (p, ".."))
  705. pent = pent->dir;
  706. else {
  707. if ((pent = extfs_resolve_symlinks_int (pent, list))==NULL){
  708. *q = c;
  709. return NULL;
  710. }
  711. if (!S_ISDIR (pent->inode->mode)){
  712. *q = c;
  713. notadir = 1;
  714. return NULL;
  715. }
  716. pdir = pent;
  717. for (pent = pent->inode->first_in_subdir; pent; pent = pent->next_in_dir)
  718. /* Hack: I keep the original semanthic unless
  719. q+1 would break in the strchr */
  720. if (!strcmp (pent->name, p)){
  721. if (q + 1 > name_end){
  722. *q = c;
  723. notadir = !S_ISDIR (pent->inode->mode);
  724. return pent;
  725. }
  726. break;
  727. }
  728. /* When we load archive, we create automagically
  729. * non-existant directories
  730. */
  731. if (pent == NULL && make_dirs) {
  732. pent = extfs_generate_entry (dir->inode->archive, p, pdir, S_IFDIR | 0777);
  733. }
  734. if (pent == NULL && make_file) {
  735. pent = extfs_generate_entry (dir->inode->archive, p, pdir, S_IFREG | 0666);
  736. }
  737. }
  738. }
  739. /* Next iteration */
  740. *q = c;
  741. p = q + 1;
  742. q = strchr (p, '/');
  743. if (!q)
  744. q = strchr (p, 0);
  745. }
  746. if (pent == NULL)
  747. my_errno = ENOENT;
  748. return pent;
  749. }
  750. static struct entry *extfs_find_entry (struct entry *dir, char *name, int make_dirs, int make_file)
  751. {
  752. struct entry *res;
  753. errloop = 0;
  754. notadir = 0;
  755. res = extfs_find_entry_int (dir, name, NULL, make_dirs, make_file);
  756. if (res == NULL) {
  757. if (errloop)
  758. my_errno = ELOOP;
  759. else if (notadir)
  760. my_errno = ENOTDIR;
  761. }
  762. return res;
  763. }
  764. static int extfs_errno (struct vfs_class *me)
  765. {
  766. (void) me;
  767. return my_errno;
  768. }
  769. static void * extfs_opendir (struct vfs_class *me, const char *dirname)
  770. {
  771. struct archive *archive = NULL;
  772. char *q;
  773. struct entry *entry;
  774. struct entry **info;
  775. if ((q = extfs_get_path (me, dirname, &archive, 0)) == NULL)
  776. return NULL;
  777. entry = extfs_find_entry (archive->root_entry, q, 0, 0);
  778. g_free (q);
  779. if (entry == NULL)
  780. return NULL;
  781. if ((entry = extfs_resolve_symlinks (entry)) == NULL)
  782. return NULL;
  783. if (!S_ISDIR (entry->inode->mode)) ERRNOR (ENOTDIR, NULL);
  784. info = g_new (struct entry *, 2);
  785. info[0] = entry->inode->first_in_subdir;
  786. info[1] = entry->inode->first_in_subdir;
  787. return info;
  788. }
  789. static void * extfs_readdir(void *data)
  790. {
  791. static union vfs_dirent dir;
  792. struct entry **info = (struct entry **) data;
  793. if (!*info)
  794. return NULL;
  795. g_strlcpy(dir.dent.d_name, (*info)->name, MC_MAXPATHLEN);
  796. compute_namelen(&dir.dent);
  797. *info = (*info)->next_in_dir;
  798. return (void *) &dir;
  799. }
  800. static int extfs_closedir (void *data)
  801. {
  802. g_free (data);
  803. return 0;
  804. }
  805. static void extfs_stat_move (struct stat *buf, const struct inode *inode)
  806. {
  807. buf->st_dev = inode->dev;
  808. buf->st_ino = inode->inode;
  809. buf->st_mode = inode->mode;
  810. buf->st_nlink = inode->nlink;
  811. buf->st_uid = inode->uid;
  812. buf->st_gid = inode->gid;
  813. #ifdef HAVE_STRUCT_STAT_ST_RDEV
  814. buf->st_rdev = inode->rdev;
  815. #endif
  816. buf->st_size = inode->size;
  817. #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
  818. buf->st_blksize = RECORDSIZE;
  819. #endif
  820. #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
  821. buf->st_blocks = (inode->size + RECORDSIZE - 1) / RECORDSIZE;
  822. #endif
  823. buf->st_atime = inode->atime;
  824. buf->st_mtime = inode->mtime;
  825. buf->st_ctime = inode->ctime;
  826. }
  827. static int
  828. extfs_internal_stat (struct vfs_class *me, const char *path, struct stat *buf,
  829. int resolve)
  830. {
  831. struct archive *archive;
  832. char *q;
  833. struct entry *entry;
  834. char *path2 = g_strdup (path);
  835. int result = -1;
  836. if ((q = extfs_get_path_mangle (me, path2, &archive, 0)) == NULL)
  837. goto cleanup;
  838. entry = extfs_find_entry (archive->root_entry, q, 0, 0);
  839. if (entry == NULL)
  840. goto cleanup;
  841. if (resolve && (entry = extfs_resolve_symlinks (entry)) == NULL)
  842. goto cleanup;
  843. extfs_stat_move (buf, entry->inode);
  844. result = 0;
  845. cleanup:
  846. g_free (path2);
  847. return result;
  848. }
  849. static int extfs_stat (struct vfs_class *me, const char *path, struct stat *buf)
  850. {
  851. return extfs_internal_stat (me, path, buf, 1);
  852. }
  853. static int extfs_lstat (struct vfs_class *me, const char *path, struct stat *buf)
  854. {
  855. return extfs_internal_stat (me, path, buf, 0);
  856. }
  857. static int extfs_fstat (void *data, struct stat *buf)
  858. {
  859. struct pseudofile *file = (struct pseudofile *)data;
  860. extfs_stat_move (buf, file->entry->inode);
  861. return 0;
  862. }
  863. static int
  864. extfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size)
  865. {
  866. struct archive *archive;
  867. char *q;
  868. size_t len;
  869. struct entry *entry;
  870. char *mpath = g_strdup (path);
  871. int result = -1;
  872. if ((q = extfs_get_path_mangle (me, mpath, &archive, 0)) == NULL)
  873. goto cleanup;
  874. entry = extfs_find_entry (archive->root_entry, q, 0, 0);
  875. if (entry == NULL)
  876. goto cleanup;
  877. if (!S_ISLNK (entry->inode->mode)) {
  878. me->verrno = EINVAL;
  879. goto cleanup;
  880. }
  881. len = strlen (entry->inode->linkname);
  882. if (size < len)
  883. len = size;
  884. /* readlink() does not append a NUL character to buf */
  885. memcpy (buf, entry->inode->linkname, result = len);
  886. cleanup:
  887. g_free (mpath);
  888. return result;
  889. }
  890. static int extfs_chmod (struct vfs_class *me, const char *path, int mode)
  891. {
  892. (void) me;
  893. (void) path;
  894. (void) mode;
  895. return 0;
  896. }
  897. static int extfs_write (void *data, const char *buf, int nbyte)
  898. {
  899. struct pseudofile *file = (struct pseudofile *)data;
  900. file->has_changed = 1;
  901. return write (file->local_handle, buf, nbyte);
  902. }
  903. static int extfs_unlink (struct vfs_class *me, const char *file)
  904. {
  905. struct archive *archive;
  906. char *q, *mpath = g_strdup (file);
  907. struct entry *entry;
  908. int result = -1;
  909. if ((q = extfs_get_path_mangle (me, mpath, &archive, 0)) == NULL)
  910. goto cleanup;
  911. entry = extfs_find_entry (archive->root_entry, q, 0, 0);
  912. if (entry == NULL)
  913. goto cleanup;
  914. if ((entry = extfs_resolve_symlinks (entry)) == NULL)
  915. goto cleanup;
  916. if (S_ISDIR (entry->inode->mode)) {
  917. me->verrno = EISDIR;
  918. goto cleanup;
  919. }
  920. if (extfs_cmd (" rm ", archive, entry, "")){
  921. my_errno = EIO;
  922. goto cleanup;
  923. }
  924. extfs_remove_entry (entry);
  925. result = 0;
  926. cleanup:
  927. g_free (mpath);
  928. return result;
  929. }
  930. static int extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode)
  931. {
  932. struct archive *archive;
  933. char *q, *mpath = g_strdup(path);
  934. struct entry *entry;
  935. int result = -1;
  936. (void) mode;
  937. if ((q = extfs_get_path_mangle (me, mpath, &archive, 0)) == NULL)
  938. goto cleanup;
  939. entry = extfs_find_entry (archive->root_entry, q, 0, 0);
  940. if (entry != NULL) {
  941. me->verrno = EEXIST;
  942. goto cleanup;
  943. }
  944. entry = extfs_find_entry (archive->root_entry, q, 1, 0);
  945. if (entry == NULL)
  946. goto cleanup;
  947. if ((entry = extfs_resolve_symlinks (entry)) == NULL)
  948. goto cleanup;
  949. if (!S_ISDIR (entry->inode->mode)) {
  950. me->verrno = ENOTDIR;
  951. goto cleanup;
  952. }
  953. if (extfs_cmd (" mkdir ", archive, entry, "")){
  954. my_errno = EIO;
  955. extfs_remove_entry (entry);
  956. goto cleanup;
  957. }
  958. result = 0;
  959. cleanup:
  960. g_free (mpath);
  961. return result;
  962. }
  963. static int extfs_rmdir (struct vfs_class *me, const char *path)
  964. {
  965. struct archive *archive;
  966. char *q, *mpath = g_strdup(path);
  967. struct entry *entry;
  968. int result = -1;
  969. if ((q = extfs_get_path_mangle (me, mpath, &archive, 0)) == NULL)
  970. goto cleanup;
  971. entry = extfs_find_entry (archive->root_entry, q, 0, 0);
  972. if (entry == NULL)
  973. goto cleanup;
  974. if ((entry = extfs_resolve_symlinks (entry)) == NULL)
  975. goto cleanup;
  976. if (!S_ISDIR (entry->inode->mode)) {
  977. me->verrno = ENOTDIR;
  978. goto cleanup;
  979. }
  980. if (extfs_cmd (" rmdir ", archive, entry, "")){
  981. my_errno = EIO;
  982. goto cleanup;
  983. }
  984. extfs_remove_entry (entry);
  985. result = 0;
  986. cleanup:
  987. g_free (mpath);
  988. return result;
  989. }
  990. static int
  991. extfs_chdir (struct vfs_class *me, const char *path)
  992. {
  993. struct archive *archive = NULL;
  994. char *q;
  995. struct entry *entry;
  996. my_errno = ENOTDIR;
  997. if ((q = extfs_get_path (me, path, &archive, 0)) == NULL)
  998. return -1;
  999. entry = extfs_find_entry (archive->root_entry, q, 0, 0);
  1000. g_free (q);
  1001. if (!entry)
  1002. return -1;
  1003. entry = extfs_resolve_symlinks (entry);
  1004. if ((!entry) || (!S_ISDIR (entry->inode->mode)))
  1005. return -1;
  1006. my_errno = 0;
  1007. return 0;
  1008. }
  1009. static int extfs_lseek (void *data, off_t offset, int whence)
  1010. {
  1011. struct pseudofile *file = (struct pseudofile *) data;
  1012. return lseek (file->local_handle, offset, whence);
  1013. }
  1014. static vfsid
  1015. extfs_getid (struct vfs_class *me, const char *path)
  1016. {
  1017. struct archive *archive = NULL;
  1018. char *p;
  1019. if (!(p = extfs_get_path (me, path, &archive, 1)))
  1020. return NULL;
  1021. g_free (p);
  1022. return (vfsid) archive;
  1023. }
  1024. static int extfs_nothingisopen (vfsid id)
  1025. {
  1026. if (((struct archive *)id)->fd_usage <= 0)
  1027. return 1;
  1028. return 0;
  1029. }
  1030. static void extfs_remove_entry (struct entry *e)
  1031. {
  1032. int i = --(e->inode->nlink);
  1033. struct entry *pe, *ent, *prev;
  1034. if (S_ISDIR (e->inode->mode) && e->inode->first_in_subdir != NULL) {
  1035. struct entry *f = e->inode->first_in_subdir;
  1036. e->inode->first_in_subdir = NULL;
  1037. extfs_remove_entry (f);
  1038. }
  1039. pe = e->dir;
  1040. if (e == pe->inode->first_in_subdir)
  1041. pe->inode->first_in_subdir = e->next_in_dir;
  1042. prev = NULL;
  1043. for (ent = pe->inode->first_in_subdir; ent && ent->next_in_dir;
  1044. ent = ent->next_in_dir)
  1045. if (e == ent->next_in_dir) {
  1046. prev = ent;
  1047. break;
  1048. }
  1049. if (prev)
  1050. prev->next_in_dir = e->next_in_dir;
  1051. if (e == pe->inode->last_in_subdir)
  1052. pe->inode->last_in_subdir = prev;
  1053. if (i <= 0) {
  1054. if (e->inode->local_filename != NULL) {
  1055. unlink (e->inode->local_filename);
  1056. free (e->inode->local_filename);
  1057. }
  1058. g_free (e->inode->linkname);
  1059. g_free (e->inode);
  1060. }
  1061. g_free (e->name);
  1062. g_free (e);
  1063. }
  1064. static void extfs_free_entry (struct entry *e)
  1065. {
  1066. int i = --(e->inode->nlink);
  1067. if (S_ISDIR (e->inode->mode) && e->inode->first_in_subdir != NULL) {
  1068. struct entry *f = e->inode->first_in_subdir;
  1069. e->inode->first_in_subdir = NULL;
  1070. extfs_free_entry (f);
  1071. }
  1072. if (i <= 0) {
  1073. if (e->inode->local_filename != NULL) {
  1074. unlink (e->inode->local_filename);
  1075. free (e->inode->local_filename);
  1076. }
  1077. g_free (e->inode->linkname);
  1078. g_free (e->inode);
  1079. }
  1080. if (e->next_in_dir != NULL)
  1081. extfs_free_entry (e->next_in_dir);
  1082. g_free (e->name);
  1083. g_free (e);
  1084. }
  1085. static void extfs_free (vfsid id)
  1086. {
  1087. struct archive *parc;
  1088. struct archive *archive = (struct archive *)id;
  1089. if (archive == first_archive) {
  1090. first_archive = archive->next;
  1091. } else {
  1092. for (parc = first_archive; parc != NULL; parc = parc->next)
  1093. if (parc->next == archive) {
  1094. parc->next = archive->next;
  1095. break;
  1096. }
  1097. }
  1098. extfs_free_archive (archive);
  1099. }
  1100. static char *
  1101. extfs_getlocalcopy (struct vfs_class *me, const char *path)
  1102. {
  1103. struct pseudofile *fp =
  1104. (struct pseudofile *) extfs_open (me, path, O_RDONLY, 0);
  1105. char *p;
  1106. if (fp == NULL)
  1107. return NULL;
  1108. if (fp->entry->inode->local_filename == NULL) {
  1109. extfs_close ((void *) fp);
  1110. return NULL;
  1111. }
  1112. p = g_strdup (fp->entry->inode->local_filename);
  1113. fp->archive->fd_usage++;
  1114. extfs_close ((void *) fp);
  1115. return p;
  1116. }
  1117. static int
  1118. extfs_ungetlocalcopy (struct vfs_class *me, const char *path,
  1119. const char *local, int has_changed)
  1120. {
  1121. struct pseudofile *fp =
  1122. (struct pseudofile *) extfs_open (me, path, O_RDONLY, 0);
  1123. if (fp == NULL)
  1124. return 0;
  1125. if (!strcmp (fp->entry->inode->local_filename, local)) {
  1126. fp->archive->fd_usage--;
  1127. fp->has_changed |= has_changed;
  1128. extfs_close ((void *) fp);
  1129. return 0;
  1130. } else {
  1131. /* Should not happen */
  1132. extfs_close ((void *) fp);
  1133. return 0;
  1134. }
  1135. }
  1136. static int extfs_init (struct vfs_class *me)
  1137. {
  1138. FILE *cfg;
  1139. char *mc_extfsini;
  1140. char key[256];
  1141. (void) me;
  1142. mc_extfsini = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR "extfs.ini");
  1143. cfg = fopen (mc_extfsini, "r");
  1144. /* We may not use vfs_die() message or message or similar,
  1145. * UI is not initialized at this time and message would not
  1146. * appear on screen. */
  1147. if (!cfg) {
  1148. fprintf (stderr, _("Warning: file %s not found\n"), mc_extfsini);
  1149. g_free (mc_extfsini);
  1150. return 0;
  1151. }
  1152. extfs_no = 0;
  1153. while (extfs_no < MAXEXTFS && fgets (key, sizeof (key), cfg)) {
  1154. char *c;
  1155. /* Handle those with a trailing ':', those flag that the
  1156. * file system does not require an archive to work
  1157. */
  1158. if (*key == '[') {
  1159. fprintf(stderr, "Warning: You need to update your %s file.\n",
  1160. mc_extfsini);
  1161. fclose(cfg);
  1162. g_free (mc_extfsini);
  1163. return 0;
  1164. }
  1165. if (*key == '#' || *key == '\n')
  1166. continue;
  1167. if ((c = strchr (key, '\n'))){
  1168. *c-- = 0;
  1169. } else { /* Last line without newline or strlen (key) > 255 */
  1170. c = &key [strlen (key) - 1];
  1171. }
  1172. extfs_need_archive [extfs_no] = !(*c == ':');
  1173. if (*c == ':')
  1174. *c = 0;
  1175. if (!(*key))
  1176. continue;
  1177. extfs_prefixes [extfs_no++] = g_strdup (key);
  1178. }
  1179. fclose(cfg);
  1180. g_free (mc_extfsini);
  1181. return 1;
  1182. }
  1183. static int extfs_which (struct vfs_class *me, const char *path)
  1184. {
  1185. int i;
  1186. (void) me;
  1187. for (i = 0; i < extfs_no; i++)
  1188. if (!strcmp (path, extfs_prefixes [i]))
  1189. return i;
  1190. return -1;
  1191. }
  1192. static void extfs_done (struct vfs_class *me)
  1193. {
  1194. int i;
  1195. struct archive *ar;
  1196. (void) me;
  1197. for (ar = first_archive; ar != NULL;) {
  1198. extfs_free ((vfsid) ar);
  1199. ar = first_archive;
  1200. }
  1201. for (i = 0; i < extfs_no; i++ )
  1202. g_free (extfs_prefixes [i]);
  1203. extfs_no = 0;
  1204. }
  1205. static int
  1206. extfs_setctl (struct vfs_class *me, const char *path, int ctlop, void *arg)
  1207. {
  1208. (void) arg;
  1209. if (ctlop == VFS_SETCTL_RUN) {
  1210. extfs_run (me, path);
  1211. return 1;
  1212. }
  1213. return 0;
  1214. }
  1215. void
  1216. init_extfs (void)
  1217. {
  1218. vfs_extfs_ops.name = "extfs";
  1219. vfs_extfs_ops.init = extfs_init;
  1220. vfs_extfs_ops.done = extfs_done;
  1221. vfs_extfs_ops.fill_names = extfs_fill_names;
  1222. vfs_extfs_ops.which = extfs_which;
  1223. vfs_extfs_ops.open = extfs_open;
  1224. vfs_extfs_ops.close = extfs_close;
  1225. vfs_extfs_ops.read = extfs_read;
  1226. vfs_extfs_ops.write = extfs_write;
  1227. vfs_extfs_ops.opendir = extfs_opendir;
  1228. vfs_extfs_ops.readdir = extfs_readdir;
  1229. vfs_extfs_ops.closedir = extfs_closedir;
  1230. vfs_extfs_ops.stat = extfs_stat;
  1231. vfs_extfs_ops.lstat = extfs_lstat;
  1232. vfs_extfs_ops.fstat = extfs_fstat;
  1233. vfs_extfs_ops.chmod = extfs_chmod;
  1234. vfs_extfs_ops.readlink = extfs_readlink;
  1235. vfs_extfs_ops.unlink = extfs_unlink;
  1236. vfs_extfs_ops.chdir = extfs_chdir;
  1237. vfs_extfs_ops.ferrno = extfs_errno;
  1238. vfs_extfs_ops.lseek = extfs_lseek;
  1239. vfs_extfs_ops.getid = extfs_getid;
  1240. vfs_extfs_ops.nothingisopen = extfs_nothingisopen;
  1241. vfs_extfs_ops.free = extfs_free;
  1242. vfs_extfs_ops.getlocalcopy = extfs_getlocalcopy;
  1243. vfs_extfs_ops.ungetlocalcopy = extfs_ungetlocalcopy;
  1244. vfs_extfs_ops.mkdir = extfs_mkdir;
  1245. vfs_extfs_ops.rmdir = extfs_rmdir;
  1246. vfs_extfs_ops.setctl = extfs_setctl;
  1247. vfs_register_class (&vfs_extfs_ops);
  1248. }