From 63740624ea51cfd5965f363f26dc5355f515d4d7 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Thu, 16 Oct 2003 16:40:11 +0000 Subject: [PATCH] * xdirentry.h: Rename vfs_s_data to vfs_s_subclass. * cpio.c: Initialize only non-zero fields in vfs_s_subclass. * fish.c: Likewise. * ftpfs.c: Likewise. * tar.c: Likewise. --- vfs/ChangeLog | 6 ++++++ vfs/cpio.c | 39 ++++++++++----------------------------- vfs/fish.c | 46 ++++++++++++++++------------------------------ vfs/ftpfs.c | 49 ++++++++++++++++++------------------------------- vfs/tar.c | 39 ++++++++++----------------------------- vfs/xdirentry.h | 4 ++-- 6 files changed, 62 insertions(+), 121 deletions(-) diff --git a/vfs/ChangeLog b/vfs/ChangeLog index eac98f180..b32455e53 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,5 +1,11 @@ 2003-10-16 Pavel Roskin + * xdirentry.h: Rename vfs_s_data to vfs_s_subclass. + * cpio.c: Initialize only non-zero fields in vfs_s_subclass. + * fish.c: Likewise. + * ftpfs.c: Likewise. + * tar.c: Likewise. + * vfs.h: Rename commands for mc_ctl() and mc_setctl() to make it clear which function they are used with. * vfs.c (mc_ctl): Change last argument to (void*). diff --git a/vfs/cpio.c b/vfs/cpio.c index b885a55dc..df14bea6e 100644 --- a/vfs/cpio.c +++ b/vfs/cpio.c @@ -594,41 +594,22 @@ static int cpio_fh_open(struct vfs_class *me, struct vfs_s_fh *fh, int flags, in return 0; } -static struct vfs_s_data cpiofs_data = { - NULL, - 0, - 0, - NULL, - - NULL, /* init inode */ - NULL, /* free inode */ - NULL, /* init entry */ - - cpio_super_check, - cpio_super_same, - cpio_open_archive, - cpio_free_archive, - - cpio_fh_open, - NULL, - - vfs_s_find_entry_tree, - NULL, - NULL, - NULL, - - NULL, - NULL, - NULL -}; - void init_cpiofs (void) { + static struct vfs_s_subclass cpiofs_subclass; + + cpiofs_subclass.archive_check = cpio_super_check; + cpiofs_subclass.archive_same = cpio_super_same; + cpiofs_subclass.open_archive = cpio_open_archive; + cpiofs_subclass.free_archive = cpio_free_archive; + cpiofs_subclass.fh_open = cpio_fh_open; + cpiofs_subclass.find_entry = vfs_s_find_entry_tree; + vfs_s_init_class (&vfs_cpiofs_ops); vfs_cpiofs_ops.name = "cpiofs"; vfs_cpiofs_ops.prefix = "ucpio"; - vfs_cpiofs_ops.data = &cpiofs_data; + vfs_cpiofs_ops.data = &cpiofs_subclass; vfs_cpiofs_ops.read = cpio_read; vfs_cpiofs_ops.write = NULL; vfs_cpiofs_ops.setctl = NULL; diff --git a/vfs/fish.c b/vfs/fish.c index 56a202685..766d65d7e 100644 --- a/vfs/fish.c +++ b/vfs/fish.c @@ -833,38 +833,10 @@ static int fish_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags, i return 0; } -static struct vfs_s_data fish_data = { - NULL, - 0, - 0, - NULL, - - NULL, /* init_inode */ - NULL, /* free_inode */ - NULL, /* init_entry */ - - NULL, /* archive_check */ - archive_same, - open_archive, - free_archive, - - fish_fh_open, /* fh_open */ - NULL, /* fh_close */ - - vfs_s_find_entry_linear, - dir_load, - dir_uptodate, - file_store, - - linear_start, - linear_read, - linear_close -}; - static void fish_fill_names (struct vfs_class *me, void (*func)(char *)) { - struct vfs_s_super *super = fish_data.supers; + struct vfs_s_super *super = MEDATA->supers; char *flags; char *name; @@ -895,10 +867,24 @@ fish_fill_names (struct vfs_class *me, void (*func)(char *)) void init_fish (void) { + static struct vfs_s_subclass fish_subclass; + + fish_subclass.archive_same = archive_same; + fish_subclass.open_archive = open_archive; + fish_subclass.free_archive = free_archive; + fish_subclass.fh_open = fish_fh_open; + fish_subclass.find_entry = vfs_s_find_entry_linear; + fish_subclass.dir_load = dir_load; + fish_subclass.dir_uptodate = dir_uptodate; + fish_subclass.file_store = file_store; + fish_subclass.linear_start = linear_start; + fish_subclass.linear_read = linear_read; + fish_subclass.linear_close = linear_close; + vfs_s_init_class (&vfs_fish_ops); vfs_fish_ops.name = "fish"; vfs_fish_ops.prefix = "sh:"; - vfs_fish_ops.data = &fish_data; + vfs_fish_ops.data = &fish_subclass; vfs_fish_ops.fill_names = fish_fill_names; vfs_fish_ops.chmod = fish_chmod; vfs_fish_ops.chown = fish_chown; diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index a0b39e750..10ab19f59 100644 --- a/vfs/ftpfs.c +++ b/vfs/ftpfs.c @@ -1719,34 +1719,6 @@ static int ftpfs_fh_close (struct vfs_class *me, struct vfs_s_fh *fh) return 0; } -static struct vfs_s_data ftp_data = { - NULL, - 0, - 0, - NULL, /* logfile */ - - NULL, /* init_inode */ - NULL, /* free_inode */ - NULL, /* init_entry */ - - NULL, /* archive_check */ - archive_same, - open_archive, - free_archive, - - ftpfs_fh_open, /* fh_open */ - ftpfs_fh_close, /* fh_close */ - - vfs_s_find_entry_linear, - dir_load, - dir_uptodate, - file_store, - - linear_start, - linear_read, - linear_close -}; - static void ftpfs_done (struct vfs_class *me) { @@ -1765,7 +1737,7 @@ ftpfs_done (struct vfs_class *me) static void ftpfs_fill_names (struct vfs_class *me, void (*func)(char *)) { - struct vfs_s_super * super = ftp_data.supers; + struct vfs_s_super *super = MEDATA->supers; char *name; while (super){ @@ -1776,11 +1748,13 @@ ftpfs_fill_names (struct vfs_class *me, void (*func)(char *)) } } +static struct vfs_s_subclass ftpfs_subclass; + void ftpfs_set_debug (const char *file) { logfile = fopen (file, "w+"); if (logfile) - ftp_data.logfile = logfile; + ftpfs_subclass.logfile = logfile; } static char buffer[BUF_MEDIUM]; @@ -2053,11 +2027,24 @@ static int lookup_netrc (const char *host, char **login, char **pass) void init_ftpfs (void) { + ftpfs_subclass.archive_same = archive_same; + ftpfs_subclass.open_archive = open_archive; + ftpfs_subclass.free_archive = free_archive; + ftpfs_subclass.fh_open = ftpfs_fh_open; + ftpfs_subclass.fh_close = ftpfs_fh_close; + ftpfs_subclass.find_entry = vfs_s_find_entry_linear; + ftpfs_subclass.dir_load = dir_load; + ftpfs_subclass.dir_uptodate = dir_uptodate; + ftpfs_subclass.file_store = file_store; + ftpfs_subclass.linear_start = linear_start; + ftpfs_subclass.linear_read = linear_read; + ftpfs_subclass.linear_close = linear_close; + vfs_s_init_class (&vfs_ftpfs_ops); vfs_ftpfs_ops.name = "ftpfs"; vfs_ftpfs_ops.flags = VFSF_NOLINKS; vfs_ftpfs_ops.prefix = "ftp:"; - vfs_ftpfs_ops.data = &ftp_data; + vfs_ftpfs_ops.data = &ftpfs_subclass; vfs_ftpfs_ops.done = &ftpfs_done; vfs_ftpfs_ops.fill_names = ftpfs_fill_names; vfs_ftpfs_ops.chmod = ftpfs_chmod; diff --git a/vfs/tar.c b/vfs/tar.c index e7583370f..5026c9f5b 100644 --- a/vfs/tar.c +++ b/vfs/tar.c @@ -496,41 +496,22 @@ static int tar_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags, in return 0; } -static struct vfs_s_data tarfs_data = { - NULL, - 0, - 0, - NULL, /* logfile */ - - NULL, /* init_inode */ - NULL, /* free_inode */ - NULL, /* init_entry */ - - tar_super_check, - tar_super_same, - open_archive, - tar_free_archive, - - tar_fh_open, /* fh_open */ - NULL, /* fh_close */ - - vfs_s_find_entry_tree, - NULL, - NULL, - NULL, - - NULL, - NULL, - NULL -}; - void init_tarfs (void) { + static struct vfs_s_subclass tarfs_subclass; + + tarfs_subclass.archive_check = tar_super_check; + tarfs_subclass.archive_same = tar_super_same; + tarfs_subclass.open_archive = open_archive; + tarfs_subclass.free_archive = tar_free_archive; + tarfs_subclass.fh_open = tar_fh_open; + tarfs_subclass.find_entry = vfs_s_find_entry_tree; + vfs_s_init_class (&vfs_tarfs_ops); vfs_tarfs_ops.name = "tarfs"; vfs_tarfs_ops.prefix = "utar"; - vfs_tarfs_ops.data = &tarfs_data; + vfs_tarfs_ops.data = &tarfs_subclass; vfs_tarfs_ops.read = tar_read; vfs_tarfs_ops.write = NULL; vfs_tarfs_ops.ungetlocalcopy = tar_ungetlocalcopy; diff --git a/vfs/xdirentry.h b/vfs/xdirentry.h index 9abfd3722..c009fc6a8 100644 --- a/vfs/xdirentry.h +++ b/vfs/xdirentry.h @@ -114,7 +114,7 @@ struct vfs_s_fh { * One of our subclasses (tar, cpio, fish, ftpfs) with data and methods. * Extends vfs_class. Stored in the "data" field of vfs_class. */ -struct vfs_s_data { +struct vfs_s_subclass { struct vfs_s_super *supers; int inode_counter; dev_t rdev; @@ -202,7 +202,7 @@ int vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino); #define ERRNOR(a, b) do { me->verrno = a; return b; } while (0) -#define MEDATA ((struct vfs_s_data *) me->data) +#define MEDATA ((struct vfs_s_subclass *) me->data) #define FH ((struct vfs_s_fh *) fh) #define FH_SUPER FH->ino->super