extfs.c 35 KB

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