From 1d6e00faf0d7288ca95d11457d8ea4a79f5a1861 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Sat, 11 Oct 2003 08:21:16 +0000 Subject: [PATCH] * vfs.h: Introduce new VFS flags instead of the old unused ones. * vfs.c (vfs_file_class_flags): New function. (vfs_file_is_ftp): Eliminate. (vfs_file_is_smb): Likewise. (vfs_file_is_local): Likewise. (vfs_current_is_local): Use new VFSF_LOCAL flag. --- vfs/ChangeLog | 7 +++++++ vfs/extfs.c | 2 +- vfs/fish.c | 1 - vfs/ftpfs.c | 2 +- vfs/local.c | 2 +- vfs/mcfs.c | 2 +- vfs/sfs.c | 2 +- vfs/smbfs.c | 2 +- vfs/vfs.c | 26 ++++++++------------------ vfs/vfs.h | 24 +++++++++++++----------- 10 files changed, 34 insertions(+), 36 deletions(-) diff --git a/vfs/ChangeLog b/vfs/ChangeLog index b531d69fd..490e2b5c5 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,5 +1,12 @@ 2003-10-11 Pavel Roskin + * vfs.h: Introduce new VFS flags instead of the old unused ones. + * vfs.c (vfs_file_class_flags): New function. + (vfs_file_is_ftp): Eliminate. + (vfs_file_is_smb): Likewise. + (vfs_file_is_local): Likewise. + (vfs_current_is_local): Use new VFSF_LOCAL flag. + * vfs.c: Constify arguments of many functions. * undelfs.c (undelfs_get_path): Constify first argument. diff --git a/vfs/extfs.c b/vfs/extfs.c index c77eba90b..a1e20ad39 100644 --- a/vfs/extfs.c +++ b/vfs/extfs.c @@ -1375,7 +1375,7 @@ static int extfs_setctl (vfs *me, char *path, int ctlop, char *arg) vfs vfs_extfs_ops = { NULL, /* This is place of next pointer */ "extfs", - F_EXEC, /* flags */ + 0, /* flags */ NULL, /* prefix */ NULL, /* data */ 0, /* errno */ diff --git a/vfs/fish.c b/vfs/fish.c index 263ccbadb..ba01c89fd 100644 --- a/vfs/fish.c +++ b/vfs/fish.c @@ -899,7 +899,6 @@ init_fish (void) { vfs_s_init_class (&vfs_fish_ops); vfs_fish_ops.name = "fish"; - vfs_fish_ops.flags = F_EXEC; vfs_fish_ops.prefix = "sh:"; vfs_fish_ops.data = &fish_data; vfs_fish_ops.fill_names = fish_fill_names; diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index 8a458e987..d8dab97fa 100644 --- a/vfs/ftpfs.c +++ b/vfs/ftpfs.c @@ -1771,7 +1771,7 @@ ftpfs_fill_names (vfs *me, void (*func)(char *)) vfs vfs_ftpfs_ops = { NULL, /* This is place of next pointer */ "ftpfs", - F_NET, /* flags */ + VFSF_NOLINKS, /* flags */ "ftp:", /* prefix */ &ftp_data, /* data */ 0, /* errno */ diff --git a/vfs/local.c b/vfs/local.c index bc13b0d10..7463de4dd 100644 --- a/vfs/local.c +++ b/vfs/local.c @@ -306,7 +306,7 @@ local_which (vfs *me, char *path) vfs vfs_local_ops = { NULL, /* This is place of next pointer */ "localfs", - 0, /* flags */ + VFSF_LOCAL, /* flags */ NULL, /* prefix */ NULL, /* data */ 0, /* errno */ diff --git a/vfs/mcfs.c b/vfs/mcfs.c index 6789fc64b..2783f062c 100644 --- a/vfs/mcfs.c +++ b/vfs/mcfs.c @@ -1154,7 +1154,7 @@ mcfs_setctl (vfs *me, char *path, int ctlop, char *arg) vfs vfs_mcfs_ops = { NULL, /* This is place of next pointer */ "mcfs", - F_NET, /* flags */ + 0, /* flags */ "mc:", /* prefix */ NULL, /* data */ 0, /* errno */ diff --git a/vfs/sfs.c b/vfs/sfs.c index 4f239e6c3..d20ef551c 100644 --- a/vfs/sfs.c +++ b/vfs/sfs.c @@ -396,7 +396,7 @@ sfs_which (vfs *me, char *path) vfs vfs_sfs_ops = { NULL, /* This is place of next pointer */ "sfs", - F_EXEC, /* flags */ + 0, /* flags */ NULL, /* prefix */ NULL, /* data */ 0, /* errno */ diff --git a/vfs/smbfs.c b/vfs/smbfs.c index 5339cedd3..da84f5ad4 100644 --- a/vfs/smbfs.c +++ b/vfs/smbfs.c @@ -1890,7 +1890,7 @@ smbfs_fstat (void *data, struct stat *buf) vfs vfs_smbfs_ops = { NULL, /* This is place of next pointer */ "smbfs", - F_NET, /* flags */ + VFSF_NOLINKS, /* flags */ "smb:", /* prefix */ NULL, /* data */ 0, /* errno */ diff --git a/vfs/vfs.c b/vfs/vfs.c index e1bb9191a..9d75fc9b2 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -933,34 +933,24 @@ mc_chdir (char *path) return 0; } +/* Return 1 is the current VFS class is local */ int vfs_current_is_local (void) { - return current_vfs == &vfs_local_ops; + return (current_vfs->flags & VFSF_LOCAL) != 0; } +/* Return flags of the VFS class of the given filename */ int -vfs_file_is_local (const char *file) +vfs_file_class_flags (const char *filename) { - char *filename = vfs_canon (file); - vfs *vfs = vfs_get_class (filename); - - g_free (filename); - return vfs == &vfs_local_ops; -} + struct vfs_class *vfs; + char *fname; -int -vfs_file_is_ftp (const char *filename) -{ -#ifdef USE_NETCODE - vfs *vfs; - char *fname = vfs_canon (filename); + fname = vfs_canon (filename); vfs = vfs_get_class (fname); g_free (fname); - return vfs == &vfs_ftpfs_ops; -#else - return 0; -#endif + return vfs->flags; } int diff --git a/vfs/vfs.h b/vfs/vfs.h index 002875685..bbcfb34d5 100644 --- a/vfs/vfs.h +++ b/vfs/vfs.h @@ -1,6 +1,10 @@ #ifndef __VFS_H #define __VFS_H +/* Flags of VFS classes */ +#define VFSF_LOCAL 1 /* Class is local (not virtual) filesystem */ +#define VFSF_NOLINKS 2 /* Hard links not supported */ + #ifdef USE_VFS #ifdef HAVE_MMAP #include @@ -23,8 +27,6 @@ struct vfs_class { vfs *next; char *name; /* "FIles over SHell" */ int flags; -#define F_EXEC 1 /* Filesystem needs to execute external programs */ -#define F_NET 2 /* Filesystem needs to access network */ char *prefix; /* "fish:" */ void *data; /* this is for filesystem's own use */ int verrno; /* can't use errno because glibc2 might define errno as function */ @@ -127,11 +129,15 @@ char *vfs_path (const char *path); char *vfs_strip_suffix_from_filename (const char *filename); char *vfs_canon (const char *path); char *mc_get_current_wd (char *buffer, int bufsize); -int vfs_current_is_local (void); -int vfs_file_is_local (const char *name); -int vfs_file_is_ftp (const char *filename); -int vfs_file_is_smb (const char *filename); char *vfs_get_current_dir (void); +int vfs_current_is_local (void); +int vfs_file_class_flags (const char *filename); + +static inline int +vfs_file_is_local (const char *filename) +{ + return vfs_file_class_flags (filename) & VFSF_LOCAL; +} extern int vfs_timeout; @@ -208,11 +214,7 @@ int mc_munmap (caddr_t addr, size_t len); #define vfs_add_current_stamps() do { } while (0) #define vfs_current_is_local() 1 #define vfs_file_is_local(x) 1 -#define vfs_file_is_ftp(x) 0 -#define vfs_file_is_smb(x) 0 -#define vfs_current_is_tarfs() 0 -#define vfs_current_is_cpiofs() 0 -#define vfs_current_is_extfs() 0 +#define vfs_file_class_flags(x) (VFSF_LOCAL) #define vfs_path(x) x #define vfs_strip_suffix_from_filename(x) g_strdup(x) #define vfs_release_path(x)