* vfs.c: Eliminate MC_OP. Reorder other MC_* macros for
readability.
Этот коммит содержится в:
родитель
0318ed5d0b
Коммит
106a90ae99
@ -1,5 +1,8 @@
|
|||||||
2003-11-05 Pavel Roskin <proski@gnu.org>
|
2003-11-05 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* vfs.c: Eliminate MC_OP. Reorder other MC_* macros for
|
||||||
|
readability.
|
||||||
|
|
||||||
* vfs.c: Move all parsing code, vfs_die() and vfs_get_password()
|
* vfs.c: Move all parsing code, vfs_die() and vfs_get_password()
|
||||||
to utilvfs.c, vfs_print_stats() to direntry.c.
|
to utilvfs.c, vfs_print_stats() to direntry.c.
|
||||||
* utilvfs.c (vfs_parse_ls_lga): Disable caching current date,
|
* utilvfs.c (vfs_parse_ls_lga): Disable caching current date,
|
||||||
|
119
vfs/vfs.c
119
vfs/vfs.c
@ -454,26 +454,75 @@ mc_open (const char *filename, int flags, ...)
|
|||||||
return vfs_new_handle (vfs, info);
|
return vfs_new_handle (vfs, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MC_OP(name, inarg, callarg, pre, post) \
|
|
||||||
int mc_##name inarg \
|
|
||||||
{ \
|
|
||||||
struct vfs_class *vfs; \
|
|
||||||
int result; \
|
|
||||||
\
|
|
||||||
pre \
|
|
||||||
result = vfs->name ? (*vfs->name)callarg : -1; \
|
|
||||||
post \
|
|
||||||
if (result == -1) \
|
|
||||||
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \
|
|
||||||
return result; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MC_NAMEOP(name, inarg, callarg) \
|
#define MC_NAMEOP(name, inarg, callarg) \
|
||||||
MC_OP (name, inarg, callarg, path = vfs_canon (path); vfs = vfs_get_class (path);, g_free (path); )
|
int mc_##name inarg \
|
||||||
|
{ \
|
||||||
|
struct vfs_class *vfs; \
|
||||||
|
int result; \
|
||||||
|
path = vfs_canon (path); \
|
||||||
|
vfs = vfs_get_class (path); \
|
||||||
|
result = vfs->name ? (*vfs->name)callarg : -1; \
|
||||||
|
g_free (path); \
|
||||||
|
if (result == -1) \
|
||||||
|
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \
|
||||||
|
return result; \
|
||||||
|
}
|
||||||
|
|
||||||
|
MC_NAMEOP (chmod, (char *path, int mode), (vfs, path, mode))
|
||||||
|
MC_NAMEOP (chown, (char *path, int owner, int group), (vfs, path, owner, group))
|
||||||
|
MC_NAMEOP (utime, (char *path, struct utimbuf *times), (vfs, path, times))
|
||||||
|
MC_NAMEOP (readlink, (char *path, char *buf, int bufsiz), (vfs, path, buf, bufsiz))
|
||||||
|
MC_NAMEOP (unlink, (char *path), (vfs, path))
|
||||||
|
MC_NAMEOP (symlink, (char *name1, char *path), (vfs, name1, path))
|
||||||
|
MC_NAMEOP (mkdir, (char *path, mode_t mode), (vfs, path, mode))
|
||||||
|
MC_NAMEOP (rmdir, (char *path), (vfs, path))
|
||||||
|
MC_NAMEOP (mknod, (char *path, int mode, int dev), (vfs, path, mode, dev))
|
||||||
|
|
||||||
|
|
||||||
#define MC_HANDLEOP(name, inarg, callarg) \
|
#define MC_HANDLEOP(name, inarg, callarg) \
|
||||||
MC_OP (name, inarg, callarg, if (handle == -1) return -1; vfs = vfs_op (handle);, ;)
|
int mc_##name inarg \
|
||||||
|
{ \
|
||||||
|
struct vfs_class *vfs; \
|
||||||
|
int result; \
|
||||||
|
if (handle == -1) \
|
||||||
|
return -1; \
|
||||||
|
vfs = vfs_op (handle); \
|
||||||
|
result = vfs->name ? (*vfs->name)callarg : -1; \
|
||||||
|
if (result == -1) \
|
||||||
|
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \
|
||||||
|
return result; \
|
||||||
|
}
|
||||||
|
|
||||||
MC_HANDLEOP(read, (int handle, char *buffer, int count), (vfs_info (handle), buffer, count) )
|
MC_HANDLEOP(read, (int handle, char *buffer, int count), (vfs_info (handle), buffer, count) )
|
||||||
|
MC_HANDLEOP (write, (int handle, char *buf, int nbyte), (vfs_info (handle), buf, nbyte))
|
||||||
|
|
||||||
|
|
||||||
|
#define MC_RENAMEOP(name) \
|
||||||
|
int mc_##name (const char *fname1, const char *fname2) \
|
||||||
|
{ \
|
||||||
|
struct vfs_class *vfs; \
|
||||||
|
int result; \
|
||||||
|
char *name2, *name1 = vfs_canon (fname1); \
|
||||||
|
vfs = vfs_get_class (name1); \
|
||||||
|
name2 = vfs_canon (fname2); \
|
||||||
|
if (vfs != vfs_get_class (name2)){ \
|
||||||
|
errno = EXDEV; \
|
||||||
|
g_free (name1); \
|
||||||
|
g_free (name2); \
|
||||||
|
return -1; \
|
||||||
|
} \
|
||||||
|
result = vfs->name ? (*vfs->name)(vfs, name1, name2) : -1; \
|
||||||
|
g_free (name1); \
|
||||||
|
g_free (name2); \
|
||||||
|
if (result == -1) \
|
||||||
|
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \
|
||||||
|
return result; \
|
||||||
|
}
|
||||||
|
|
||||||
|
MC_RENAMEOP (link)
|
||||||
|
MC_RENAMEOP (rename)
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
mc_ctl (int handle, int ctlop, void *arg)
|
mc_ctl (int handle, int ctlop, void *arg)
|
||||||
@ -679,42 +728,6 @@ vfs_get_current_dir (void)
|
|||||||
return current_dir;
|
return current_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
MC_NAMEOP (chmod, (char *path, int mode), (vfs, path, mode))
|
|
||||||
MC_NAMEOP (chown, (char *path, int owner, int group), (vfs, path, owner, group))
|
|
||||||
MC_NAMEOP (utime, (char *path, struct utimbuf *times), (vfs, path, times))
|
|
||||||
MC_NAMEOP (readlink, (char *path, char *buf, int bufsiz), (vfs, path, buf, bufsiz))
|
|
||||||
MC_NAMEOP (unlink, (char *path), (vfs, path))
|
|
||||||
MC_NAMEOP (symlink, (char *name1, char *path), (vfs, name1, path))
|
|
||||||
|
|
||||||
#define MC_RENAMEOP(name) \
|
|
||||||
int mc_##name (const char *fname1, const char *fname2) \
|
|
||||||
{ \
|
|
||||||
struct vfs_class *vfs; \
|
|
||||||
int result; \
|
|
||||||
\
|
|
||||||
char *name2, *name1 = vfs_canon (fname1); \
|
|
||||||
vfs = vfs_get_class (name1); \
|
|
||||||
name2 = vfs_canon (fname2); \
|
|
||||||
if (vfs != vfs_get_class (name2)){ \
|
|
||||||
errno = EXDEV; \
|
|
||||||
g_free (name1); \
|
|
||||||
g_free (name2); \
|
|
||||||
return -1; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
result = vfs->name ? (*vfs->name)(vfs, name1, name2) : -1; \
|
|
||||||
g_free (name1); \
|
|
||||||
g_free (name2); \
|
|
||||||
if (result == -1) \
|
|
||||||
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \
|
|
||||||
return result; \
|
|
||||||
}
|
|
||||||
|
|
||||||
MC_RENAMEOP (link)
|
|
||||||
MC_RENAMEOP (rename)
|
|
||||||
|
|
||||||
MC_HANDLEOP (write, (int handle, char *buf, int nbyte), (vfs_info (handle), buf, nbyte))
|
|
||||||
|
|
||||||
off_t mc_lseek (int fd, off_t offset, int whence)
|
off_t mc_lseek (int fd, off_t offset, int whence)
|
||||||
{
|
{
|
||||||
struct vfs_class *vfs;
|
struct vfs_class *vfs;
|
||||||
@ -987,10 +1000,6 @@ vfs_file_class_flags (const char *filename)
|
|||||||
return vfs->flags;
|
return vfs->flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
MC_NAMEOP (mkdir, (char *path, mode_t mode), (vfs, path, mode))
|
|
||||||
MC_NAMEOP (rmdir, (char *path), (vfs, path))
|
|
||||||
MC_NAMEOP (mknod, (char *path, int mode, int dev), (vfs, path, mode, dev))
|
|
||||||
|
|
||||||
#ifdef HAVE_MMAP
|
#ifdef HAVE_MMAP
|
||||||
static struct mc_mmapping {
|
static struct mc_mmapping {
|
||||||
caddr_t addr;
|
caddr_t addr;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user