Ticket #1619: Problem with "preserve attributes", file times and ntfs/vfat partitions
[midnight-commander.git] / vfs / cpio.c
blobf9fa1a820c9132d2277fb2d896b97cb2d0e9f351
1 /* Virtual File System: GNU Tar file system.
2 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007
3 Free Software Foundation, Inc.
5 Written by: 2000 Jan Hudec
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.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
21 /** \file
22 * \brief Source: Virtual File System: GNU Tar file system.
23 * \author Jan Hudec
24 * \date 2000
27 #include <config.h>
29 #include <errno.h>
30 #include <fcntl.h>
32 #include "../src/global.h"
34 #include "../src/wtools.h" /* message() */
35 #include "../src/main.h" /* print_vfs_message */
36 #include "../src/unixcompat.h"
38 #include "utilvfs.h"
39 #include "vfs-impl.h"
40 #include "gc.h" /* vfs_rmstamp */
41 #include "xdirentry.h"
43 enum {
44 STATUS_START,
45 STATUS_OK,
46 STATUS_TRAIL,
47 STATUS_FAIL,
48 STATUS_EOF
51 enum {
52 CPIO_UNKNOWN = 0, /* Not determined yet */
53 CPIO_BIN, /* Binary format */
54 CPIO_BINRE, /* Binary format, reverse endianity */
55 CPIO_OLDC, /* Old ASCII format */
56 CPIO_NEWC, /* New ASCII format */
57 CPIO_CRC /* New ASCII format + CRC */
60 static struct vfs_class vfs_cpiofs_ops;
62 struct old_cpio_header
64 unsigned short c_magic;
65 short c_dev;
66 unsigned short c_ino;
67 unsigned short c_mode;
68 unsigned short c_uid;
69 unsigned short c_gid;
70 unsigned short c_nlink;
71 short c_rdev;
72 unsigned short c_mtimes[2];
73 unsigned short c_namesize;
74 unsigned short c_filesizes[2];
77 struct new_cpio_header
79 unsigned short c_magic;
80 unsigned long c_ino;
81 unsigned long c_mode;
82 unsigned long c_uid;
83 unsigned long c_gid;
84 unsigned long c_nlink;
85 unsigned long c_mtime;
86 unsigned long c_filesize;
87 long c_dev;
88 long c_devmin;
89 long c_rdev;
90 long c_rdevmin;
91 unsigned long c_namesize;
92 unsigned long c_chksum;
95 struct defer_inode {
96 struct defer_inode *next;
97 unsigned long inumber;
98 unsigned short device;
99 struct vfs_s_inode *inode;
102 /* FIXME: should be off_t instead of int. */
103 static int cpio_position;
105 static int cpio_find_head(struct vfs_class *me, struct vfs_s_super *super);
106 static int cpio_create_entry(struct vfs_class *me, struct vfs_s_super *super, struct stat *, char *name);
107 static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *super);
108 static ssize_t cpio_read_oldc_head(struct vfs_class *me, struct vfs_s_super *super);
109 static ssize_t cpio_read_crc_head(struct vfs_class *me, struct vfs_s_super *super);
110 static ssize_t cpio_read(void *fh, char *buffer, int count);
112 #define CPIO_POS(super) cpio_position
113 /* If some time reentrancy should be needed change it to */
114 /* #define CPIO_POS(super) (super)->u.arch.fd */
116 #define CPIO_SEEK_SET(super, where) mc_lseek((super)->u.arch.fd, CPIO_POS(super) = (where), SEEK_SET)
117 #define CPIO_SEEK_CUR(super, where) mc_lseek((super)->u.arch.fd, CPIO_POS(super) += (where), SEEK_SET)
119 static struct defer_inode *
120 cpio_defer_find (struct defer_inode *l, struct defer_inode *i)
122 while (l && (l->inumber != i->inumber || l->device != i->device))
123 l = l->next;
124 return l;
127 static int cpio_skip_padding(struct vfs_s_super *super)
129 switch(super->u.arch.type) {
130 case CPIO_BIN:
131 case CPIO_BINRE:
132 return CPIO_SEEK_CUR(super, (2 - (CPIO_POS(super) % 2)) % 2);
133 case CPIO_NEWC:
134 case CPIO_CRC:
135 return CPIO_SEEK_CUR(super, (4 - (CPIO_POS(super) % 4)) % 4);
136 case CPIO_OLDC:
137 return CPIO_POS(super);
138 default:
139 g_assert_not_reached();
140 return 42; /* & the compiler is happy :-) */
144 static void cpio_free_archive(struct vfs_class *me, struct vfs_s_super *super)
146 struct defer_inode *l, *lnext;
148 (void) me;
150 if(super->u.arch.fd != -1)
151 mc_close(super->u.arch.fd);
152 super->u.arch.fd = -1;
153 for (l = super->u.arch.deferred; l; l = lnext) {
154 lnext = l->next;
155 g_free (l);
157 super->u.arch.deferred = NULL;
160 static int
161 cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super,
162 const char *name)
164 int fd, type;
165 mode_t mode;
166 struct vfs_s_inode *root;
168 if ((fd = mc_open (name, O_RDONLY)) == -1) {
169 message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), name);
170 return -1;
173 super->name = g_strdup (name);
174 super->u.arch.fd = -1; /* for now */
175 mc_stat (name, &(super->u.arch.st));
176 super->u.arch.type = CPIO_UNKNOWN;
178 type = get_compression_type (fd, name);
179 if (type != COMPRESSION_NONE) {
180 char *s;
182 mc_close (fd);
183 s = g_strconcat (name, decompress_extension (type), (char *) NULL);
184 if ((fd = mc_open (s, O_RDONLY)) == -1) {
185 message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s);
186 g_free (s);
187 return -1;
189 g_free (s);
192 super->u.arch.fd = fd;
193 mode = super->u.arch.st.st_mode & 07777;
194 mode |= (mode & 0444) >> 2; /* set eXec where Read is */
195 mode |= S_IFDIR;
197 root = vfs_s_new_inode (me, super, &(super->u.arch.st));
198 root->st.st_mode = mode;
199 root->data_offset = -1;
200 root->st.st_nlink++;
201 root->st.st_dev = MEDATA->rdev++;
203 super->root = root;
205 CPIO_SEEK_SET (super, 0);
207 return fd;
210 static ssize_t cpio_read_head(struct vfs_class *me, struct vfs_s_super *super)
212 switch(cpio_find_head(me, super)) {
213 case CPIO_UNKNOWN:
214 return -1;
215 case CPIO_BIN:
216 case CPIO_BINRE:
217 return cpio_read_bin_head(me, super);
218 case CPIO_OLDC:
219 return cpio_read_oldc_head(me, super);
220 case CPIO_NEWC:
221 case CPIO_CRC:
222 return cpio_read_crc_head(me, super);
223 default:
224 g_assert_not_reached();
225 return 42; /* & the compiler is happy :-) */
229 #define MAGIC_LENGTH (6) /* How many bytes we have to read ahead */
230 #define SEEKBACK CPIO_SEEK_CUR(super, ptr - top)
231 #define RETURN(x) return(super->u.arch.type = (x))
232 #define TYPEIS(x) ((super->u.arch.type == CPIO_UNKNOWN) || (super->u.arch.type == (x)))
233 static int cpio_find_head(struct vfs_class *me, struct vfs_s_super *super)
235 char buf[256];
236 int ptr = 0;
237 int top;
238 int tmp;
240 top = mc_read (super->u.arch.fd, buf, 256);
241 if (top > 0)
242 CPIO_POS (super) += top;
243 for(;;) {
244 if(ptr + MAGIC_LENGTH >= top) {
245 if(top > 128) {
246 memmove(buf, buf + top - 128, 128);
247 ptr -= top - 128;
248 top = 128;
250 if((tmp = mc_read(super->u.arch.fd, buf, top)) == 0 || tmp == -1) {
251 message (D_ERROR, MSG_ERROR, _("Premature end of cpio archive\n%s"), super->name);
252 cpio_free_archive(me, super);
253 return CPIO_UNKNOWN;
255 top += tmp;
257 if(TYPEIS(CPIO_BIN) && ((*(unsigned short *)(buf + ptr)) == 070707)) {
258 SEEKBACK; RETURN(CPIO_BIN);
259 } else if(TYPEIS(CPIO_BINRE) && ((*(unsigned short *)(buf + ptr)) == GUINT16_SWAP_LE_BE_CONSTANT(070707))) {
260 SEEKBACK; RETURN(CPIO_BINRE);
261 } else if(TYPEIS(CPIO_OLDC) && (!strncmp(buf + ptr, "070707", 6))) {
262 SEEKBACK; RETURN(CPIO_OLDC);
263 } else if(TYPEIS(CPIO_NEWC) && (!strncmp(buf + ptr, "070701", 6))) {
264 SEEKBACK; RETURN(CPIO_NEWC);
265 } else if(TYPEIS(CPIO_CRC) && (!strncmp(buf + ptr, "070702", 6))) {
266 SEEKBACK; RETURN(CPIO_CRC);
268 ptr++;
271 #undef RETURN
272 #undef SEEKBACK
274 #define HEAD_LENGTH (26)
275 static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *super)
277 union {
278 struct old_cpio_header buf;
279 short shorts[HEAD_LENGTH >> 1];
280 } u;
281 int len;
282 char *name;
283 struct stat st;
285 if((len = mc_read(super->u.arch.fd, (char *)&u.buf, HEAD_LENGTH)) < HEAD_LENGTH)
286 return STATUS_EOF;
287 CPIO_POS(super) += len;
288 if(super->u.arch.type == CPIO_BINRE) {
289 int i;
290 for(i = 0; i < (HEAD_LENGTH >> 1); i++)
291 u.shorts[i] = GUINT16_SWAP_LE_BE_CONSTANT(u.shorts[i]);
293 g_assert(u.buf.c_magic == 070707);
295 if (u.buf.c_namesize == 0 || u.buf.c_namesize > MC_MAXPATHLEN) {
296 message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"),
297 super->name);
298 return STATUS_FAIL;
300 name = g_malloc(u.buf.c_namesize);
301 if((len = mc_read(super->u.arch.fd, name, u.buf.c_namesize)) < u.buf.c_namesize) {
302 g_free(name);
303 return STATUS_EOF;
305 name[u.buf.c_namesize - 1] = '\0';
306 CPIO_POS(super) += len;
307 cpio_skip_padding(super);
309 if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */
310 g_free(name);
311 return STATUS_TRAIL;
314 st.st_dev = u.buf.c_dev;
315 st.st_ino = u.buf.c_ino;
316 st.st_mode = u.buf.c_mode;
317 st.st_nlink = u.buf.c_nlink;
318 st.st_uid = u.buf.c_uid;
319 st.st_gid = u.buf.c_gid;
320 st.st_rdev = u.buf.c_rdev;
321 st.st_size = (u.buf.c_filesizes[0] << 16) | u.buf.c_filesizes[1];
322 st.st_atime = st.st_mtime = st.st_ctime = (u.buf.c_mtimes[0] << 16) | u.buf.c_mtimes[1];
324 return cpio_create_entry(me, super, &st, name);
326 #undef HEAD_LENGTH
328 #define HEAD_LENGTH (76)
329 static ssize_t cpio_read_oldc_head(struct vfs_class *me, struct vfs_s_super *super)
331 struct new_cpio_header hd;
332 union {
333 struct stat st;
334 char buf[HEAD_LENGTH + 1];
335 } u;
336 int len;
337 char *name;
339 if (mc_read (super->u.arch.fd, u.buf, HEAD_LENGTH) != HEAD_LENGTH)
340 return STATUS_EOF;
341 CPIO_POS (super) += HEAD_LENGTH;
342 u.buf[HEAD_LENGTH] = 0;
344 if (sscanf (u.buf, "070707%6lo%6lo%6lo%6lo%6lo%6lo%6lo%11lo%6lo%11lo",
345 (unsigned long *)&hd.c_dev, &hd.c_ino, &hd.c_mode, &hd.c_uid, &hd.c_gid,
346 &hd.c_nlink, (unsigned long *)&hd.c_rdev, &hd.c_mtime,
347 &hd.c_namesize, &hd.c_filesize) < 10) {
348 message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"),
349 super->name);
350 return STATUS_FAIL;
353 if (hd.c_namesize == 0 || hd.c_namesize > MC_MAXPATHLEN) {
354 message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"),
355 super->name);
356 return STATUS_FAIL;
358 name = g_malloc(hd.c_namesize);
359 if((len = mc_read(super->u.arch.fd, name, hd.c_namesize)) == -1 ||
360 (unsigned long) len < hd.c_namesize) {
361 g_free (name);
362 return STATUS_EOF;
364 name[hd.c_namesize - 1] = '\0';
365 CPIO_POS(super) += len;
366 cpio_skip_padding(super);
368 if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */
369 g_free(name);
370 return STATUS_TRAIL;
373 u.st.st_dev = hd.c_dev;
374 u.st.st_ino = hd.c_ino;
375 u.st.st_mode = hd.c_mode;
376 u.st.st_nlink = hd.c_nlink;
377 u.st.st_uid = hd.c_uid;
378 u.st.st_gid = hd.c_gid;
379 u.st.st_rdev = hd.c_rdev;
380 u.st.st_size = hd.c_filesize;
381 u.st.st_atime = u.st.st_mtime = u.st.st_ctime = hd.c_mtime;
383 return cpio_create_entry (me, super, &u.st, name);
385 #undef HEAD_LENGTH
387 #define HEAD_LENGTH (110)
388 static ssize_t cpio_read_crc_head(struct vfs_class *me, struct vfs_s_super *super)
390 struct new_cpio_header hd;
391 union {
392 struct stat st;
393 char buf[HEAD_LENGTH + 1];
394 } u;
395 int len;
396 char *name;
398 if (mc_read (super->u.arch.fd, u.buf, HEAD_LENGTH) != HEAD_LENGTH)
399 return STATUS_EOF;
400 CPIO_POS (super) += HEAD_LENGTH;
401 u.buf[HEAD_LENGTH] = 0;
403 if (sscanf (u.buf, "%6ho%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx",
404 &hd.c_magic, &hd.c_ino, &hd.c_mode, &hd.c_uid, &hd.c_gid,
405 &hd.c_nlink, &hd.c_mtime, &hd.c_filesize,
406 (unsigned long *)&hd.c_dev, (unsigned long *)&hd.c_devmin, (unsigned long *)&hd.c_rdev, (unsigned long *)&hd.c_rdevmin,
407 &hd.c_namesize, &hd.c_chksum) < 14) {
408 message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"),
409 super->name);
410 return STATUS_FAIL;
413 if((super->u.arch.type == CPIO_NEWC && hd.c_magic != 070701) ||
414 (super->u.arch.type == CPIO_CRC && hd.c_magic != 070702))
415 return STATUS_FAIL;
417 if (hd.c_namesize == 0 || hd.c_namesize > MC_MAXPATHLEN) {
418 message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"),
419 super->name);
420 return STATUS_FAIL;
423 name = g_malloc(hd.c_namesize);
424 if((len = mc_read (super->u.arch.fd, name, hd.c_namesize)) == -1 ||
425 (unsigned long) len < hd.c_namesize) {
426 g_free (name);
427 return STATUS_EOF;
429 name[hd.c_namesize - 1] = '\0';
430 CPIO_POS(super) += len;
431 cpio_skip_padding(super);
433 if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */
434 g_free(name);
435 return STATUS_TRAIL;
438 u.st.st_dev = makedev (hd.c_dev, hd.c_devmin);
439 u.st.st_ino = hd.c_ino;
440 u.st.st_mode = hd.c_mode;
441 u.st.st_nlink = hd.c_nlink;
442 u.st.st_uid = hd.c_uid;
443 u.st.st_gid = hd.c_gid;
444 u.st.st_rdev = makedev (hd.c_rdev, hd.c_rdevmin);
445 u.st.st_size = hd.c_filesize;
446 u.st.st_atime = u.st.st_mtime = u.st.st_ctime = hd.c_mtime;
448 return cpio_create_entry (me, super, &u.st, name);
451 static int
452 cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super,
453 struct stat *st, char *name)
455 struct vfs_s_inode *inode = NULL;
456 struct vfs_s_inode *root = super->root;
457 struct vfs_s_entry *entry = NULL;
458 char *tn;
460 switch (st->st_mode & S_IFMT) { /* For case of HP/UX archives */
461 case S_IFCHR:
462 case S_IFBLK:
463 #ifdef S_IFSOCK
464 case S_IFSOCK:
465 #endif
466 #ifdef S_IFIFO
467 case S_IFIFO:
468 #endif
469 #ifdef S_IFNAM
470 case S_IFNAM:
471 #endif
472 if ((st->st_size != 0) && (st->st_rdev == 0x0001)) {
473 /* FIXME: representation of major/minor differs between */
474 /* different operating systems. */
475 st->st_rdev = (unsigned) st->st_size;
476 st->st_size = 0;
478 break;
479 default:
480 break;
483 if ((st->st_nlink > 1) && (super->u.arch.type == CPIO_NEWC || super->u.arch.type == CPIO_CRC)) { /* For case of hardlinked files */
484 struct defer_inode i, *l;
485 i.inumber = st->st_ino;
486 i.device = st->st_dev;
487 i.inode = NULL;
488 if ((l = cpio_defer_find (super->u.arch.deferred, &i)) != NULL) {
489 inode = l->inode;
490 if (inode->st.st_size && st->st_size
491 && (inode->st.st_size != st->st_size)) {
492 message (D_ERROR, MSG_ERROR,
494 ("Inconsistent hardlinks of\n%s\nin cpio archive\n%s"),
495 name, super->name);
496 inode = NULL;
497 } else if (!inode->st.st_size)
498 inode->st.st_size = st->st_size;
502 for (tn = name + strlen (name) - 1; tn >= name && *tn == PATH_SEP; tn--)
503 *tn = 0;
504 if ((tn = strrchr (name, PATH_SEP))) {
505 *tn = 0;
506 root = vfs_s_find_inode (me, super, name, LINK_FOLLOW, FL_MKDIR);
507 *tn = PATH_SEP;
508 tn++;
509 } else
510 tn = name;
512 entry = MEDATA->find_entry (me, root, tn, LINK_FOLLOW, FL_NONE); /* In case entry is already there */
514 if (entry) { /* This shouldn't happen! (well, it can happen if there is a record for a
515 file and than a record for a directory it is in; cpio would die with
516 'No such file or directory' is such case) */
518 if (!S_ISDIR (entry->ino->st.st_mode)) { /* This can be considered archive inconsistency */
519 message (D_ERROR, MSG_ERROR,
520 _("%s contains duplicate entries! Skipping!"),
521 super->name);
522 } else {
523 entry->ino->st.st_mode = st->st_mode;
524 entry->ino->st.st_uid = st->st_uid;
525 entry->ino->st.st_gid = st->st_gid;
526 entry->ino->st.st_atime = st->st_atime;
527 entry->ino->st.st_mtime = st->st_mtime;
528 entry->ino->st.st_ctime = st->st_ctime;
531 } else { /* !entry */
533 if (!inode) {
534 inode = vfs_s_new_inode (me, super, st);
535 if ((st->st_nlink > 0) && (super->u.arch.type == CPIO_NEWC || super->u.arch.type == CPIO_CRC)) { /* For case of hardlinked files */
536 struct defer_inode *i;
537 i = g_new (struct defer_inode, 1);
538 i->inumber = st->st_ino;
539 i->device = st->st_dev;
540 i->inode = inode;
541 i->next = super->u.arch.deferred;
542 super->u.arch.deferred = i;
546 if (st->st_size)
547 inode->data_offset = CPIO_POS (super);
549 entry = vfs_s_new_entry (me, tn, inode);
550 vfs_s_insert_entry (me, root, entry);
552 if (S_ISLNK (st->st_mode)) {
553 inode->linkname = g_malloc (st->st_size + 1);
554 if (mc_read (super->u.arch.fd, inode->linkname, st->st_size)
555 < st->st_size) {
556 inode->linkname[0] = 0;
557 g_free (name);
558 return STATUS_EOF;
560 inode->linkname[st->st_size] = 0; /* Linkname stored without terminating \0 !!! */
561 CPIO_POS (super) += st->st_size;
562 cpio_skip_padding (super);
563 } else {
564 CPIO_SEEK_CUR (super, st->st_size);
567 } /* !entry */
569 g_free (name);
570 return STATUS_OK;
573 /* Need to CPIO_SEEK_CUR to skip the file at the end of add entry!!!! */
575 static int
576 cpio_open_archive (struct vfs_class *me, struct vfs_s_super *super,
577 const char *name, char *op)
579 int status = STATUS_START;
581 (void) op;
583 if (cpio_open_cpio_file (me, super, name) == -1)
584 return -1;
586 for (;;) {
587 status = cpio_read_head (me, super);
589 switch (status) {
590 case STATUS_EOF:
591 message (D_ERROR, MSG_ERROR, _("Unexpected end of file\n%s"), name);
592 return 0;
593 case STATUS_OK:
594 continue;
595 case STATUS_TRAIL:
596 break;
598 break;
601 return 0;
604 /* Remaining functions are exactly same as for tarfs (and were in fact just copied) */
605 static void *
606 cpio_super_check (struct vfs_class *me, const char *archive_name, char *op)
608 static struct stat sb;
610 (void) me;
611 (void) op;
613 if (mc_stat (archive_name, &sb))
614 return NULL;
615 return &sb;
618 static int
619 cpio_super_same (struct vfs_class *me, struct vfs_s_super *parc,
620 const char *archive_name, char *op, void *cookie)
622 struct stat *archive_stat = cookie; /* stat of main archive */
624 (void) me;
625 (void) op;
627 if (strcmp (parc->name, archive_name))
628 return 0;
630 /* Has the cached archive been changed on the disk? */
631 if (parc->u.arch.st.st_mtime < archive_stat->st_mtime) {
632 /* Yes, reload! */
633 (*vfs_cpiofs_ops.free) ((vfsid) parc);
634 vfs_rmstamp (&vfs_cpiofs_ops, (vfsid) parc);
635 return 2;
637 /* Hasn't been modified, give it a new timeout */
638 vfs_stamp (&vfs_cpiofs_ops, (vfsid) parc);
639 return 1;
642 static ssize_t cpio_read(void *fh, char *buffer, int count)
644 off_t begin = FH->ino->data_offset;
645 int fd = FH_SUPER->u.arch.fd;
646 struct vfs_class *me = FH_SUPER->me;
648 if (mc_lseek (fd, begin + FH->pos, SEEK_SET) !=
649 begin + FH->pos) ERRNOR (EIO, -1);
651 count = MIN(count, FH->ino->st.st_size - FH->pos);
653 if ((count = mc_read (fd, buffer, count)) == -1) ERRNOR (errno, -1);
655 FH->pos += count;
656 return count;
659 static int cpio_fh_open(struct vfs_class *me, struct vfs_s_fh *fh, int flags, int mode)
661 (void) fh;
662 (void) mode;
664 if ((flags & O_ACCMODE) != O_RDONLY) ERRNOR (EROFS, -1);
665 return 0;
668 void
669 init_cpiofs (void)
671 static struct vfs_s_subclass cpio_subclass;
673 cpio_subclass.flags = VFS_S_READONLY;
674 cpio_subclass.archive_check = cpio_super_check;
675 cpio_subclass.archive_same = cpio_super_same;
676 cpio_subclass.open_archive = cpio_open_archive;
677 cpio_subclass.free_archive = cpio_free_archive;
678 cpio_subclass.fh_open = cpio_fh_open;
680 vfs_s_init_class (&vfs_cpiofs_ops, &cpio_subclass);
681 vfs_cpiofs_ops.name = "cpiofs";
682 vfs_cpiofs_ops.prefix = "ucpio";
683 vfs_cpiofs_ops.read = cpio_read;
684 vfs_cpiofs_ops.setctl = NULL;
685 vfs_register_class (&vfs_cpiofs_ops);