* 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.
This commit is contained in:
Pavel Roskin 2003-10-11 08:21:16 +00:00
parent 60bab59379
commit 1d6e00faf0
10 changed files with 34 additions and 36 deletions

View File

@ -1,5 +1,12 @@
2003-10-11 Pavel Roskin <proski@gnu.org>
* 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.

View File

@ -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 */

View File

@ -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;

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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

View File

@ -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 <sys/mman.h>
@ -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)