2 Virtual File System: GNU Tar file system.
4 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2011
5 The Free Software Foundation, Inc.
10 This file is part of the Midnight Commander.
12 The Midnight Commander is free software: you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation, either version 3 of the License,
15 or (at your option) any later version.
17 The Midnight Commander is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 * \brief Source: Virtual File System: GNU Tar file system.
36 #include <sys/types.h>
40 #include "lib/global.h"
41 #include "lib/unixcompat.h"
43 #include "lib/widget.h" /* message() */
45 #include "lib/vfs/vfs.h"
46 #include "lib/vfs/utilvfs.h"
47 #include "lib/vfs/xdirentry.h"
48 #include "lib/vfs/gc.h" /* vfs_rmstamp */
52 /*** global variables ****************************************************************************/
54 /*** file scope macro definitions ****************************************************************/
56 #define CPIO_POS(super) cpio_position
57 /* If some time reentrancy should be needed change it to */
58 /* #define CPIO_POS(super) (super)->u.arch.fd */
60 #define CPIO_SEEK_SET(super, where) \
61 mc_lseek (((cpio_super_data_t *)(super)->data)->fd, \
62 CPIO_POS(super) = (where), SEEK_SET)
63 #define CPIO_SEEK_CUR(super, where) \
64 mc_lseek (((cpio_super_data_t *)(super)->data)->fd, \
65 CPIO_POS(super) += (where), SEEK_SET)
67 #define MAGIC_LENGTH (6) /* How many bytes we have to read ahead */
68 #define SEEKBACK CPIO_SEEK_CUR(super, ptr - top)
69 #define RETURN(x) return (((cpio_super_data_t *)super->data)->type = (x))
71 ((((cpio_super_data_t *)super->data)->type == CPIO_UNKNOWN) || \
72 (((cpio_super_data_t *)super->data)->type == (x)))
74 #define HEAD_LENGTH (26)
76 /*** file scope type declarations ****************************************************************/
89 CPIO_UNKNOWN
= 0, /* Not determined yet */
90 CPIO_BIN
, /* Binary format */
91 CPIO_BINRE
, /* Binary format, reverse endianity */
92 CPIO_OLDC
, /* Old ASCII format */
93 CPIO_NEWC
, /* New ASCII format */
94 CPIO_CRC
/* New ASCII format + CRC */
97 struct old_cpio_header
99 unsigned short c_magic
;
101 unsigned short c_ino
;
102 unsigned short c_mode
;
103 unsigned short c_uid
;
104 unsigned short c_gid
;
105 unsigned short c_nlink
;
107 unsigned short c_mtimes
[2];
108 unsigned short c_namesize
;
109 unsigned short c_filesizes
[2];
112 struct new_cpio_header
114 unsigned short c_magic
;
116 unsigned long c_mode
;
119 unsigned long c_nlink
;
120 unsigned long c_mtime
;
121 unsigned long c_filesize
;
126 unsigned long c_namesize
;
127 unsigned long c_chksum
;
132 unsigned long inumber
;
133 unsigned short device
;
134 struct vfs_s_inode
*inode
;
141 int type
; /* Type of the archive */
142 GSList
*deferred
; /* List of inodes for which another entries may appear */
145 /*** file scope variables ************************************************************************/
147 static struct vfs_class vfs_cpiofs_ops
;
149 /* FIXME: should be off_t instead of int. */
150 static int cpio_position
;
152 /*** file scope functions ************************************************************************/
153 /* --------------------------------------------------------------------------------------------- */
155 static int cpio_find_head (struct vfs_class
*me
, struct vfs_s_super
*super
);
156 static ssize_t
cpio_read_bin_head (struct vfs_class
*me
, struct vfs_s_super
*super
);
157 static ssize_t
cpio_read_oldc_head (struct vfs_class
*me
, struct vfs_s_super
*super
);
158 static ssize_t
cpio_read_crc_head (struct vfs_class
*me
, struct vfs_s_super
*super
);
159 static ssize_t
cpio_read (void *fh
, char *buffer
, size_t count
);
161 /* --------------------------------------------------------------------------------------------- */
164 cpio_defer_find (const void *a
, const void *b
)
166 const defer_inode
*a1
= (const defer_inode
*) a
;
167 const defer_inode
*b1
= (const defer_inode
*) b
;
169 return (a1
->inumber
== b1
->inumber
&& a1
->device
== b1
->device
) ? 0 : 1;
172 /* --------------------------------------------------------------------------------------------- */
175 cpio_skip_padding (struct vfs_s_super
*super
)
177 switch (((cpio_super_data_t
*) super
->data
)->type
)
181 return CPIO_SEEK_CUR (super
, (2 - (CPIO_POS (super
) % 2)) % 2);
184 return CPIO_SEEK_CUR (super
, (4 - (CPIO_POS (super
) % 4)) % 4);
186 return CPIO_POS (super
);
188 g_assert_not_reached ();
189 return 42; /* & the compiler is happy :-) */
193 /* --------------------------------------------------------------------------------------------- */
196 cpio_free_archive (struct vfs_class
*me
, struct vfs_s_super
*super
)
198 cpio_super_data_t
*arch
= (cpio_super_data_t
*) super
->data
;
202 if (super
->data
== NULL
)
208 g_slist_foreach (arch
->deferred
, (GFunc
) g_free
, NULL
);
209 g_slist_free (arch
->deferred
);
210 arch
->deferred
= NULL
;
211 g_free (super
->data
);
215 /* --------------------------------------------------------------------------------------------- */
218 cpio_open_cpio_file (struct vfs_class
*me
, struct vfs_s_super
*super
, const vfs_path_t
* vpath
)
221 cpio_super_data_t
*arch
;
223 struct vfs_s_inode
*root
;
224 char *name
= vfs_path_to_str (vpath
);
226 fd
= mc_open (name
, O_RDONLY
);
229 message (D_ERROR
, MSG_ERROR
, _("Cannot open cpio archive\n%s"), name
);
234 super
->name
= g_strdup (name
);
235 super
->data
= g_new (cpio_super_data_t
, 1);
236 arch
= (cpio_super_data_t
*) super
->data
;
237 arch
->fd
= -1; /* for now */
238 mc_stat (vpath
, &arch
->st
);
239 arch
->type
= CPIO_UNKNOWN
;
240 arch
->deferred
= NULL
;
242 type
= get_compression_type (fd
, name
);
243 if (type
!= COMPRESSION_NONE
)
248 s
= g_strconcat (name
, decompress_extension (type
), (char *) NULL
);
249 fd
= mc_open (s
, O_RDONLY
);
252 message (D_ERROR
, MSG_ERROR
, _("Cannot open cpio archive\n%s"), s
);
261 mode
= arch
->st
.st_mode
& 07777;
262 mode
|= (mode
& 0444) >> 2; /* set eXec where Read is */
265 root
= vfs_s_new_inode (me
, super
, &arch
->st
);
266 root
->st
.st_mode
= mode
;
267 root
->data_offset
= -1;
269 root
->st
.st_dev
= MEDATA
->rdev
++;
273 CPIO_SEEK_SET (super
, 0);
279 /* --------------------------------------------------------------------------------------------- */
282 cpio_read_head (struct vfs_class
*me
, struct vfs_s_super
*super
)
284 switch (cpio_find_head (me
, super
))
290 return cpio_read_bin_head (me
, super
);
292 return cpio_read_oldc_head (me
, super
);
295 return cpio_read_crc_head (me
, super
);
297 g_assert_not_reached ();
298 return 42; /* & the compiler is happy :-) */
302 /* --------------------------------------------------------------------------------------------- */
305 cpio_find_head (struct vfs_class
*me
, struct vfs_s_super
*super
)
307 cpio_super_data_t
*arch
= (cpio_super_data_t
*) super
->data
;
308 char buf
[BUF_SMALL
* 2];
313 top
= mc_read (arch
->fd
, buf
, sizeof (buf
));
315 CPIO_POS (super
) += top
;
319 if (ptr
+ MAGIC_LENGTH
>= top
)
321 if (top
> (ssize_t
) (sizeof (buf
) / 2))
323 memmove (buf
, buf
+ top
- sizeof (buf
) / 2, sizeof (buf
) / 2);
324 ptr
-= top
- sizeof (buf
) / 2;
325 top
= sizeof (buf
) / 2;
327 tmp
= mc_read (arch
->fd
, buf
, top
);
328 if (tmp
== 0 || tmp
== -1)
330 message (D_ERROR
, MSG_ERROR
, _("Premature end of cpio archive\n%s"), super
->name
);
331 cpio_free_archive (me
, super
);
336 if (TYPEIS (CPIO_BIN
) && ((*(unsigned short *) (buf
+ ptr
)) == 070707))
341 else if (TYPEIS (CPIO_BINRE
)
342 && ((*(unsigned short *) (buf
+ ptr
)) == GUINT16_SWAP_LE_BE_CONSTANT (070707)))
347 else if (TYPEIS (CPIO_OLDC
) && (strncmp (buf
+ ptr
, "070707", 6) == 0))
352 else if (TYPEIS (CPIO_NEWC
) && (strncmp (buf
+ ptr
, "070701", 6) == 0))
357 else if (TYPEIS (CPIO_CRC
) && (strncmp (buf
+ ptr
, "070702", 6) == 0))
366 /* --------------------------------------------------------------------------------------------- */
369 cpio_create_entry (struct vfs_class
*me
, struct vfs_s_super
*super
, struct stat
*st
, char *name
)
371 cpio_super_data_t
*arch
= (cpio_super_data_t
*) super
->data
;
372 struct vfs_s_inode
*inode
= NULL
;
373 struct vfs_s_inode
*root
= super
->root
;
374 struct vfs_s_entry
*entry
= NULL
;
377 switch (st
->st_mode
& S_IFMT
)
378 { /* For case of HP/UX archives */
390 if ((st
->st_size
!= 0) && (st
->st_rdev
== 0x0001))
392 /* FIXME: representation of major/minor differs between */
393 /* different operating systems. */
394 st
->st_rdev
= (unsigned) st
->st_size
;
402 if ((st
->st_nlink
> 1) && ((arch
->type
== CPIO_NEWC
) || (arch
->type
== CPIO_CRC
)))
403 { /* For case of hardlinked files */
404 defer_inode i
= { st
->st_ino
, st
->st_dev
, NULL
};
407 l
= g_slist_find_custom (arch
->deferred
, &i
, cpio_defer_find
);
410 inode
= ((defer_inode
*) l
->data
)->inode
;
411 if (inode
->st
.st_size
!= 0 && st
->st_size
!= 0 && (inode
->st
.st_size
!= st
->st_size
))
413 message (D_ERROR
, MSG_ERROR
,
414 _("Inconsistent hardlinks of\n%s\nin cpio archive\n%s"),
418 else if (inode
->st
.st_size
== 0)
419 inode
->st
.st_size
= st
->st_size
;
423 /* remove trailing slashes */
424 for (tn
= name
+ strlen (name
) - 1; tn
>= name
&& *tn
== PATH_SEP
; tn
--)
427 tn
= strrchr (name
, PATH_SEP
);
430 else if (tn
== name
+ 1)
432 /* started with "./" -- directory in the root of archive */
438 root
= vfs_s_find_inode (me
, super
, name
, LINK_FOLLOW
, FL_MKDIR
);
443 entry
= MEDATA
->find_entry (me
, root
, tn
, LINK_FOLLOW
, FL_NONE
); /* In case entry is already there */
447 /* This shouldn't happen! (well, it can happen if there is a record for a
448 file and than a record for a directory it is in; cpio would die with
449 'No such file or directory' is such case) */
451 if (!S_ISDIR (entry
->ino
->st
.st_mode
))
453 /* This can be considered archive inconsistency */
454 message (D_ERROR
, MSG_ERROR
,
455 _("%s contains duplicate entries! Skipping!"), super
->name
);
459 entry
->ino
->st
.st_mode
= st
->st_mode
;
460 entry
->ino
->st
.st_uid
= st
->st_uid
;
461 entry
->ino
->st
.st_gid
= st
->st_gid
;
462 entry
->ino
->st
.st_atime
= st
->st_atime
;
463 entry
->ino
->st
.st_mtime
= st
->st_mtime
;
464 entry
->ino
->st
.st_ctime
= st
->st_ctime
;
473 inode
= vfs_s_new_inode (me
, super
, st
);
474 if ((st
->st_nlink
> 0) && ((arch
->type
== CPIO_NEWC
) || (arch
->type
== CPIO_CRC
)))
476 /* For case of hardlinked files */
479 i
= g_new (defer_inode
, 1);
480 i
->inumber
= st
->st_ino
;
481 i
->device
= st
->st_dev
;
484 arch
->deferred
= g_slist_prepend (arch
->deferred
, i
);
488 if (st
->st_size
!= 0)
489 inode
->data_offset
= CPIO_POS (super
);
491 entry
= vfs_s_new_entry (me
, tn
, inode
);
492 vfs_s_insert_entry (me
, root
, entry
);
496 if (!S_ISLNK (st
->st_mode
))
497 CPIO_SEEK_CUR (super
, st
->st_size
);
500 inode
->linkname
= g_malloc (st
->st_size
+ 1);
502 if (mc_read (arch
->fd
, inode
->linkname
, st
->st_size
) < st
->st_size
)
504 inode
->linkname
[0] = '\0';
508 inode
->linkname
[st
->st_size
] = '\0'; /* Linkname stored without terminating \0 !!! */
509 CPIO_POS (super
) += st
->st_size
;
510 cpio_skip_padding (super
);
517 /* --------------------------------------------------------------------------------------------- */
520 cpio_read_bin_head (struct vfs_class
*me
, struct vfs_s_super
*super
)
524 struct old_cpio_header buf
;
525 short shorts
[HEAD_LENGTH
>> 1];
528 cpio_super_data_t
*arch
= (cpio_super_data_t
*) super
->data
;
533 len
= mc_read (arch
->fd
, (char *) &u
.buf
, HEAD_LENGTH
);
534 if (len
< HEAD_LENGTH
)
536 CPIO_POS (super
) += len
;
537 if (arch
->type
== CPIO_BINRE
)
540 for (i
= 0; i
< (HEAD_LENGTH
>> 1); i
++)
541 u
.shorts
[i
] = GUINT16_SWAP_LE_BE_CONSTANT (u
.shorts
[i
]);
544 if (u
.buf
.c_magic
!= 070707 || u
.buf
.c_namesize
== 0 || u
.buf
.c_namesize
> MC_MAXPATHLEN
)
546 message (D_ERROR
, MSG_ERROR
, _("Corrupted cpio header encountered in\n%s"), super
->name
);
549 name
= g_malloc (u
.buf
.c_namesize
);
550 len
= mc_read (arch
->fd
, name
, u
.buf
.c_namesize
);
551 if (len
< u
.buf
.c_namesize
)
556 name
[u
.buf
.c_namesize
- 1] = '\0';
557 CPIO_POS (super
) += len
;
558 cpio_skip_padding (super
);
560 if (!strcmp ("TRAILER!!!", name
))
561 { /* We got to the last record */
566 st
.st_dev
= u
.buf
.c_dev
;
567 st
.st_ino
= u
.buf
.c_ino
;
568 st
.st_mode
= u
.buf
.c_mode
;
569 st
.st_nlink
= u
.buf
.c_nlink
;
570 st
.st_uid
= u
.buf
.c_uid
;
571 st
.st_gid
= u
.buf
.c_gid
;
572 st
.st_rdev
= u
.buf
.c_rdev
;
573 st
.st_size
= (u
.buf
.c_filesizes
[0] << 16) | u
.buf
.c_filesizes
[1];
574 st
.st_atime
= st
.st_mtime
= st
.st_ctime
= (u
.buf
.c_mtimes
[0] << 16) | u
.buf
.c_mtimes
[1];
576 return cpio_create_entry (me
, super
, &st
, name
);
579 /* --------------------------------------------------------------------------------------------- */
582 #define HEAD_LENGTH (76)
585 cpio_read_oldc_head (struct vfs_class
*me
, struct vfs_s_super
*super
)
587 cpio_super_data_t
*arch
= (cpio_super_data_t
*) super
->data
;
588 struct new_cpio_header hd
;
592 char buf
[HEAD_LENGTH
+ 1];
597 if (mc_read (arch
->fd
, u
.buf
, HEAD_LENGTH
) != HEAD_LENGTH
)
599 CPIO_POS (super
) += HEAD_LENGTH
;
600 u
.buf
[HEAD_LENGTH
] = 0;
602 if (sscanf (u
.buf
, "070707%6lo%6lo%6lo%6lo%6lo%6lo%6lo%11lo%6lo%11lo",
603 (unsigned long *) &hd
.c_dev
, &hd
.c_ino
, &hd
.c_mode
, &hd
.c_uid
, &hd
.c_gid
,
604 &hd
.c_nlink
, (unsigned long *) &hd
.c_rdev
, &hd
.c_mtime
,
605 &hd
.c_namesize
, &hd
.c_filesize
) < 10)
607 message (D_ERROR
, MSG_ERROR
, _("Corrupted cpio header encountered in\n%s"), super
->name
);
611 if (hd
.c_namesize
== 0 || hd
.c_namesize
> MC_MAXPATHLEN
)
613 message (D_ERROR
, MSG_ERROR
, _("Corrupted cpio header encountered in\n%s"), super
->name
);
616 name
= g_malloc (hd
.c_namesize
);
617 len
= mc_read (arch
->fd
, name
, hd
.c_namesize
);
618 if ((len
== -1) || ((unsigned long) len
< hd
.c_namesize
))
623 name
[hd
.c_namesize
- 1] = '\0';
624 CPIO_POS (super
) += len
;
625 cpio_skip_padding (super
);
627 if (!strcmp ("TRAILER!!!", name
))
628 { /* We got to the last record */
633 u
.st
.st_dev
= hd
.c_dev
;
634 u
.st
.st_ino
= hd
.c_ino
;
635 u
.st
.st_mode
= hd
.c_mode
;
636 u
.st
.st_nlink
= hd
.c_nlink
;
637 u
.st
.st_uid
= hd
.c_uid
;
638 u
.st
.st_gid
= hd
.c_gid
;
639 u
.st
.st_rdev
= hd
.c_rdev
;
640 u
.st
.st_size
= hd
.c_filesize
;
641 u
.st
.st_atime
= u
.st
.st_mtime
= u
.st
.st_ctime
= hd
.c_mtime
;
643 return cpio_create_entry (me
, super
, &u
.st
, name
);
646 /* --------------------------------------------------------------------------------------------- */
649 #define HEAD_LENGTH (110)
652 cpio_read_crc_head (struct vfs_class
*me
, struct vfs_s_super
*super
)
654 cpio_super_data_t
*arch
= (cpio_super_data_t
*) super
->data
;
655 struct new_cpio_header hd
;
659 char buf
[HEAD_LENGTH
+ 1];
664 if (mc_read (arch
->fd
, u
.buf
, HEAD_LENGTH
) != HEAD_LENGTH
)
667 CPIO_POS (super
) += HEAD_LENGTH
;
668 u
.buf
[HEAD_LENGTH
] = '\0';
670 if (sscanf (u
.buf
, "%6ho%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx",
671 &hd
.c_magic
, &hd
.c_ino
, &hd
.c_mode
, &hd
.c_uid
, &hd
.c_gid
,
672 &hd
.c_nlink
, &hd
.c_mtime
, &hd
.c_filesize
,
673 (unsigned long *) &hd
.c_dev
, (unsigned long *) &hd
.c_devmin
,
674 (unsigned long *) &hd
.c_rdev
, (unsigned long *) &hd
.c_rdevmin
,
675 &hd
.c_namesize
, &hd
.c_chksum
) < 14)
677 message (D_ERROR
, MSG_ERROR
, _("Corrupted cpio header encountered in\n%s"), super
->name
);
681 if ((arch
->type
== CPIO_NEWC
&& hd
.c_magic
!= 070701) ||
682 (arch
->type
== CPIO_CRC
&& hd
.c_magic
!= 070702))
685 if (hd
.c_namesize
== 0 || hd
.c_namesize
> MC_MAXPATHLEN
)
687 message (D_ERROR
, MSG_ERROR
, _("Corrupted cpio header encountered in\n%s"), super
->name
);
691 name
= g_malloc (hd
.c_namesize
);
692 len
= mc_read (arch
->fd
, name
, hd
.c_namesize
);
694 if ((len
== -1) || ((unsigned long) len
< hd
.c_namesize
))
699 name
[hd
.c_namesize
- 1] = '\0';
700 CPIO_POS (super
) += len
;
701 cpio_skip_padding (super
);
703 if (strcmp ("TRAILER!!!", name
) == 0)
704 { /* We got to the last record */
709 u
.st
.st_dev
= makedev (hd
.c_dev
, hd
.c_devmin
);
710 u
.st
.st_ino
= hd
.c_ino
;
711 u
.st
.st_mode
= hd
.c_mode
;
712 u
.st
.st_nlink
= hd
.c_nlink
;
713 u
.st
.st_uid
= hd
.c_uid
;
714 u
.st
.st_gid
= hd
.c_gid
;
715 u
.st
.st_rdev
= makedev (hd
.c_rdev
, hd
.c_rdevmin
);
716 u
.st
.st_size
= hd
.c_filesize
;
717 u
.st
.st_atime
= u
.st
.st_mtime
= u
.st
.st_ctime
= hd
.c_mtime
;
719 return cpio_create_entry (me
, super
, &u
.st
, name
);
722 /* --------------------------------------------------------------------------------------------- */
723 /** Need to CPIO_SEEK_CUR to skip the file at the end of add entry!!!! */
726 cpio_open_archive (struct vfs_s_super
*super
, const vfs_path_t
* vpath
,
727 const vfs_path_element_t
* vpath_element
)
729 int status
= STATUS_START
;
731 (void) vpath_element
;
733 if (cpio_open_cpio_file (vpath_element
->class, super
, vpath
) == -1)
738 status
= cpio_read_head (vpath_element
->class, super
);
746 archive_name
= vfs_path_to_str (vpath
);
747 message (D_ERROR
, MSG_ERROR
, _("Unexpected end of file\n%s"), archive_name
);
748 g_free (archive_name
);
762 /* --------------------------------------------------------------------------------------------- */
763 /** Remaining functions are exactly same as for tarfs (and were in fact just copied) */
766 cpio_super_check (const vfs_path_t
* vpath
)
768 static struct stat sb
;
771 stat_result
= mc_stat (vpath
, &sb
);
772 return (stat_result
== 0 ? &sb
: NULL
);
775 /* --------------------------------------------------------------------------------------------- */
778 cpio_super_same (const vfs_path_element_t
* vpath_element
, struct vfs_s_super
*parc
,
779 const vfs_path_t
* vpath
, void *cookie
)
781 struct stat
*archive_stat
= cookie
; /* stat of main archive */
782 char *archive_name
= vfs_path_to_str (vpath
);
784 (void) vpath_element
;
786 if (strcmp (parc
->name
, archive_name
))
788 g_free (archive_name
);
791 g_free (archive_name
);
793 /* Has the cached archive been changed on the disk? */
794 if (((cpio_super_data_t
*) parc
->data
)->st
.st_mtime
< archive_stat
->st_mtime
)
797 (*vfs_cpiofs_ops
.free
) ((vfsid
) parc
);
798 vfs_rmstamp (&vfs_cpiofs_ops
, (vfsid
) parc
);
801 /* Hasn't been modified, give it a new timeout */
802 vfs_stamp (&vfs_cpiofs_ops
, (vfsid
) parc
);
806 /* --------------------------------------------------------------------------------------------- */
809 cpio_read (void *fh
, char *buffer
, size_t count
)
811 off_t begin
= FH
->ino
->data_offset
;
812 int fd
= ((cpio_super_data_t
*) FH_SUPER
->data
)->fd
;
813 struct vfs_class
*me
= FH_SUPER
->me
;
816 if (mc_lseek (fd
, begin
+ FH
->pos
, SEEK_SET
) != begin
+ FH
->pos
)
819 count
= MIN (count
, (size_t) (FH
->ino
->st
.st_size
- FH
->pos
));
821 res
= mc_read (fd
, buffer
, count
);
829 /* --------------------------------------------------------------------------------------------- */
832 cpio_fh_open (struct vfs_class
*me
, vfs_file_handler_t
* fh
, int flags
, mode_t mode
)
838 if ((flags
& O_ACCMODE
) != O_RDONLY
)
843 /* --------------------------------------------------------------------------------------------- */
844 /*** public functions ****************************************************************************/
845 /* --------------------------------------------------------------------------------------------- */
850 static struct vfs_s_subclass cpio_subclass
;
852 cpio_subclass
.flags
= VFS_S_READONLY
; /* FIXME: cpiofs used own temp files */
853 cpio_subclass
.archive_check
= cpio_super_check
;
854 cpio_subclass
.archive_same
= cpio_super_same
;
855 cpio_subclass
.open_archive
= cpio_open_archive
;
856 cpio_subclass
.free_archive
= cpio_free_archive
;
857 cpio_subclass
.fh_open
= cpio_fh_open
;
859 vfs_s_init_class (&vfs_cpiofs_ops
, &cpio_subclass
);
860 vfs_cpiofs_ops
.name
= "cpiofs";
861 vfs_cpiofs_ops
.prefix
= "ucpio";
862 vfs_cpiofs_ops
.read
= cpio_read
;
863 vfs_cpiofs_ops
.setctl
= NULL
;
864 vfs_register_class (&vfs_cpiofs_ops
);
867 /* --------------------------------------------------------------------------------------------- */