This source file includes following definitions.
- extfs_super_new
- extfs_entry_new
- extfs_fill_name
- extfs_cmp_archive
- extfs_generate_entry
- extfs_find_entry_int
- extfs_find_entry
- extfs_fill_names
- extfs_free_inode
- extfs_free_archive
- extfs_skip_leading_dotslash
- extfs_add_file
- extfs_open_archive
- extfs_read_archive
- extfs_which
- extfs_open_and_read_archive
- extfs_get_path
- extfs_get_path_from_entry
- extfs_resolve_symlinks_int
- extfs_resolve_symlinks
- extfs_get_archive_name
- extfs_cmd
- extfs_run
- extfs_open
- extfs_read
- extfs_close
- extfs_errno
- extfs_opendir
- extfs_readdir
- extfs_closedir
- extfs_stat_move
- extfs_internal_stat
- extfs_stat
- extfs_lstat
- extfs_fstat
- extfs_readlink
- extfs_chown
- extfs_chmod
- extfs_write
- extfs_unlink
- extfs_mkdir
- extfs_rmdir
- extfs_chdir
- extfs_lseek
- extfs_getid
- extfs_getlocalcopy
- extfs_ungetlocalcopy
- extfs_get_plugins
- extfs_init
- extfs_done
- extfs_setctl
- vfs_init_extfs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 #include <config.h>
41
42 #include <stdio.h>
43 #include <ctype.h>
44 #include <string.h>
45 #include <stdlib.h>
46 #include <sys/types.h>
47 #include <sys/stat.h>
48 #include <unistd.h>
49 #include <signal.h>
50 #include <errno.h>
51 #include <sys/wait.h>
52
53 #include "lib/global.h"
54 #include "lib/fileloc.h"
55 #include "lib/mcconfig.h"
56 #include "lib/util.h"
57 #include "lib/widget.h"
58
59 #include "src/execute.h"
60
61 #include "lib/vfs/vfs.h"
62 #include "lib/vfs/utilvfs.h"
63 #include "lib/vfs/xdirentry.h"
64 #include "lib/vfs/gc.h"
65
66 #include "extfs.h"
67
68
69
70
71
72 #undef ERRNOR
73 #define ERRNOR(x,y) do { my_errno = x; return y; } while(0)
74
75 #define RECORDSIZE 512
76
77 #define EXTFS_SUPER(a) ((struct extfs_super_t *) (a))
78
79
80
81 struct extfs_super_t
82 {
83 struct vfs_s_super base;
84
85 int fstype;
86 char *local_name;
87 struct stat local_stat;
88 dev_t rdev;
89 };
90
91 typedef struct
92 {
93 char *path;
94 char *prefix;
95 gboolean need_archive;
96 } extfs_plugin_info_t;
97
98
99
100 static GArray *extfs_plugins = NULL;
101
102 static gboolean errloop;
103 static gboolean notadir;
104
105 static struct vfs_s_subclass extfs_subclass;
106 static struct vfs_class *vfs_extfs_ops = VFS_CLASS (&extfs_subclass);
107
108 static int my_errno = 0;
109
110
111
112
113
114 static struct vfs_s_entry *extfs_resolve_symlinks_int (struct vfs_s_entry *entry, GSList * list);
115
116
117
118 static struct extfs_super_t *
119 extfs_super_new (struct vfs_class *me, const char *name, const vfs_path_t * local_name_vpath,
120 int fstype)
121 {
122 struct extfs_super_t *super;
123 struct vfs_s_super *vsuper;
124
125 super = g_new0 (struct extfs_super_t, 1);
126 vsuper = VFS_SUPER (super);
127
128 vsuper->me = me;
129 vsuper->name = g_strdup (name);
130
131 super->fstype = fstype;
132
133 if (local_name_vpath != NULL)
134 {
135 super->local_name = g_strdup (vfs_path_get_last_path_str (local_name_vpath));
136 mc_stat (local_name_vpath, &super->local_stat);
137 }
138
139 VFS_SUBCLASS (me)->supers = g_list_prepend (VFS_SUBCLASS (me)->supers, super);
140
141 return super;
142 }
143
144
145
146
147 static struct vfs_s_entry *
148 extfs_entry_new (struct vfs_class *me, const char *name, struct vfs_s_inode *inode)
149 {
150 struct vfs_s_entry *entry;
151
152 (void) me;
153
154 entry = g_new0 (struct vfs_s_entry, 1);
155
156 entry->name = g_strdup (name);
157 entry->ino = inode;
158
159 return entry;
160 }
161
162
163
164 static void
165 extfs_fill_name (void *data, void *user_data)
166 {
167 struct vfs_s_super *a = VFS_SUPER (data);
168 fill_names_f func = (fill_names_f) user_data;
169 extfs_plugin_info_t *info;
170 char *name;
171
172 info = &g_array_index (extfs_plugins, extfs_plugin_info_t, EXTFS_SUPER (a)->fstype);
173 name =
174 g_strconcat (a->name != NULL ? a->name : "", PATH_SEP_STR, info->prefix,
175 VFS_PATH_URL_DELIMITER, (char *) NULL);
176 func (name);
177 g_free (name);
178 }
179
180
181
182 static gint
183 extfs_cmp_archive (const void *a, const void *b)
184 {
185 const struct vfs_s_super *ar = (const struct vfs_s_super *) a;
186 const char *archive_name = (const char *) b;
187
188 return (ar->name != NULL && strcmp (ar->name, archive_name) == 0) ? 0 : 1;
189 }
190
191
192
193 static struct vfs_s_entry *
194 extfs_generate_entry (struct extfs_super_t *archive, const char *name, struct vfs_s_inode *parent,
195 mode_t mode)
196 {
197 struct vfs_class *me = VFS_SUPER (archive)->me;
198 struct stat st;
199 mode_t myumask;
200 struct vfs_s_inode *inode;
201 struct vfs_s_entry *entry;
202
203 memset (&st, 0, sizeof (st));
204 st.st_ino = VFS_SUPER (archive)->ino_usage++;
205 st.st_dev = archive->rdev;
206 myumask = umask (022);
207 umask (myumask);
208 st.st_mode = mode & ~myumask;
209 st.st_uid = getuid ();
210 st.st_gid = getgid ();
211 st.st_mtime = time (NULL);
212 st.st_atime = st.st_mtime;
213 st.st_ctime = st.st_mtime;
214 st.st_nlink = 1;
215
216 inode = vfs_s_new_inode (me, VFS_SUPER (archive), &st);
217 entry = vfs_s_new_entry (me, name, inode);
218 if (parent != NULL)
219 vfs_s_insert_entry (me, parent, entry);
220
221 return entry;
222 }
223
224
225
226 static struct vfs_s_entry *
227 extfs_find_entry_int (struct vfs_s_inode *dir, const char *name, GSList * list, int flags)
228 {
229 struct vfs_s_entry *pent, *pdir;
230 const char *p, *name_end;
231 char *q;
232 char c = PATH_SEP;
233 struct extfs_super_t *super;
234
235 if (g_path_is_absolute (name))
236 {
237
238 name = g_path_skip_root (name);
239 dir = dir->super->root;
240 }
241
242 super = EXTFS_SUPER (dir->super);
243 pent = dir->ent;
244 p = name;
245 name_end = name + strlen (name);
246
247 while ((pent != NULL) && (c != '\0') && (*p != '\0'))
248 {
249 q = strchr (p, PATH_SEP);
250 if (q == NULL)
251 q = (char *) name_end;
252
253 c = *q;
254 *q = '\0';
255
256 if (DIR_IS_DOTDOT (p))
257 pent = pent->dir->ent;
258 else
259 {
260 GList *pl;
261
262 pent = extfs_resolve_symlinks_int (pent, list);
263 if (pent == NULL)
264 {
265 *q = c;
266 return NULL;
267 }
268
269 if (!S_ISDIR (pent->ino->st.st_mode))
270 {
271 *q = c;
272 notadir = TRUE;
273 return NULL;
274 }
275
276 pdir = pent;
277 pl = g_queue_find_custom (pent->ino->subdir, p, vfs_s_entry_compare);
278 pent = pl != NULL ? VFS_ENTRY (pl->data) : NULL;
279 if (pent != NULL && q + 1 > name_end)
280 {
281
282 *q = c;
283 notadir = !S_ISDIR (pent->ino->st.st_mode);
284 return pent;
285 }
286
287
288 if (pent == NULL && (flags & FL_MKDIR) != 0)
289 pent = extfs_generate_entry (super, p, pdir->ino, S_IFDIR | 0777);
290 if (pent == NULL && (flags & FL_MKFILE) != 0)
291 pent = extfs_generate_entry (super, p, pdir->ino, S_IFREG | 0666);
292 }
293
294
295 *q = c;
296 if (c != '\0')
297 p = q + 1;
298 }
299 if (pent == NULL)
300 my_errno = ENOENT;
301 return pent;
302 }
303
304
305
306 static struct vfs_s_entry *
307 extfs_find_entry (struct vfs_s_inode *dir, const char *name, int flags)
308 {
309 struct vfs_s_entry *res;
310
311 errloop = FALSE;
312 notadir = FALSE;
313
314 res = extfs_find_entry_int (dir, name, NULL, flags);
315 if (res == NULL)
316 {
317 if (errloop)
318 my_errno = ELOOP;
319 else if (notadir)
320 my_errno = ENOTDIR;
321 }
322 return res;
323 }
324
325
326
327 static void
328 extfs_fill_names (struct vfs_class *me, fill_names_f func)
329 {
330 g_list_foreach (VFS_SUBCLASS (me)->supers, extfs_fill_name, func);
331 }
332
333
334
335
336 static void
337 extfs_free_inode (struct vfs_class *me, struct vfs_s_inode *ino)
338 {
339 (void) me;
340
341 if (ino->localname != NULL)
342 {
343 unlink (ino->localname);
344 MC_PTR_FREE (ino->localname);
345 }
346 }
347
348
349
350 static void
351 extfs_free_archive (struct vfs_class *me, struct vfs_s_super *psup)
352 {
353 struct extfs_super_t *archive = EXTFS_SUPER (psup);
354
355 (void) me;
356
357 if (archive->local_name != NULL)
358 {
359 struct stat my;
360 vfs_path_t *local_name_vpath, *name_vpath;
361
362 local_name_vpath = vfs_path_from_str (archive->local_name);
363 name_vpath = vfs_path_from_str (psup->name);
364 mc_stat (local_name_vpath, &my);
365 mc_ungetlocalcopy (name_vpath, local_name_vpath,
366 archive->local_stat.st_mtime != my.st_mtime);
367 vfs_path_free (local_name_vpath, TRUE);
368 vfs_path_free (name_vpath, TRUE);
369 g_free (archive->local_name);
370 }
371 }
372
373
374
375 static inline char *
376 extfs_skip_leading_dotslash (char *s)
377 {
378
379
380
381
382
383
384
385
386
387 if (s[0] == '.' && s[1] == PATH_SEP)
388 s += 2;
389
390 return s;
391 }
392
393
394
395 static int
396 extfs_add_file (struct extfs_super_t *archive, const char *file_name)
397 {
398 struct vfs_s_super *super = VFS_SUPER (archive);
399 struct stat hstat;
400 char *current_file_name = NULL, *current_link_name = NULL;
401 int ret = 0;
402
403 if (vfs_parse_ls_lga (file_name, &hstat, ¤t_file_name, ¤t_link_name, NULL))
404 {
405 char *cfn = current_file_name;
406
407 if (*cfn != '\0')
408 {
409 struct vfs_s_entry *entry;
410 struct vfs_s_entry *pent = NULL;
411 struct vfs_s_inode *inode;
412 char *p, *q;
413
414 cfn = extfs_skip_leading_dotslash (cfn);
415 if (IS_PATH_SEP (*cfn))
416 cfn++;
417 p = strchr (cfn, '\0');
418 if (p != cfn && IS_PATH_SEP (p[-1]))
419 p[-1] = '\0';
420 p = strrchr (cfn, PATH_SEP);
421 if (p == NULL)
422 {
423 p = cfn;
424 q = strchr (cfn, '\0');
425 }
426 else
427 {
428 *(p++) = '\0';
429 q = cfn;
430 }
431
432 if (*q != '\0')
433 {
434 pent = extfs_find_entry (super->root, q, FL_MKDIR);
435 if (pent == NULL)
436 {
437 ret = -1;
438 goto done;
439 }
440 }
441
442 if (pent != NULL)
443 {
444 entry = extfs_entry_new (super->me, p, pent->ino);
445 entry->dir = pent->ino;
446 g_queue_push_tail (pent->ino->subdir, entry);
447 }
448 else
449 {
450 entry = extfs_entry_new (super->me, p, super->root);
451 entry->dir = super->root;
452 g_queue_push_tail (super->root->subdir, entry);
453 }
454
455 if (!S_ISLNK (hstat.st_mode) && (current_link_name != NULL))
456 {
457 pent = extfs_find_entry (super->root, current_link_name, FL_NONE);
458 if (pent == NULL)
459 {
460 ret = -1;
461 goto done;
462 }
463
464 pent->ino->st.st_nlink++;
465 entry->ino = pent->ino;
466 }
467 else
468 {
469 struct stat st;
470
471 memset (&st, 0, sizeof (st));
472 st.st_ino = super->ino_usage++;
473 st.st_nlink = 1;
474 st.st_dev = archive->rdev;
475 st.st_mode = hstat.st_mode;
476 #ifdef HAVE_STRUCT_STAT_ST_RDEV
477 st.st_rdev = hstat.st_rdev;
478 #endif
479 st.st_uid = hstat.st_uid;
480 st.st_gid = hstat.st_gid;
481 st.st_size = hstat.st_size;
482 st.st_mtime = hstat.st_mtime;
483 st.st_atime = hstat.st_atime;
484 st.st_ctime = hstat.st_ctime;
485
486 if (current_link_name == NULL && S_ISLNK (hstat.st_mode))
487 st.st_mode &= ~S_IFLNK;
488
489 inode = vfs_s_new_inode (super->me, super, &st);
490 inode->ent = entry;
491 entry->ino = inode;
492
493 if (current_link_name != NULL && S_ISLNK (hstat.st_mode))
494 {
495 inode->linkname = current_link_name;
496 current_link_name = NULL;
497 }
498 }
499 }
500
501 done:
502 g_free (current_file_name);
503 g_free (current_link_name);
504 }
505
506 return ret;
507 }
508
509
510
511 static mc_pipe_t *
512 extfs_open_archive (int fstype, const char *name, struct extfs_super_t **pparc, GError ** error)
513 {
514 const extfs_plugin_info_t *info;
515 static dev_t archive_counter = 0;
516 mc_pipe_t *result = NULL;
517 mode_t mode;
518 char *cmd = NULL;
519 struct stat mystat;
520 struct extfs_super_t *current_archive;
521 struct vfs_s_entry *root_entry;
522 char *tmp = NULL;
523 vfs_path_t *local_name_vpath = NULL;
524 const char *local_last_path = NULL;
525 vfs_path_t *name_vpath;
526
527 memset (&mystat, 0, sizeof (mystat));
528
529 name_vpath = vfs_path_from_str (name);
530 info = &g_array_index (extfs_plugins, extfs_plugin_info_t, fstype);
531
532 if (info->need_archive)
533 {
534 if (mc_stat (name_vpath, &mystat) == -1)
535 goto ret;
536
537 if (!vfs_file_is_local (name_vpath))
538 {
539 local_name_vpath = mc_getlocalcopy (name_vpath);
540 if (local_name_vpath == NULL)
541 goto ret;
542 }
543
544 local_last_path = vfs_path_get_last_path_str (local_name_vpath);
545 if (local_last_path == NULL)
546 tmp = name_quote (vfs_path_get_last_path_str (name_vpath), FALSE);
547 }
548
549 if (local_last_path != NULL)
550 cmd = g_strconcat (info->path, info->prefix, " list ", local_last_path, (char *) NULL);
551 else if (tmp != NULL)
552 {
553 cmd = g_strconcat (info->path, info->prefix, " list ", tmp, (char *) NULL);
554 g_free (tmp);
555 }
556
557 if (cmd != NULL)
558 {
559 result = mc_popen (cmd, TRUE, TRUE, error);
560 g_free (cmd);
561 }
562
563 if (result == NULL)
564 {
565 if (local_name_vpath != NULL)
566 {
567 mc_ungetlocalcopy (name_vpath, local_name_vpath, FALSE);
568 vfs_path_free (local_name_vpath, TRUE);
569 }
570 goto ret;
571 }
572
573 current_archive = extfs_super_new (vfs_extfs_ops, name, local_name_vpath, fstype);
574 current_archive->rdev = archive_counter++;
575 vfs_path_free (local_name_vpath, TRUE);
576
577 mode = mystat.st_mode & 07777;
578 if (mode & 0400)
579 mode |= 0100;
580 if (mode & 0040)
581 mode |= 0010;
582 if (mode & 0004)
583 mode |= 0001;
584 mode |= S_IFDIR;
585
586 root_entry = extfs_generate_entry (current_archive, PATH_SEP_STR, NULL, mode);
587 root_entry->ino->st.st_uid = mystat.st_uid;
588 root_entry->ino->st.st_gid = mystat.st_gid;
589 root_entry->ino->st.st_atime = mystat.st_atime;
590 root_entry->ino->st.st_ctime = mystat.st_ctime;
591 root_entry->ino->st.st_mtime = mystat.st_mtime;
592 root_entry->ino->ent = root_entry;
593 VFS_SUPER (current_archive)->root = root_entry->ino;
594
595 *pparc = current_archive;
596
597 ret:
598 vfs_path_free (name_vpath, TRUE);
599 return result;
600 }
601
602
603
604
605
606
607
608 static int
609 extfs_read_archive (mc_pipe_t * pip, struct extfs_super_t *archive, GError ** error)
610 {
611 int ret = 0;
612 GString *buffer;
613 GString *err_msg = NULL;
614 GString *remain_file_name = NULL;
615
616 while (ret != -1)
617 {
618
619 pip->out.len = MC_PIPE_BUFSIZE;
620 pip->err.len = MC_PIPE_BUFSIZE;
621
622 mc_pread (pip, error);
623
624 if (*error != NULL)
625 return (-1);
626
627 if (pip->err.len > 0)
628 {
629
630 if (err_msg == NULL)
631 err_msg = g_string_new_len (pip->err.buf, pip->err.len);
632 else
633 {
634 if (err_msg->str[err_msg->len - 1] != '\n')
635 g_string_append_c (err_msg, '\n');
636 g_string_append_len (err_msg, pip->err.buf, pip->err.len);
637 }
638 }
639
640 if (pip->out.len == MC_PIPE_STREAM_EOF)
641 break;
642
643 if (pip->out.len == 0)
644 continue;
645
646 if (pip->out.len == MC_PIPE_ERROR_READ)
647 return (-1);
648
649 while (ret != -1 && (buffer = mc_pstream_get_string (&pip->out)) != NULL)
650 {
651
652
653 if (buffer->str[buffer->len - 1] == '\n')
654 {
655
656
657 g_string_truncate (buffer, buffer->len - 1);
658
659
660 if (remain_file_name != NULL)
661 {
662 g_string_append_len (remain_file_name, buffer->str, buffer->len);
663 g_string_free (buffer, TRUE);
664 buffer = remain_file_name;
665 remain_file_name = NULL;
666 }
667 }
668 else
669 {
670
671
672 if (remain_file_name == NULL)
673 remain_file_name = buffer;
674 else
675 {
676 g_string_append_len (remain_file_name, buffer->str, buffer->len);
677 g_string_free (buffer, TRUE);
678 }
679
680 continue;
681 }
682
683 ret = extfs_add_file (archive, buffer->str);
684
685 g_string_free (buffer, TRUE);
686 }
687 }
688
689 if (remain_file_name != NULL)
690 g_string_free (remain_file_name, TRUE);
691
692 if (err_msg != NULL)
693 {
694 if (*error == NULL)
695 mc_propagate_error (error, 0, "%s", err_msg->str);
696
697 g_string_free (err_msg, TRUE);
698 }
699
700 return ret;
701 }
702
703
704
705 static int
706 extfs_which (struct vfs_class *me, const char *path)
707 {
708 size_t path_len;
709 size_t i;
710
711 (void) me;
712
713 path_len = strlen (path);
714
715 for (i = 0; i < extfs_plugins->len; i++)
716 {
717 extfs_plugin_info_t *info;
718
719 info = &g_array_index (extfs_plugins, extfs_plugin_info_t, i);
720
721 if ((strncmp (path, info->prefix, path_len) == 0)
722 && ((info->prefix[path_len] == '\0') || (info->prefix[path_len] == '+')))
723 return i;
724 }
725 return -1;
726 }
727
728
729
730 static int
731 extfs_open_and_read_archive (int fstype, const char *name, struct extfs_super_t **archive)
732 {
733 int result = -1;
734 struct extfs_super_t *a;
735 mc_pipe_t *pip;
736 GError *error = NULL;
737
738 pip = extfs_open_archive (fstype, name, archive, &error);
739
740 a = *archive;
741
742 if (pip == NULL)
743 {
744 const extfs_plugin_info_t *info;
745
746 info = &g_array_index (extfs_plugins, extfs_plugin_info_t, fstype);
747 message (D_ERROR, MSG_ERROR, _("Cannot open %s archive\n%s:\n%s"), info->prefix, name,
748 error->message);
749 g_error_free (error);
750 }
751 else
752 {
753 result = extfs_read_archive (pip, a, &error);
754
755 if (result != 0)
756 VFS_SUPER (a)->me->free (VFS_SUPER (a));
757
758 if (error != NULL)
759 {
760 message (D_ERROR, MSG_ERROR, _("EXTFS virtual file system:\n%s"), error->message);
761 g_error_free (error);
762 }
763
764 mc_pclose (pip, NULL);
765 }
766
767 return result;
768 }
769
770
771
772
773
774 static const char *
775 extfs_get_path (const vfs_path_t * vpath, struct extfs_super_t **archive, int flags)
776 {
777 char *archive_name;
778 int result = -1;
779 GList *parc;
780 int fstype;
781 const vfs_path_element_t *path_element;
782 struct extfs_super_t *a = NULL;
783
784 path_element = vfs_path_get_by_index (vpath, -1);
785
786 fstype = extfs_which (path_element->class, path_element->vfs_prefix);
787 if (fstype == -1)
788 return NULL;
789
790 archive_name = vfs_path_to_str_elements_count (vpath, -1);
791
792
793 parc = g_list_find_custom (extfs_subclass.supers, archive_name, extfs_cmp_archive);
794 if (parc != NULL)
795 {
796 a = EXTFS_SUPER (parc->data);
797 vfs_stamp (vfs_extfs_ops, (vfsid) a);
798 g_free (archive_name);
799 }
800 else
801 {
802 if ((flags & FL_NO_OPEN) == 0)
803 result = extfs_open_and_read_archive (fstype, archive_name, &a);
804
805 g_free (archive_name);
806
807 if (result == -1)
808 {
809 path_element->class->verrno = EIO;
810 return NULL;
811 }
812 }
813
814 *archive = a;
815 return path_element->path;
816 }
817
818
819
820
821 static char *
822 extfs_get_path_from_entry (const struct vfs_s_entry *entry)
823 {
824 const struct vfs_s_entry *e;
825 GString *localpath;
826
827 localpath = g_string_new ("");
828
829 for (e = entry; e->dir != NULL; e = e->dir->ent)
830 {
831 g_string_prepend (localpath, e->name);
832 if (e->dir->ent->dir != NULL)
833 g_string_prepend_c (localpath, PATH_SEP);
834 }
835
836 return g_string_free (localpath, FALSE);
837 }
838
839
840
841 static struct vfs_s_entry *
842 extfs_resolve_symlinks_int (struct vfs_s_entry *entry, GSList * list)
843 {
844 struct vfs_s_entry *pent = NULL;
845
846 if (!S_ISLNK (entry->ino->st.st_mode))
847 return entry;
848
849 if (g_slist_find (list, entry) != NULL)
850 {
851
852 errloop = TRUE;
853 }
854 else
855 {
856 GSList *looping;
857
858 looping = g_slist_prepend (list, entry);
859 pent = extfs_find_entry_int (entry->dir, entry->ino->linkname, looping, FL_NONE);
860 looping = g_slist_delete_link (looping, looping);
861
862 if (pent == NULL)
863 my_errno = ENOENT;
864 }
865
866 return pent;
867 }
868
869
870
871 static struct vfs_s_entry *
872 extfs_resolve_symlinks (struct vfs_s_entry *entry)
873 {
874 struct vfs_s_entry *res;
875
876 errloop = FALSE;
877 notadir = FALSE;
878 res = extfs_resolve_symlinks_int (entry, NULL);
879 if (res == NULL)
880 {
881 if (errloop)
882 my_errno = ELOOP;
883 else if (notadir)
884 my_errno = ENOTDIR;
885 }
886 return res;
887 }
888
889
890
891 static char *
892 extfs_get_archive_name (const struct extfs_super_t *archive)
893 {
894 const char *archive_name;
895
896 if (archive->local_name != NULL)
897 archive_name = archive->local_name;
898 else
899 archive_name = CONST_VFS_SUPER (archive)->name;
900
901 if (archive_name == NULL || *archive_name == '\0')
902 return g_strdup ("no_archive_name");
903 else
904 {
905 char *ret_str;
906 vfs_path_t *vpath;
907 const vfs_path_element_t *path_element;
908
909 vpath = vfs_path_from_str (archive_name);
910 path_element = vfs_path_get_by_index (vpath, -1);
911 ret_str = g_strdup (path_element->path);
912 vfs_path_free (vpath, TRUE);
913 return ret_str;
914 }
915 }
916
917
918
919
920 static int
921 extfs_cmd (const char *str_extfs_cmd, const struct extfs_super_t *archive,
922 const struct vfs_s_entry *entry, const char *localname)
923 {
924 char *file;
925 char *quoted_file;
926 char *quoted_localname;
927 char *archive_name, *quoted_archive_name;
928 const extfs_plugin_info_t *info;
929 char *cmd;
930 int retval = 0;
931 GError *error = NULL;
932 mc_pipe_t *pip;
933
934 file = extfs_get_path_from_entry (entry);
935 quoted_file = name_quote (file, FALSE);
936 g_free (file);
937
938
939 file = extfs_skip_leading_dotslash (quoted_file);
940
941 archive_name = extfs_get_archive_name (archive);
942 quoted_archive_name = name_quote (archive_name, FALSE);
943 g_free (archive_name);
944 quoted_localname = name_quote (localname, FALSE);
945 info = &g_array_index (extfs_plugins, extfs_plugin_info_t, archive->fstype);
946 cmd = g_strconcat (info->path, info->prefix, str_extfs_cmd,
947 quoted_archive_name, " ", file, " ", quoted_localname, (char *) NULL);
948 g_free (quoted_file);
949 g_free (quoted_localname);
950 g_free (quoted_archive_name);
951
952
953 pip = mc_popen (cmd, FALSE, TRUE, &error);
954 g_free (cmd);
955
956 if (pip == NULL)
957 {
958 message (D_ERROR, MSG_ERROR, _("EXTFS virtual file system:\n%s"), error->message);
959 g_error_free (error);
960 return (-1);
961 }
962
963 mc_pread (pip, &error);
964 if (error != NULL)
965 {
966 message (D_ERROR, MSG_ERROR, _("EXTFS virtual file system:\n%s"), error->message);
967 g_error_free (error);
968 retval = -1;
969 }
970 else if (pip->err.len > 0)
971 message (D_ERROR, MSG_ERROR, _("EXTFS virtual file system:\n%s"), pip->err.buf);
972
973 mc_pclose (pip, NULL);
974
975 return retval;
976 }
977
978
979
980 static void
981 extfs_run (const vfs_path_t * vpath)
982 {
983 struct extfs_super_t *archive = NULL;
984 const char *p;
985 char *q, *archive_name, *quoted_archive_name;
986 char *cmd;
987 const extfs_plugin_info_t *info;
988
989 p = extfs_get_path (vpath, &archive, FL_NONE);
990 if (p == NULL)
991 return;
992 q = name_quote (p, FALSE);
993
994 archive_name = extfs_get_archive_name (archive);
995 quoted_archive_name = name_quote (archive_name, FALSE);
996 g_free (archive_name);
997 info = &g_array_index (extfs_plugins, extfs_plugin_info_t, archive->fstype);
998 cmd =
999 g_strconcat (info->path, info->prefix, " run ", quoted_archive_name, " ", q, (char *) NULL);
1000 g_free (quoted_archive_name);
1001 g_free (q);
1002 shell_execute (cmd, 0);
1003 g_free (cmd);
1004 }
1005
1006
1007
1008 static void *
1009 extfs_open (const vfs_path_t * vpath, int flags, mode_t mode)
1010 {
1011 vfs_file_handler_t *extfs_info;
1012 struct extfs_super_t *archive = NULL;
1013 const char *q;
1014 struct vfs_s_entry *entry;
1015 int local_handle;
1016 gboolean created = FALSE;
1017
1018 q = extfs_get_path (vpath, &archive, FL_NONE);
1019 if (q == NULL)
1020 return NULL;
1021 entry = extfs_find_entry (VFS_SUPER (archive)->root, q, FL_NONE);
1022 if ((entry == NULL) && ((flags & O_CREAT) != 0))
1023 {
1024
1025 entry = extfs_find_entry (VFS_SUPER (archive)->root, q, FL_MKFILE);
1026 created = (entry != NULL);
1027 }
1028
1029 if (entry == NULL)
1030 return NULL;
1031 entry = extfs_resolve_symlinks (entry);
1032 if (entry == NULL)
1033 return NULL;
1034
1035 if (S_ISDIR (entry->ino->st.st_mode))
1036 ERRNOR (EISDIR, NULL);
1037
1038 if (entry->ino->localname == NULL)
1039 {
1040 vfs_path_t *local_filename_vpath;
1041 const char *local_filename;
1042
1043 local_handle = vfs_mkstemps (&local_filename_vpath, "extfs", entry->name);
1044
1045 if (local_handle == -1)
1046 return NULL;
1047 close (local_handle);
1048 local_filename = vfs_path_get_by_index (local_filename_vpath, -1)->path;
1049
1050 if (!created && ((flags & O_TRUNC) == 0)
1051 && extfs_cmd (" copyout ", archive, entry, local_filename))
1052 {
1053 unlink (local_filename);
1054 vfs_path_free (local_filename_vpath, TRUE);
1055 my_errno = EIO;
1056 return NULL;
1057 }
1058 entry->ino->localname = g_strdup (local_filename);
1059 vfs_path_free (local_filename_vpath, TRUE);
1060 }
1061
1062 local_handle = open (entry->ino->localname, NO_LINEAR (flags), mode);
1063
1064 if (local_handle == -1)
1065 {
1066
1067 flags = ~O_CREAT & (NO_LINEAR (flags) | O_TRUNC);
1068 local_handle = open (entry->ino->localname, flags, mode);
1069 }
1070
1071 if (local_handle == -1)
1072 ERRNOR (EIO, NULL);
1073
1074 extfs_info = g_new (vfs_file_handler_t, 1);
1075 vfs_s_init_fh (extfs_info, entry->ino, created);
1076 extfs_info->handle = local_handle;
1077
1078
1079 vfs_rmstamp (vfs_extfs_ops, (vfsid) archive);
1080 VFS_SUPER (archive)->fd_usage++;
1081 return extfs_info;
1082 }
1083
1084
1085
1086 static ssize_t
1087 extfs_read (void *fh, char *buffer, size_t count)
1088 {
1089 vfs_file_handler_t *file = VFS_FILE_HANDLER (fh);
1090
1091 return read (file->handle, buffer, count);
1092 }
1093
1094
1095
1096 static int
1097 extfs_close (void *fh)
1098 {
1099 vfs_file_handler_t *file = VFS_FILE_HANDLER (fh);
1100 int errno_code = 0;
1101
1102 close (file->handle);
1103 file->handle = -1;
1104
1105
1106 if (file->changed)
1107 {
1108 struct stat file_status;
1109
1110 if (extfs_cmd
1111 (" copyin ", EXTFS_SUPER (VFS_FILE_HANDLER_SUPER (fh)), file->ino->ent,
1112 file->ino->localname))
1113 errno_code = EIO;
1114
1115 if (stat (file->ino->localname, &file_status) != 0)
1116 errno_code = EIO;
1117 else
1118 file->ino->st.st_size = file_status.st_size;
1119
1120 file->ino->st.st_mtime = time (NULL);
1121 }
1122
1123 if (--VFS_FILE_HANDLER_SUPER (fh)->fd_usage == 0)
1124 vfs_stamp_create (vfs_extfs_ops, VFS_FILE_HANDLER_SUPER (fh));
1125
1126 g_free (fh);
1127 if (errno_code != 0)
1128 ERRNOR (EIO, -1);
1129 return 0;
1130 }
1131
1132
1133
1134 static int
1135 extfs_errno (struct vfs_class *me)
1136 {
1137 (void) me;
1138 return my_errno;
1139 }
1140
1141
1142
1143 static void *
1144 extfs_opendir (const vfs_path_t * vpath)
1145 {
1146 struct extfs_super_t *archive = NULL;
1147 const char *q;
1148 struct vfs_s_entry *entry;
1149 GList **info;
1150
1151 q = extfs_get_path (vpath, &archive, FL_NONE);
1152 if (q == NULL)
1153 return NULL;
1154 entry = extfs_find_entry (VFS_SUPER (archive)->root, q, FL_NONE);
1155 if (entry == NULL)
1156 return NULL;
1157 entry = extfs_resolve_symlinks (entry);
1158 if (entry == NULL)
1159 return NULL;
1160 if (!S_ISDIR (entry->ino->st.st_mode))
1161 ERRNOR (ENOTDIR, NULL);
1162
1163 info = g_new (GList *, 1);
1164 *info = g_queue_peek_head_link (entry->ino->subdir);
1165
1166 return info;
1167 }
1168
1169
1170
1171 static struct vfs_dirent *
1172 extfs_readdir (void *data)
1173 {
1174 struct vfs_dirent *dir;
1175 GList **info = (GList **) data;
1176
1177 if (*info == NULL)
1178 return NULL;
1179
1180 dir = vfs_dirent_init (NULL, VFS_ENTRY ((*info)->data)->name, 0);
1181
1182 *info = g_list_next (*info);
1183
1184 return dir;
1185 }
1186
1187
1188
1189 static int
1190 extfs_closedir (void *data)
1191 {
1192 g_free (data);
1193 return 0;
1194 }
1195
1196
1197
1198
1199 static void
1200 extfs_stat_move (struct stat *buf, const struct vfs_s_inode *inode)
1201 {
1202 *buf = inode->st;
1203
1204 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
1205 buf->st_blksize = RECORDSIZE;
1206 #endif
1207 vfs_adjust_stat (buf);
1208 #ifdef HAVE_STRUCT_STAT_ST_MTIM
1209 buf->st_atim.tv_nsec = buf->st_mtim.tv_nsec = buf->st_ctim.tv_nsec = 0;
1210 #endif
1211 }
1212
1213
1214
1215 static int
1216 extfs_internal_stat (const vfs_path_t * vpath, struct stat *buf, gboolean resolve)
1217 {
1218 struct extfs_super_t *archive;
1219 const char *q;
1220 struct vfs_s_entry *entry;
1221 int result = -1;
1222
1223 q = extfs_get_path (vpath, &archive, FL_NONE);
1224 if (q == NULL)
1225 goto cleanup;
1226 entry = extfs_find_entry (VFS_SUPER (archive)->root, q, FL_NONE);
1227 if (entry == NULL)
1228 goto cleanup;
1229 if (resolve)
1230 {
1231 entry = extfs_resolve_symlinks (entry);
1232 if (entry == NULL)
1233 goto cleanup;
1234 }
1235 extfs_stat_move (buf, entry->ino);
1236 result = 0;
1237 cleanup:
1238 return result;
1239 }
1240
1241
1242
1243 static int
1244 extfs_stat (const vfs_path_t * vpath, struct stat *buf)
1245 {
1246 return extfs_internal_stat (vpath, buf, TRUE);
1247 }
1248
1249
1250
1251 static int
1252 extfs_lstat (const vfs_path_t * vpath, struct stat *buf)
1253 {
1254 return extfs_internal_stat (vpath, buf, FALSE);
1255 }
1256
1257
1258
1259 static int
1260 extfs_fstat (void *fh, struct stat *buf)
1261 {
1262 vfs_file_handler_t *file = VFS_FILE_HANDLER (fh);
1263
1264 extfs_stat_move (buf, file->ino);
1265 return 0;
1266 }
1267
1268
1269
1270 static int
1271 extfs_readlink (const vfs_path_t * vpath, char *buf, size_t size)
1272 {
1273 struct extfs_super_t *archive;
1274 const char *q;
1275 size_t len;
1276 struct vfs_s_entry *entry;
1277 int result = -1;
1278
1279 q = extfs_get_path (vpath, &archive, FL_NONE);
1280 if (q == NULL)
1281 goto cleanup;
1282 entry = extfs_find_entry (VFS_SUPER (archive)->root, q, FL_NONE);
1283 if (entry == NULL)
1284 goto cleanup;
1285 if (!S_ISLNK (entry->ino->st.st_mode))
1286 {
1287 const vfs_path_element_t *path_element;
1288
1289 path_element = vfs_path_get_by_index (vpath, -1);
1290 path_element->class->verrno = EINVAL;
1291 goto cleanup;
1292 }
1293 len = strlen (entry->ino->linkname);
1294 if (size < len)
1295 len = size;
1296
1297 result = len;
1298 memcpy (buf, entry->ino->linkname, result);
1299 cleanup:
1300 return result;
1301 }
1302
1303
1304
1305 static int
1306 extfs_chown (const vfs_path_t * vpath, uid_t owner, gid_t group)
1307 {
1308 (void) vpath;
1309 (void) owner;
1310 (void) group;
1311 return 0;
1312 }
1313
1314
1315
1316 static int
1317 extfs_chmod (const vfs_path_t * vpath, mode_t mode)
1318 {
1319 (void) vpath;
1320 (void) mode;
1321 return 0;
1322 }
1323
1324
1325
1326 static ssize_t
1327 extfs_write (void *fh, const char *buf, size_t nbyte)
1328 {
1329 vfs_file_handler_t *file = VFS_FILE_HANDLER (fh);
1330
1331 file->changed = TRUE;
1332 return write (file->handle, buf, nbyte);
1333 }
1334
1335
1336
1337 static int
1338 extfs_unlink (const vfs_path_t * vpath)
1339 {
1340 struct extfs_super_t *archive;
1341 const char *q;
1342 struct vfs_s_entry *entry;
1343 int result = -1;
1344
1345 q = extfs_get_path (vpath, &archive, FL_NONE);
1346 if (q == NULL)
1347 goto cleanup;
1348 entry = extfs_find_entry (VFS_SUPER (archive)->root, q, FL_NONE);
1349 if (entry == NULL)
1350 goto cleanup;
1351 entry = extfs_resolve_symlinks (entry);
1352 if (entry == NULL)
1353 goto cleanup;
1354 if (S_ISDIR (entry->ino->st.st_mode))
1355 {
1356 const vfs_path_element_t *path_element;
1357
1358 path_element = vfs_path_get_by_index (vpath, -1);
1359 path_element->class->verrno = EISDIR;
1360 goto cleanup;
1361 }
1362 if (extfs_cmd (" rm ", archive, entry, ""))
1363 {
1364 my_errno = EIO;
1365 goto cleanup;
1366 }
1367 vfs_s_free_entry (VFS_SUPER (archive)->me, entry);
1368 result = 0;
1369 cleanup:
1370 return result;
1371 }
1372
1373
1374
1375 static int
1376 extfs_mkdir (const vfs_path_t * vpath, mode_t mode)
1377 {
1378 struct extfs_super_t *archive;
1379 const char *q;
1380 struct vfs_s_entry *entry;
1381 int result = -1;
1382 const vfs_path_element_t *path_element;
1383
1384 (void) mode;
1385
1386 path_element = vfs_path_get_by_index (vpath, -1);
1387 q = extfs_get_path (vpath, &archive, FL_NONE);
1388 if (q == NULL)
1389 goto cleanup;
1390 entry = extfs_find_entry (VFS_SUPER (archive)->root, q, FL_NONE);
1391 if (entry != NULL)
1392 {
1393 path_element->class->verrno = EEXIST;
1394 goto cleanup;
1395 }
1396 entry = extfs_find_entry (VFS_SUPER (archive)->root, q, FL_MKDIR);
1397 if (entry == NULL)
1398 goto cleanup;
1399 entry = extfs_resolve_symlinks (entry);
1400 if (entry == NULL)
1401 goto cleanup;
1402 if (!S_ISDIR (entry->ino->st.st_mode))
1403 {
1404 path_element->class->verrno = ENOTDIR;
1405 goto cleanup;
1406 }
1407
1408 if (extfs_cmd (" mkdir ", archive, entry, ""))
1409 {
1410 my_errno = EIO;
1411 vfs_s_free_entry (VFS_SUPER (archive)->me, entry);
1412 goto cleanup;
1413 }
1414 result = 0;
1415 cleanup:
1416 return result;
1417 }
1418
1419
1420
1421 static int
1422 extfs_rmdir (const vfs_path_t * vpath)
1423 {
1424 struct extfs_super_t *archive;
1425 const char *q;
1426 struct vfs_s_entry *entry;
1427 int result = -1;
1428
1429 q = extfs_get_path (vpath, &archive, FL_NONE);
1430 if (q == NULL)
1431 goto cleanup;
1432 entry = extfs_find_entry (VFS_SUPER (archive)->root, q, FL_NONE);
1433 if (entry == NULL)
1434 goto cleanup;
1435 entry = extfs_resolve_symlinks (entry);
1436 if (entry == NULL)
1437 goto cleanup;
1438 if (!S_ISDIR (entry->ino->st.st_mode))
1439 {
1440 const vfs_path_element_t *path_element;
1441
1442 path_element = vfs_path_get_by_index (vpath, -1);
1443 path_element->class->verrno = ENOTDIR;
1444 goto cleanup;
1445 }
1446
1447 if (extfs_cmd (" rmdir ", archive, entry, ""))
1448 {
1449 my_errno = EIO;
1450 goto cleanup;
1451 }
1452 vfs_s_free_entry (VFS_SUPER (archive)->me, entry);
1453 result = 0;
1454 cleanup:
1455 return result;
1456 }
1457
1458
1459
1460 static int
1461 extfs_chdir (const vfs_path_t * vpath)
1462 {
1463 void *data;
1464
1465 my_errno = ENOTDIR;
1466 data = extfs_opendir (vpath);
1467 if (data == NULL)
1468 return (-1);
1469 extfs_closedir (data);
1470 my_errno = 0;
1471 return 0;
1472 }
1473
1474
1475
1476 static off_t
1477 extfs_lseek (void *fh, off_t offset, int whence)
1478 {
1479 vfs_file_handler_t *file = VFS_FILE_HANDLER (fh);
1480
1481 return lseek (file->handle, offset, whence);
1482 }
1483
1484
1485
1486 static vfsid
1487 extfs_getid (const vfs_path_t * vpath)
1488 {
1489 struct extfs_super_t *archive = NULL;
1490 const char *p;
1491
1492 p = extfs_get_path (vpath, &archive, FL_NO_OPEN);
1493 return (p == NULL ? NULL : (vfsid) archive);
1494 }
1495
1496
1497
1498 static vfs_path_t *
1499 extfs_getlocalcopy (const vfs_path_t * vpath)
1500 {
1501 vfs_file_handler_t *fh;
1502 vfs_path_t *p;
1503
1504 fh = VFS_FILE_HANDLER (extfs_open (vpath, O_RDONLY, 0));
1505 if (fh == NULL)
1506 return NULL;
1507 if (fh->ino->localname == NULL)
1508 {
1509 extfs_close ((void *) fh);
1510 return NULL;
1511 }
1512 p = vfs_path_from_str (fh->ino->localname);
1513 VFS_FILE_HANDLER_SUPER (fh)->fd_usage++;
1514 extfs_close ((void *) fh);
1515 return p;
1516 }
1517
1518
1519
1520 static int
1521 extfs_ungetlocalcopy (const vfs_path_t * vpath, const vfs_path_t * local, gboolean has_changed)
1522 {
1523 vfs_file_handler_t *fh;
1524
1525 fh = VFS_FILE_HANDLER (extfs_open (vpath, O_RDONLY, 0));
1526 if (fh == NULL)
1527 return 0;
1528
1529 if (strcmp (fh->ino->localname, vfs_path_get_last_path_str (local)) == 0)
1530 {
1531 VFS_FILE_HANDLER_SUPER (fh)->fd_usage--;
1532 if (has_changed)
1533 fh->changed = TRUE;
1534 extfs_close ((void *) fh);
1535 return 0;
1536 }
1537 else
1538 {
1539
1540 extfs_close ((void *) fh);
1541 return 0;
1542 }
1543 }
1544
1545
1546
1547 static gboolean
1548 extfs_get_plugins (const char *where, gboolean silent)
1549 {
1550 char *dirname;
1551 GDir *dir;
1552 const char *filename;
1553
1554 dirname = g_build_path (PATH_SEP_STR, where, MC_EXTFS_DIR, (char *) NULL);
1555 dir = g_dir_open (dirname, 0, NULL);
1556
1557
1558
1559
1560 if (dir == NULL)
1561 {
1562 if (!silent)
1563 fprintf (stderr, _("Warning: cannot open %s directory\n"), dirname);
1564 g_free (dirname);
1565 return FALSE;
1566 }
1567
1568 if (extfs_plugins == NULL)
1569 extfs_plugins = g_array_sized_new (FALSE, TRUE, sizeof (extfs_plugin_info_t), 32);
1570
1571 while ((filename = g_dir_read_name (dir)) != NULL)
1572 {
1573 char fullname[MC_MAXPATHLEN];
1574 struct stat s;
1575
1576 g_snprintf (fullname, sizeof (fullname), "%s" PATH_SEP_STR "%s", dirname, filename);
1577
1578 if ((stat (fullname, &s) == 0) && S_ISREG (s.st_mode) && !S_ISDIR (s.st_mode)
1579 && is_exe (s.st_mode))
1580 {
1581 int f;
1582
1583 f = open (fullname, O_RDONLY);
1584
1585 if (f >= 0)
1586 {
1587 size_t len, i;
1588 extfs_plugin_info_t info;
1589 gboolean found = FALSE;
1590
1591 close (f);
1592
1593
1594
1595
1596 len = strlen (filename);
1597 info.need_archive = (filename[len - 1] != '+');
1598 info.path = g_strconcat (dirname, PATH_SEP_STR, (char *) NULL);
1599 info.prefix = g_strdup (filename);
1600
1601
1602 if (!info.need_archive)
1603 info.prefix[len - 1] = '\0';
1604
1605
1606 for (i = 0; i < extfs_plugins->len; i++)
1607 {
1608 extfs_plugin_info_t *p;
1609
1610 p = &g_array_index (extfs_plugins, extfs_plugin_info_t, i);
1611
1612
1613 if ((strcmp (info.path, p->path) != 0)
1614 && (strcmp (info.prefix, p->prefix) == 0))
1615 {
1616 found = TRUE;
1617 break;
1618 }
1619 }
1620
1621 if (found)
1622 {
1623 g_free (info.path);
1624 g_free (info.prefix);
1625 }
1626 else
1627 {
1628
1629 if (!info.need_archive)
1630 info.prefix[len - 1] = '+';
1631 g_array_append_val (extfs_plugins, info);
1632 }
1633 }
1634 }
1635 }
1636
1637 g_dir_close (dir);
1638 g_free (dirname);
1639
1640 return TRUE;
1641 }
1642
1643
1644
1645 static int
1646 extfs_init (struct vfs_class *me)
1647 {
1648 gboolean d1, d2;
1649
1650 (void) me;
1651
1652
1653 d1 = extfs_get_plugins (mc_config_get_data_path (), TRUE);
1654
1655 d2 = extfs_get_plugins (LIBEXECDIR, d1);
1656
1657 return (d1 || d2 ? 1 : 0);
1658 }
1659
1660
1661
1662 static void
1663 extfs_done (struct vfs_class *me)
1664 {
1665 size_t i;
1666
1667 while (VFS_SUBCLASS (me)->supers != NULL)
1668 me->free ((vfsid) VFS_SUBCLASS (me)->supers->data);
1669
1670 if (extfs_plugins == NULL)
1671 return;
1672
1673 for (i = 0; i < extfs_plugins->len; i++)
1674 {
1675 extfs_plugin_info_t *info;
1676
1677 info = &g_array_index (extfs_plugins, extfs_plugin_info_t, i);
1678 g_free (info->path);
1679 g_free (info->prefix);
1680 }
1681
1682 g_array_free (extfs_plugins, TRUE);
1683 }
1684
1685
1686
1687 static int
1688 extfs_setctl (const vfs_path_t * vpath, int ctlop, void *arg)
1689 {
1690 (void) arg;
1691
1692 if (ctlop == VFS_SETCTL_RUN)
1693 {
1694 extfs_run (vpath);
1695 return 1;
1696 }
1697 return 0;
1698 }
1699
1700
1701
1702
1703
1704 void
1705 vfs_init_extfs (void)
1706 {
1707 vfs_init_subclass (&extfs_subclass, "extfs", VFSF_UNKNOWN, NULL);
1708 vfs_extfs_ops->init = extfs_init;
1709 vfs_extfs_ops->done = extfs_done;
1710 vfs_extfs_ops->fill_names = extfs_fill_names;
1711 vfs_extfs_ops->which = extfs_which;
1712 vfs_extfs_ops->open = extfs_open;
1713 vfs_extfs_ops->close = extfs_close;
1714 vfs_extfs_ops->read = extfs_read;
1715 vfs_extfs_ops->write = extfs_write;
1716 vfs_extfs_ops->opendir = extfs_opendir;
1717 vfs_extfs_ops->readdir = extfs_readdir;
1718 vfs_extfs_ops->closedir = extfs_closedir;
1719 vfs_extfs_ops->stat = extfs_stat;
1720 vfs_extfs_ops->lstat = extfs_lstat;
1721 vfs_extfs_ops->fstat = extfs_fstat;
1722 vfs_extfs_ops->chmod = extfs_chmod;
1723 vfs_extfs_ops->chown = extfs_chown;
1724 vfs_extfs_ops->readlink = extfs_readlink;
1725 vfs_extfs_ops->unlink = extfs_unlink;
1726 vfs_extfs_ops->chdir = extfs_chdir;
1727 vfs_extfs_ops->ferrno = extfs_errno;
1728 vfs_extfs_ops->lseek = extfs_lseek;
1729 vfs_extfs_ops->getid = extfs_getid;
1730 vfs_extfs_ops->getlocalcopy = extfs_getlocalcopy;
1731 vfs_extfs_ops->ungetlocalcopy = extfs_ungetlocalcopy;
1732 vfs_extfs_ops->mkdir = extfs_mkdir;
1733 vfs_extfs_ops->rmdir = extfs_rmdir;
1734 vfs_extfs_ops->setctl = extfs_setctl;
1735 extfs_subclass.free_inode = extfs_free_inode;
1736 extfs_subclass.free_archive = extfs_free_archive;
1737 vfs_register_class (vfs_extfs_ops);
1738 }
1739
1740