* vfs.h: Constify chdir() and opendir() methods. Adjust all
dependencies. * vfs.c (mc_chdir): Constify, eliminate protection against broken implementations of chdir() method. (mc_opendir): Constify.
Этот коммит содержится в:
родитель
4b5a2a0b62
Коммит
30c4bd1b6d
@ -1,5 +1,11 @@
|
|||||||
2003-11-13 Pavel Roskin <proski@gnu.org>
|
2003-11-13 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* vfs.h: Constify chdir() and opendir() methods. Adjust all
|
||||||
|
dependencies.
|
||||||
|
* vfs.c (mc_chdir): Constify, eliminate protection against
|
||||||
|
broken implementations of chdir() method.
|
||||||
|
(mc_opendir): Constify.
|
||||||
|
|
||||||
* direntry.c (vfs_s_stamp_me): Generalize and move ...
|
* direntry.c (vfs_s_stamp_me): Generalize and move ...
|
||||||
* gc.c (vfs_stamp_create): ... here. Use whenever possible.
|
* gc.c (vfs_stamp_create): ... here. Use whenever possible.
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ struct dirhandle {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
vfs_s_opendir (struct vfs_class *me, char *dirname)
|
vfs_s_opendir (struct vfs_class *me, const char *dirname)
|
||||||
{
|
{
|
||||||
struct vfs_s_inode *dir;
|
struct vfs_s_inode *dir;
|
||||||
struct dirhandle *info;
|
struct dirhandle *info;
|
||||||
@ -618,7 +618,7 @@ vfs_s_closedir (void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vfs_s_chdir (struct vfs_class *me, char *path)
|
vfs_s_chdir (struct vfs_class *me, const char *path)
|
||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
if (!(data = vfs_s_opendir (me, path)))
|
if (!(data = vfs_s_opendir (me, path)))
|
||||||
|
@ -854,7 +854,7 @@ static int extfs_errno (struct vfs_class *me)
|
|||||||
return my_errno;
|
return my_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * extfs_opendir (struct vfs_class *me, char *dirname)
|
static void * extfs_opendir (struct vfs_class *me, const char *dirname)
|
||||||
{
|
{
|
||||||
struct archive *archive;
|
struct archive *archive;
|
||||||
char *q;
|
char *q;
|
||||||
@ -1071,7 +1071,7 @@ static int extfs_rmdir (struct vfs_class *me, char *path)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int extfs_chdir (struct vfs_class *me, char *path)
|
static int extfs_chdir (struct vfs_class *me, const char *path)
|
||||||
{
|
{
|
||||||
struct archive *archive;
|
struct archive *archive;
|
||||||
char *q;
|
char *q;
|
||||||
|
@ -74,7 +74,7 @@ local_errno (struct vfs_class *me)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
local_opendir (struct vfs_class *me, char *dirname)
|
local_opendir (struct vfs_class *me, const char *dirname)
|
||||||
{
|
{
|
||||||
DIR **local_info;
|
DIR **local_info;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
@ -193,7 +193,7 @@ local_rename (struct vfs_class *me, char *a, char *b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
local_chdir (struct vfs_class *me, char *path)
|
local_chdir (struct vfs_class *me, const char *path)
|
||||||
{
|
{
|
||||||
return chdir (path);
|
return chdir (path);
|
||||||
}
|
}
|
||||||
|
@ -629,7 +629,7 @@ typedef struct {
|
|||||||
} opendir_info;
|
} opendir_info;
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
mcfs_opendir (struct vfs_class *me, char *dirname)
|
mcfs_opendir (struct vfs_class *me, const char *dirname)
|
||||||
{
|
{
|
||||||
opendir_info *mcfs_info;
|
opendir_info *mcfs_info;
|
||||||
mcfs_connection *mc;
|
mcfs_connection *mc;
|
||||||
@ -1011,7 +1011,7 @@ mcfs_rename (struct vfs_class *me, char *a, char *b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mcfs_chdir (struct vfs_class *me, char *path)
|
mcfs_chdir (struct vfs_class *me, const char *path)
|
||||||
{
|
{
|
||||||
char *remote_dir;
|
char *remote_dir;
|
||||||
mcfs_connection *mc;
|
mcfs_connection *mc;
|
||||||
|
16
vfs/smbfs.c
16
vfs/smbfs.c
@ -1187,7 +1187,7 @@ is_error (int result, int errno_num)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
smbfs_opendir (struct vfs_class *me, char *dirname)
|
smbfs_opendir (struct vfs_class *me, const char *dirname)
|
||||||
{
|
{
|
||||||
opendir_info *smbfs_info;
|
opendir_info *smbfs_info;
|
||||||
smbfs_connection *sc;
|
smbfs_connection *sc;
|
||||||
@ -1436,16 +1436,16 @@ smbfs_get_stat_info (smbfs_connection * sc, char *path, struct stat *buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
smbfs_chdir (struct vfs_class *me, char *path)
|
smbfs_chdir (struct vfs_class *me, const char *path)
|
||||||
{
|
{
|
||||||
char *remote_dir;
|
char *remote_dir;
|
||||||
smbfs_connection *sc;
|
smbfs_connection *sc;
|
||||||
|
|
||||||
DEBUG(3, ("smbfs_chdir(path:%s)\n", path));
|
DEBUG (3, ("smbfs_chdir(path:%s)\n", path));
|
||||||
if (!(remote_dir = smbfs_get_path (&sc, path)))
|
if (!(remote_dir = smbfs_get_path (&sc, path)))
|
||||||
return -1;
|
return -1;
|
||||||
g_free (remote_dir);
|
g_free (remote_dir);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
vfs/vfs.c
20
vfs/vfs.c
@ -453,17 +453,18 @@ mc_close (int handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DIR *
|
DIR *
|
||||||
mc_opendir (char *dirname)
|
mc_opendir (const char *dirname)
|
||||||
{
|
{
|
||||||
int handle, *handlep;
|
int handle, *handlep;
|
||||||
void *info;
|
void *info;
|
||||||
struct vfs_class *vfs;
|
struct vfs_class *vfs;
|
||||||
|
char *dname;
|
||||||
|
|
||||||
dirname = vfs_canon (dirname);
|
dname = vfs_canon (dirname);
|
||||||
vfs = vfs_get_class (dirname);
|
vfs = vfs_get_class (dname);
|
||||||
|
|
||||||
info = vfs->opendir ? (*vfs->opendir)(vfs, dirname) : NULL;
|
info = vfs->opendir ? (*vfs->opendir)(vfs, dname) : NULL;
|
||||||
g_free (dirname);
|
g_free (dname);
|
||||||
if (!info){
|
if (!info){
|
||||||
errno = vfs->opendir ? ferrno (vfs) : E_NOTSUPP;
|
errno = vfs->opendir ? ferrno (vfs) : E_NOTSUPP;
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -663,9 +664,9 @@ vfs_canon (const char *path)
|
|||||||
* Return 0 on success, -1 on failure.
|
* Return 0 on success, -1 on failure.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mc_chdir (char *path)
|
mc_chdir (const char *path)
|
||||||
{
|
{
|
||||||
char *new_dir, *new_dir_copy;
|
char *new_dir;
|
||||||
struct vfs_class *old_vfs, *new_vfs;
|
struct vfs_class *old_vfs, *new_vfs;
|
||||||
vfsid old_vfsid;
|
vfsid old_vfsid;
|
||||||
struct vfs_stamping *parent;
|
struct vfs_stamping *parent;
|
||||||
@ -676,10 +677,7 @@ mc_chdir (char *path)
|
|||||||
if (!new_vfs->chdir)
|
if (!new_vfs->chdir)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* new_vfs->chdir can write to the second argument, use a copy */
|
result = (*new_vfs->chdir) (new_vfs, new_dir);
|
||||||
new_dir_copy = g_strdup (new_dir);
|
|
||||||
result = (*new_vfs->chdir) (new_vfs, new_dir_copy);
|
|
||||||
g_free (new_dir_copy);
|
|
||||||
|
|
||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
errno = ferrno (new_vfs);
|
errno = ferrno (new_vfs);
|
||||||
|
@ -33,7 +33,7 @@ struct vfs_class {
|
|||||||
int (*read) (void *vfs_info, char *buffer, int count);
|
int (*read) (void *vfs_info, char *buffer, int count);
|
||||||
int (*write) (void *vfs_info, char *buf, int count);
|
int (*write) (void *vfs_info, char *buf, int count);
|
||||||
|
|
||||||
void *(*opendir) (struct vfs_class *me, char *dirname);
|
void *(*opendir) (struct vfs_class *me, const char *dirname);
|
||||||
void *(*readdir) (void *vfs_info);
|
void *(*readdir) (void *vfs_info);
|
||||||
int (*closedir) (void *vfs_info);
|
int (*closedir) (void *vfs_info);
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ struct vfs_class {
|
|||||||
int (*link) (struct vfs_class *me, char *p1, char *p2);
|
int (*link) (struct vfs_class *me, char *p1, char *p2);
|
||||||
int (*unlink) (struct vfs_class *me, char *path);
|
int (*unlink) (struct vfs_class *me, char *path);
|
||||||
int (*rename) (struct vfs_class *me, char *p1, char *p2);
|
int (*rename) (struct vfs_class *me, char *p1, char *p2);
|
||||||
int (*chdir) (struct vfs_class *me, char *path);
|
int (*chdir) (struct vfs_class *me, const char *path);
|
||||||
int (*ferrno) (struct vfs_class *me);
|
int (*ferrno) (struct vfs_class *me);
|
||||||
int (*lseek) (void *vfs_info, off_t offset, int whence);
|
int (*lseek) (void *vfs_info, off_t offset, int whence);
|
||||||
int (*mknod) (struct vfs_class *me, char *path, int mode, int dev);
|
int (*mknod) (struct vfs_class *me, char *path, int mode, int dev);
|
||||||
@ -138,9 +138,9 @@ int mc_close (int handle);
|
|||||||
int mc_read (int handle, char *buffer, int count);
|
int mc_read (int handle, char *buffer, int count);
|
||||||
int mc_write (int handle, char *buffer, int count);
|
int mc_write (int handle, char *buffer, int count);
|
||||||
off_t mc_lseek (int fd, off_t offset, int whence);
|
off_t mc_lseek (int fd, off_t offset, int whence);
|
||||||
int mc_chdir (char *);
|
int mc_chdir (const char *path);
|
||||||
|
|
||||||
DIR *mc_opendir (char *dirname);
|
DIR *mc_opendir (const char *dirname);
|
||||||
struct dirent *mc_readdir (DIR * dirp);
|
struct dirent *mc_readdir (DIR * dirp);
|
||||||
int mc_closedir (DIR * dir);
|
int mc_closedir (DIR * dir);
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user