src/cmd.c (select_unselect_cmd): set dialog sizes using constants
[midnight-commander.git] / vfs / cpio.c
blobde8251a19a058e733970435362e214a90de532f4
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>
31 #include "../src/global.h"
32 #include "../src/tty.h" /* enable/disable interrupt key */
33 #include "../src/wtools.h" /* message() */
34 #include "../src/main.h" /* print_vfs_message */
35 #include "utilvfs.h"
36 #include "vfs-impl.h"
37 #include "gc.h" /* vfs_rmstamp */
38 #include "xdirentry.h"
39 #include "../src/unixcompat.h"
41 enum {
42 STATUS_START,
43 STATUS_OK,
44 STATUS_TRAIL,
45 STATUS_FAIL,
46 STATUS_EOF
49 enum {
50 CPIO_UNKNOWN = 0, /* Not determined yet */
51 CPIO_BIN, /* Binary format */
52 CPIO_BINRE, /* Binary format, reverse endianity */
53 CPIO_OLDC, /* Old ASCII format */
54 CPIO_NEWC, /* New ASCII format */
55 CPIO_CRC /* New ASCII format + CRC */
58 static struct vfs_class vfs_cpiofs_ops;
60 struct old_cpio_header
62 unsigned short c_magic;
63 short c_dev;
64 unsigned short c_ino;
65 unsigned short c_mode;
66 unsigned short c_uid;
67 unsigned short c_gid;
68 unsigned short c_nlink;
69 short c_rdev;
70 unsigned short c_mtimes[2];
71 unsigned short c_namesize;
72 unsigned short c_filesizes[2];
75 struct new_cpio_header
77 unsigned short c_magic;
78 unsigned long c_ino;
79 unsigned long c_mode;
80 unsigned long c_uid;
81 unsigned long c_gid;
82 unsigned long c_nlink;
83 unsigned long c_mtime;
84 unsigned long c_filesize;
85 long c_dev;
86 long c_devmin;
87 long c_rdev;
88 long c_rdevmin;
89 unsigned long c_namesize;
90 unsigned long c_chksum;
93 struct defer_inode {
94 struct defer_inode *next;
95 unsigned long inumber;
96 unsigned short device;
97 struct vfs_s_inode *inode;
100 /* FIXME: should be off_t instead of int. */
101 static int cpio_position;
103 static int cpio_find_head(struct vfs_class *me, struct vfs_s_super *super);
104 static int cpio_create_entry(struct vfs_class *me, struct vfs_s_super *super, struct stat *, char *name);
105 static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *super);
106 static ssize_t cpio_read_oldc_head(struct vfs_class *me, struct vfs_s_super *super);
107 static ssize_t cpio_read_crc_head(struct vfs_class *me, struct vfs_s_super *super);
108 static ssize_t cpio_read(void *fh, char *buffer, int count);
110 #define CPIO_POS(super) cpio_position
111 /* If some time reentrancy should be needed change it to */
112 /* #define CPIO_POS(super) (super)->u.arch.fd */
114 #define CPIO_SEEK_SET(super, where) mc_lseek((super)->u.arch.fd, CPIO_POS(super) = (where), SEEK_SET)
115 #define CPIO_SEEK_CUR(super, where) mc_lseek((super)->u.arch.fd, CPIO_POS(super) += (where), SEEK_SET)
117 static struct defer_inode *
118 cpio_defer_find (struct defer_inode *l, struct defer_inode *i)
120 while (l && (l->inumber != i->inumber || l->device != i->device))
121 l = l->next;
122 return l;
125 static int cpio_skip_padding(struct vfs_s_super *super)
127 switch(super->u.arch.type) {
128 case CPIO_BIN:
129 case CPIO_BINRE:
130 return CPIO_SEEK_CUR(super, (2 - (CPIO_POS(super) % 2)) % 2);
131 case CPIO_NEWC:
132 case CPIO_CRC:
133 return CPIO_SEEK_CUR(super, (4 - (CPIO_POS(super) % 4)) % 4);
134 case CPIO_OLDC:
135 return CPIO_POS(super);
136 default:
137 g_assert_not_reached();
138 return 42; /* & the compiler is happy :-) */
142 static void cpio_free_archive(struct vfs_class *me, struct vfs_s_super *super)
144 struct defer_inode *l, *lnext;
146 (void) me;
148 if(super->u.arch.fd != -1)
149 mc_close(super->u.arch.fd);
150 super->u.arch.fd = -1;
151 for (l = super->u.arch.deferred; l; l = lnext) {
152 lnext = l->next;
153 g_free (l);
155 super->u.arch.deferred = NULL;
158 static int
159 cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super,
160 const char *name)
162 int fd, type;
163 mode_t mode;
164 struct vfs_s_inode *root;
166 if ((fd = mc_open (name, O_RDONLY)) == -1) {
167 message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), name);
168 return -1;
171 super->name = g_strdup (name);
172 super->u.arch.fd = -1; /* for now */
173 mc_stat (name, &(super->u.arch.st));
174 super->u.arch.type = CPIO_UNKNOWN;
176 type = get_compression_type (fd);
177 if (type != COMPRESSION_NONE) {
178 char *s;
180 mc_close (fd);
181 s = g_strconcat (name, decompress_extension (type), (char *) NULL);
182 if ((fd = mc_open (s, O_RDONLY)) == -1) {
183 message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s);
184 g_free (s);
185 return -1;
187 g_free (s);
190 super->u.arch.fd = fd;
191 mode = super->u.arch.st.st_mode & 07777;
192 mode |= (mode & 0444) >> 2; /* set eXec where Read is */
193 mode |= S_IFDIR;
195 root = vfs_s_new_inode (me, super, &(super->u.arch.st));
196 root->st.st_mode = mode;
197 root->data_offset = -1;
198 root->st.st_nlink++;
199 root->st.st_dev = MEDATA->rdev++;
201 super->root = root;
203 CPIO_SEEK_SET (super, 0);
205 return fd;
208 static ssize_t cpio_read_head(struct vfs_class *me, struct vfs_s_super *super)
210 switch(cpio_find_head(me, super)) {
211 case CPIO_UNKNOWN:
212 return -1;
213 case CPIO_BIN:
214 case CPIO_BINRE:
215 return cpio_read_bin_head(me, super);
216 case CPIO_OLDC:
217 return cpio_read_oldc_head(me, super);
218 case CPIO_NEWC:
219 case CPIO_CRC:
220 return cpio_read_crc_head(me, super);
221 default:
222 g_assert_not_reached();
223 return 42; /* & the compiler is happy :-) */
227 #define MAGIC_LENGTH (6) /* How many bytes we have to read ahead */
228 #define SEEKBACK CPIO_SEEK_CUR(super, ptr - top)
229 #define RETURN(x) return(super->u.arch.type = (x))
230 #define TYPEIS(x) ((super->u.arch.type == CPIO_UNKNOWN) || (super->u.arch.type == (x)))
231 static int cpio_find_head(struct vfs_class *me, struct vfs_s_super *super)
233 char buf[256];
234 int ptr = 0;
235 int top;
236 int tmp;
238 top = mc_read (super->u.arch.fd, buf, 256);
239 if (top > 0)
240 CPIO_POS (super) += top;
241 for(;;) {
242 if(ptr + MAGIC_LENGTH >= top) {
243 if(top > 128) {
244 memmove(buf, buf + top - 128, 128);
245 ptr -= top - 128;
246 top = 128;
248 if((tmp = mc_read(super->u.arch.fd, buf, top)) == 0 || tmp == -1) {
249 message (D_ERROR, MSG_ERROR, _("Premature end of cpio archive\n%s"), super->name);
250 cpio_free_archive(me, super);
251 return CPIO_UNKNOWN;
253 top += tmp;
255 if(TYPEIS(CPIO_BIN) && ((*(unsigned short *)(buf + ptr)) == 070707)) {
256 SEEKBACK; RETURN(CPIO_BIN);
257 } else if(TYPEIS(CPIO_BINRE) && ((*(unsigned short *)(buf + ptr)) == GUINT16_SWAP_LE_BE_CONSTANT(070707))) {
258 SEEKBACK; RETURN(CPIO_BINRE);
259 } else if(TYPEIS(CPIO_OLDC) && (!strncmp(buf + ptr, "070707", 6))) {
260 SEEKBACK; RETURN(CPIO_OLDC);
261 } else if(TYPEIS(CPIO_NEWC) && (!strncmp(buf + ptr, "070701", 6))) {
262 SEEKBACK; RETURN(CPIO_NEWC);
263 } else if(TYPEIS(CPIO_CRC) && (!strncmp(buf + ptr, "070702", 6))) {
264 SEEKBACK; RETURN(CPIO_CRC);
266 ptr++;
269 #undef RETURN
270 #undef SEEKBACK
272 #define HEAD_LENGTH (26)
273 static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *super)
275 union {
276 struct old_cpio_header buf;
277 short shorts[HEAD_LENGTH >> 1];
278 } u;
279 int len;
280 char *name;
281 struct stat st;
283 if((len = mc_read(super->u.arch.fd, (char *)&u.buf, HEAD_LENGTH)) < HEAD_LENGTH)
284 return STATUS_EOF;
285 CPIO_POS(super) += len;
286 if(super->u.arch.type == CPIO_BINRE) {
287 int i;
288 for(i = 0; i < (HEAD_LENGTH >> 1); i++)
289 u.shorts[i] = GUINT16_SWAP_LE_BE_CONSTANT(u.shorts[i]);
291 g_assert(u.buf.c_magic == 070707);
293 if (u.buf.c_namesize == 0 || u.buf.c_namesize > MC_MAXPATHLEN) {
294 message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"),
295 super->name);
296 return STATUS_FAIL;
298 name = g_malloc(u.buf.c_namesize);
299 if((len = mc_read(super->u.arch.fd, name, u.buf.c_namesize)) < u.buf.c_namesize) {
300 g_free(name);
301 return STATUS_EOF;
303 name[u.buf.c_namesize - 1] = '\0';
304 CPIO_POS(super) += len;
305 cpio_skip_padding(super);
307 if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */
308 g_free(name);
309 return STATUS_TRAIL;
312 st.st_dev = u.buf.c_dev;
313 st.st_ino = u.buf.c_ino;
314 st.st_mode = u.buf.c_mode;
315 st.st_nlink = u.buf.c_nlink;
316 st.st_uid = u.buf.c_uid;
317 st.st_gid = u.buf.c_gid;
318 st.st_rdev = u.buf.c_rdev;
319 st.st_size = (u.buf.c_filesizes[0] << 16) | u.buf.c_filesizes[1];
320 st.st_atime = st.st_mtime = st.st_ctime = (u.buf.c_mtimes[0] << 16) | u.buf.c_mtimes[1];
322 return cpio_create_entry(me, super, &st, name);
324 #undef HEAD_LENGTH
326 #define HEAD_LENGTH (76)
327 static ssize_t cpio_read_oldc_head(struct vfs_class *me, struct vfs_s_super *super)
329 struct new_cpio_header hd;
330 union {
331 struct stat st;
332 char buf[HEAD_LENGTH + 1];
333 } u;
334 int len;
335 char *name;
337 if (mc_read (super->u.arch.fd, u.buf, HEAD_LENGTH) != HEAD_LENGTH)
338 return STATUS_EOF;
339 CPIO_POS (super) += HEAD_LENGTH;
340 u.buf[HEAD_LENGTH] = 0;
342 if (sscanf (u.buf, "070707%6lo%6lo%6lo%6lo%6lo%6lo%6lo%11lo%6lo%11lo",
343 (unsigned long *)&hd.c_dev, &hd.c_ino, &hd.c_mode, &hd.c_uid, &hd.c_gid,
344 &hd.c_nlink, (unsigned long *)&hd.c_rdev, &hd.c_mtime,
345 &hd.c_namesize, &hd.c_filesize) < 10) {
346 message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"),
347 super->name);
348 return STATUS_FAIL;
351 if (hd.c_namesize == 0 || hd.c_namesize > MC_MAXPATHLEN) {
352 message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"),
353 super->name);
354 return STATUS_FAIL;
356 name = g_malloc(hd.c_namesize);
357 if((len = mc_read(super->u.arch.fd, name, hd.c_namesize)) == -1 ||
358 (unsigned long) len < hd.c_namesize) {
359 g_free (name);
360 return STATUS_EOF;
362 name[hd.c_namesize - 1] = '\0';
363 CPIO_POS(super) += len;
364 cpio_skip_padding(super);
366 if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */
367 g_free(name);
368 return STATUS_TRAIL;
371 u.st.st_dev = hd.c_dev;
372 u.st.st_ino = hd.c_ino;
373 u.st.st_mode = hd.c_mode;
374 u.st.st_nlink = hd.c_nlink;
375 u.st.st_uid = hd.c_uid;
376 u.st.st_gid = hd.c_gid;
377 u.st.st_rdev = hd.c_rdev;
378 u.st.st_size = hd.c_filesize;
379 u.st.st_atime = u.st.st_mtime = u.st.st_ctime = hd.c_mtime;
381 return cpio_create_entry (me, super, &u.st, name);
383 #undef HEAD_LENGTH
385 #define HEAD_LENGTH (110)
386 static ssize_t cpio_read_crc_head(struct vfs_class *me, struct vfs_s_super *super)
388 struct new_cpio_header hd;
389 union {
390 struct stat st;
391 char buf[HEAD_LENGTH + 1];
392 } u;
393 int len;
394 char *name;
396 if (mc_read (super->u.arch.fd, u.buf, HEAD_LENGTH) != HEAD_LENGTH)
397 return STATUS_EOF;
398 CPIO_POS (super) += HEAD_LENGTH;
399 u.buf[HEAD_LENGTH] = 0;
401 if (sscanf (u.buf, "%6ho%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx",
402 &hd.c_magic, &hd.c_ino, &hd.c_mode, &hd.c_uid, &hd.c_gid,
403 &hd.c_nlink, &hd.c_mtime, &hd.c_filesize,
404 (unsigned long *)&hd.c_dev, (unsigned long *)&hd.c_devmin, (unsigned long *)&hd.c_rdev, (unsigned long *)&hd.c_rdevmin,
405 &hd.c_namesize, &hd.c_chksum) < 14) {
406 message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"),
407 super->name);
408 return STATUS_FAIL;
411 if((super->u.arch.type == CPIO_NEWC && hd.c_magic != 070701) ||
412 (super->u.arch.type == CPIO_CRC && hd.c_magic != 070702))
413 return STATUS_FAIL;
415 if (hd.c_namesize == 0 || hd.c_namesize > MC_MAXPATHLEN) {
416 message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"),
417 super->name);
418 return STATUS_FAIL;
421 name = g_malloc(hd.c_namesize);
422 if((len = mc_read (super->u.arch.fd, name, hd.c_namesize)) == -1 ||
423 (unsigned long) len < hd.c_namesize) {
424 g_free (name);
425 return STATUS_EOF;
427 name[hd.c_namesize - 1] = '\0';
428 CPIO_POS(super) += len;
429 cpio_skip_padding(super);
431 if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */
432 g_free(name);
433 return STATUS_TRAIL;
436 u.st.st_dev = makedev (hd.c_dev, hd.c_devmin);
437 u.st.st_ino = hd.c_ino;
438 u.st.st_mode = hd.c_mode;
439 u.st.st_nlink = hd.c_nlink;
440 u.st.st_uid = hd.c_uid;
441 u.st.st_gid = hd.c_gid;
442 u.st.st_rdev = makedev (hd.c_rdev, hd.c_rdevmin);
443 u.st.st_size = hd.c_filesize;
444 u.st.st_atime = u.st.st_mtime = u.st.st_ctime = hd.c_mtime;
446 return cpio_create_entry (me, super, &u.st, name);
449 static int
450 cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super,
451 struct stat *st, char *name)
453 struct vfs_s_inode *inode = NULL;
454 struct vfs_s_inode *root = super->root;
455 struct vfs_s_entry *entry = NULL;
456 char *tn;
458 switch (st->st_mode & S_IFMT) { /* For case of HP/UX archives */
459 case S_IFCHR:
460 case S_IFBLK:
461 #ifdef S_IFSOCK
462 case S_IFSOCK:
463 #endif
464 #ifdef S_IFIFO
465 case S_IFIFO:
466 #endif
467 #ifdef S_IFNAM
468 case S_IFNAM:
469 #endif
470 if ((st->st_size != 0) && (st->st_rdev == 0x0001)) {
471 /* FIXME: representation of major/minor differs between */
472 /* different operating systems. */
473 st->st_rdev = (unsigned) st->st_size;
474 st->st_size = 0;
476 break;
477 default:
478 break;
481 if ((st->st_nlink > 1) && (super->u.arch.type == CPIO_NEWC || super->u.arch.type == CPIO_CRC)) { /* For case of hardlinked files */
482 struct defer_inode i, *l;
483 i.inumber = st->st_ino;
484 i.device = st->st_dev;
485 i.inode = NULL;
486 if ((l = cpio_defer_find (super->u.arch.deferred, &i)) != NULL) {
487 inode = l->inode;
488 if (inode->st.st_size && st->st_size
489 && (inode->st.st_size != st->st_size)) {
490 message (D_ERROR, MSG_ERROR,
492 ("Inconsistent hardlinks of\n%s\nin cpio archive\n%s"),
493 name, super->name);
494 inode = NULL;
495 } else if (!inode->st.st_size)
496 inode->st.st_size = st->st_size;
500 for (tn = name + strlen (name) - 1; tn >= name && *tn == PATH_SEP; tn--)
501 *tn = 0;
502 if ((tn = strrchr (name, PATH_SEP))) {
503 *tn = 0;
504 root = vfs_s_find_inode (me, super, name, LINK_FOLLOW, FL_MKDIR);
505 *tn = PATH_SEP;
506 tn++;
507 } else
508 tn = name;
510 entry = MEDATA->find_entry (me, root, tn, LINK_FOLLOW, FL_NONE); /* In case entry is already there */
512 if (entry) { /* This shouldn't happen! (well, it can happen if there is a record for a
513 file and than a record for a directory it is in; cpio would die with
514 'No such file or directory' is such case) */
516 if (!S_ISDIR (entry->ino->st.st_mode)) { /* This can be considered archive inconsistency */
517 message (D_ERROR, MSG_ERROR,
518 _("%s contains duplicate entries! Skipping!"),
519 super->name);
520 } else {
521 entry->ino->st.st_mode = st->st_mode;
522 entry->ino->st.st_uid = st->st_uid;
523 entry->ino->st.st_gid = st->st_gid;
524 entry->ino->st.st_atime = st->st_atime;
525 entry->ino->st.st_mtime = st->st_mtime;
526 entry->ino->st.st_ctime = st->st_ctime;
529 } else { /* !entry */
531 if (!inode) {
532 inode = vfs_s_new_inode (me, super, st);
533 if ((st->st_nlink > 0) && (super->u.arch.type == CPIO_NEWC || super->u.arch.type == CPIO_CRC)) { /* For case of hardlinked files */
534 struct defer_inode *i;
535 i = g_new (struct defer_inode, 1);
536 i->inumber = st->st_ino;
537 i->device = st->st_dev;
538 i->inode = inode;
539 i->next = super->u.arch.deferred;
540 super->u.arch.deferred = i;
544 if (st->st_size)
545 inode->data_offset = CPIO_POS (super);
547 entry = vfs_s_new_entry (me, tn, inode);
548 vfs_s_insert_entry (me, root, entry);
550 if (S_ISLNK (st->st_mode)) {
551 inode->linkname = g_malloc (st->st_size + 1);
552 if (mc_read (super->u.arch.fd, inode->linkname, st->st_size)
553 < st->st_size) {
554 inode->linkname[0] = 0;
555 g_free (name);
556 return STATUS_EOF;
558 inode->linkname[st->st_size] = 0; /* Linkname stored without terminating \0 !!! */
559 CPIO_POS (super) += st->st_size;
560 cpio_skip_padding (super);
561 } else {
562 CPIO_SEEK_CUR (super, st->st_size);
565 } /* !entry */
567 g_free (name);
568 return STATUS_OK;
571 /* Need to CPIO_SEEK_CUR to skip the file at the end of add entry!!!! */
573 static int
574 cpio_open_archive (struct vfs_class *me, struct vfs_s_super *super,
575 const char *name, char *op)
577 int status = STATUS_START;
579 (void) op;
581 if (cpio_open_cpio_file (me, super, name) == -1)
582 return -1;
584 for (;;) {
585 status = cpio_read_head (me, super);
587 switch (status) {
588 case STATUS_EOF:
589 message (D_ERROR, MSG_ERROR, _("Unexpected end of file\n%s"), name);
590 return 0;
591 case STATUS_OK:
592 continue;
593 case STATUS_TRAIL:
594 break;
596 break;
599 return 0;
602 /* Remaining functions are exactly same as for tarfs (and were in fact just copied) */
603 static void *
604 cpio_super_check (struct vfs_class *me, const char *archive_name, char *op)
606 static struct stat sb;
608 (void) me;
609 (void) op;
611 if (mc_stat (archive_name, &sb))
612 return NULL;
613 return &sb;
616 static int
617 cpio_super_same (struct vfs_class *me, struct vfs_s_super *parc,
618 const char *archive_name, char *op, void *cookie)
620 struct stat *archive_stat = cookie; /* stat of main archive */
622 (void) me;
623 (void) op;
625 if (strcmp (parc->name, archive_name))
626 return 0;
628 /* Has the cached archive been changed on the disk? */
629 if (parc->u.arch.st.st_mtime < archive_stat->st_mtime) {
630 /* Yes, reload! */
631 (*vfs_cpiofs_ops.free) ((vfsid) parc);
632 vfs_rmstamp (&vfs_cpiofs_ops, (vfsid) parc);
633 return 2;
635 /* Hasn't been modified, give it a new timeout */
636 vfs_stamp (&vfs_cpiofs_ops, (vfsid) parc);
637 return 1;
640 static ssize_t cpio_read(void *fh, char *buffer, int count)
642 off_t begin = FH->ino->data_offset;
643 int fd = FH_SUPER->u.arch.fd;
644 struct vfs_class *me = FH_SUPER->me;
646 if (mc_lseek (fd, begin + FH->pos, SEEK_SET) !=
647 begin + FH->pos) ERRNOR (EIO, -1);
649 count = MIN(count, FH->ino->st.st_size - FH->pos);
651 if ((count = mc_read (fd, buffer, count)) == -1) ERRNOR (errno, -1);
653 FH->pos += count;
654 return count;
657 static int cpio_fh_open(struct vfs_class *me, struct vfs_s_fh *fh, int flags, int mode)
659 (void) fh;
660 (void) mode;
662 if ((flags & O_ACCMODE) != O_RDONLY) ERRNOR (EROFS, -1);
663 return 0;
666 void
667 init_cpiofs (void)
669 static struct vfs_s_subclass cpio_subclass;
671 cpio_subclass.flags = VFS_S_READONLY;
672 cpio_subclass.archive_check = cpio_super_check;
673 cpio_subclass.archive_same = cpio_super_same;
674 cpio_subclass.open_archive = cpio_open_archive;
675 cpio_subclass.free_archive = cpio_free_archive;
676 cpio_subclass.fh_open = cpio_fh_open;
678 vfs_s_init_class (&vfs_cpiofs_ops, &cpio_subclass);
679 vfs_cpiofs_ops.name = "cpiofs";
680 vfs_cpiofs_ops.prefix = "ucpio";
681 vfs_cpiofs_ops.read = cpio_read;
682 vfs_cpiofs_ops.setctl = NULL;
683 vfs_register_class (&vfs_cpiofs_ops);