mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
Following prototypes of functions was changed in VFS-module API:
* opendir * stat * lstat * chdir Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
bf54195f07
commit
1406eb5035
@ -438,21 +438,29 @@ vfs_s_inode_from_path (struct vfs_class *me, const char *name, int flags)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void *
|
||||
vfs_s_opendir (struct vfs_class *me, const char *dirname)
|
||||
vfs_s_opendir (const vfs_path_t * vpath)
|
||||
{
|
||||
struct vfs_s_inode *dir;
|
||||
struct dirhandle *info;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
dir = vfs_s_inode_from_path (me, dirname, FL_DIR | FL_FOLLOW);
|
||||
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
|
||||
dir = vfs_s_inode_from_path (path_element->class, vpath->unparsed, FL_DIR | FL_FOLLOW);
|
||||
if (dir == NULL)
|
||||
return NULL;
|
||||
if (!S_ISDIR (dir->st.st_mode))
|
||||
ERRNOR (ENOTDIR, NULL);
|
||||
{
|
||||
path_element->class->verrno = ENOTDIR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dir->st.st_nlink++;
|
||||
#if 0
|
||||
if (dir->subdir == NULL) /* This can actually happen if we allow empty directories */
|
||||
ERRNOR (EAGAIN, NULL);
|
||||
{
|
||||
path_element->class->verrno = EAGAIN;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
info = g_new (struct dirhandle, 1);
|
||||
info->cur = dir->subdir;
|
||||
@ -501,11 +509,11 @@ vfs_s_closedir (void *data)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
vfs_s_chdir (struct vfs_class *me, const char *path)
|
||||
vfs_s_chdir (const vfs_path_t * vpath)
|
||||
{
|
||||
void *data;
|
||||
|
||||
data = vfs_s_opendir (me, path);
|
||||
data = vfs_s_opendir (vpath);
|
||||
if (data == NULL)
|
||||
return -1;
|
||||
vfs_s_closedir (data);
|
||||
@ -516,11 +524,13 @@ vfs_s_chdir (struct vfs_class *me, const char *path)
|
||||
/* --------------------------- stat and friends ---------------------------- */
|
||||
|
||||
static int
|
||||
vfs_s_internal_stat (struct vfs_class *me, const char *path, struct stat *buf, int flag)
|
||||
vfs_s_internal_stat (const vfs_path_t * vpath, struct stat *buf, int flag)
|
||||
{
|
||||
struct vfs_s_inode *ino;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
ino = vfs_s_inode_from_path (me, path, flag);
|
||||
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
|
||||
ino = vfs_s_inode_from_path (path_element->class, vpath->unparsed, flag);
|
||||
if (ino == NULL)
|
||||
return -1;
|
||||
*buf = ino->st;
|
||||
@ -530,17 +540,17 @@ vfs_s_internal_stat (struct vfs_class *me, const char *path, struct stat *buf, i
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
vfs_s_stat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||
vfs_s_stat (const vfs_path_t * vpath, struct stat *buf)
|
||||
{
|
||||
return vfs_s_internal_stat (me, path, buf, FL_FOLLOW);
|
||||
return vfs_s_internal_stat (vpath, buf, FL_FOLLOW);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
vfs_s_lstat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||
vfs_s_lstat (const vfs_path_t * vpath, struct stat *buf)
|
||||
{
|
||||
return vfs_s_internal_stat (me, path, buf, FL_NONE);
|
||||
return vfs_s_internal_stat (vpath, buf, FL_NONE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -447,48 +447,39 @@ mc_opendir (const char *dirname)
|
||||
{
|
||||
int handle, *handlep;
|
||||
void *info;
|
||||
struct vfs_class *vfs;
|
||||
char *canon;
|
||||
char *dname;
|
||||
struct vfs_dirinfo *dirinfo;
|
||||
const char *encoding;
|
||||
vfs_path_t *vpath;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
canon = vfs_canon (dirname);
|
||||
dname = vfs_translate_path_n (canon);
|
||||
vpath = vfs_path_from_str (dirname);
|
||||
|
||||
if (dname != NULL)
|
||||
if (vpath == NULL)
|
||||
return NULL;
|
||||
|
||||
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
|
||||
|
||||
info = path_element->class->opendir ? (*path_element->class->opendir) (vpath) : NULL;
|
||||
|
||||
if (info == NULL)
|
||||
{
|
||||
vfs = vfs_get_class (dname);
|
||||
info = vfs->opendir ? (*vfs->opendir) (vfs, dname) : NULL;
|
||||
g_free (dname);
|
||||
|
||||
if (info == NULL)
|
||||
{
|
||||
errno = vfs->opendir ? vfs_ferrno (vfs) : E_NOTSUPP;
|
||||
g_free (canon);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dirinfo = g_new (struct vfs_dirinfo, 1);
|
||||
dirinfo->info = info;
|
||||
|
||||
encoding = vfs_get_encoding (canon);
|
||||
g_free (canon);
|
||||
dirinfo->converter = (encoding != NULL) ? str_crt_conv_from (encoding) : str_cnv_from_term;
|
||||
if (dirinfo->converter == INVALID_CONV)
|
||||
dirinfo->converter = str_cnv_from_term;
|
||||
|
||||
handle = vfs_new_handle (vfs, dirinfo);
|
||||
|
||||
handlep = g_new (int, 1);
|
||||
*handlep = handle;
|
||||
return (DIR *) handlep;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (canon);
|
||||
errno = path_element->class->opendir ? vfs_ferrno (path_element->class) : E_NOTSUPP;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dirinfo = g_new (struct vfs_dirinfo, 1);
|
||||
dirinfo->info = info;
|
||||
|
||||
dirinfo->converter =
|
||||
(vpath->unparsed_encoding !=
|
||||
NULL) ? str_crt_conv_from (vpath->unparsed_encoding) : str_cnv_from_term;
|
||||
if (dirinfo->converter == INVALID_CONV)
|
||||
dirinfo->converter = str_cnv_from_term;
|
||||
|
||||
handle = vfs_new_handle (path_element->class, dirinfo);
|
||||
|
||||
handlep = g_new (int, 1);
|
||||
*handlep = handle;
|
||||
return (DIR *) handlep;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -587,9 +578,7 @@ mc_stat (const char *filename, struct stat *buf)
|
||||
|
||||
if (path_element != NULL && path_element->class != NULL)
|
||||
{
|
||||
result =
|
||||
path_element->class->stat ? (*path_element->class->stat) (path_element->class,
|
||||
vpath->unparsed, buf) : -1;
|
||||
result = path_element->class->stat ? (*path_element->class->stat) (vpath, buf) : -1;
|
||||
if (result == -1)
|
||||
errno = path_element->class->name ? vfs_ferrno (path_element->class) : E_NOTSUPP;
|
||||
}
|
||||
@ -615,9 +604,7 @@ mc_lstat (const char *filename, struct stat *buf)
|
||||
|
||||
if (path_element != NULL && path_element->class != NULL)
|
||||
{
|
||||
result =
|
||||
path_element->class->lstat ? (*path_element->class->lstat) (path_element->class,
|
||||
vpath->unparsed, buf) : -1;
|
||||
result = path_element->class->lstat ? (*path_element->class->lstat) (vpath, buf) : -1;
|
||||
if (result == -1)
|
||||
errno = path_element->class->name ? vfs_ferrno (path_element->class) : E_NOTSUPP;
|
||||
}
|
||||
@ -721,62 +708,52 @@ mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed)
|
||||
int
|
||||
mc_chdir (const char *path)
|
||||
{
|
||||
char *new_dir;
|
||||
char *trans_dir;
|
||||
struct vfs_class *old_vfs, *new_vfs;
|
||||
// char *new_dir;
|
||||
// char *trans_dir;
|
||||
struct vfs_class *old_vfs;
|
||||
vfsid old_vfsid;
|
||||
int result;
|
||||
vfs_path_t *vpath;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
new_dir = vfs_canon (path);
|
||||
trans_dir = vfs_translate_path_n (new_dir);
|
||||
if (trans_dir != NULL)
|
||||
vpath = vfs_path_from_str (path);
|
||||
|
||||
if (vpath == NULL)
|
||||
return -1;
|
||||
|
||||
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
|
||||
|
||||
if (!path_element->class->chdir)
|
||||
return -1;
|
||||
|
||||
result = (*path_element->class->chdir) (vpath);
|
||||
|
||||
if (result == -1)
|
||||
{
|
||||
new_vfs = vfs_get_class (trans_dir);
|
||||
if (!new_vfs->chdir)
|
||||
{
|
||||
g_free (new_dir);
|
||||
g_free (trans_dir);
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = (*new_vfs->chdir) (new_vfs, trans_dir);
|
||||
|
||||
if (result == -1)
|
||||
{
|
||||
errno = vfs_ferrno (new_vfs);
|
||||
g_free (new_dir);
|
||||
g_free (trans_dir);
|
||||
return -1;
|
||||
}
|
||||
|
||||
old_vfsid = vfs_getid (current_vfs, current_dir);
|
||||
old_vfs = current_vfs;
|
||||
|
||||
/* Actually change directory */
|
||||
g_free (current_dir);
|
||||
current_dir = new_dir;
|
||||
current_vfs = new_vfs;
|
||||
|
||||
/* This function uses the new current_dir implicitly */
|
||||
vfs_stamp_create (old_vfs, old_vfsid);
|
||||
|
||||
/* Sometimes we assume no trailing slash on cwd */
|
||||
if (*current_dir)
|
||||
{
|
||||
char *p;
|
||||
p = strchr (current_dir, 0) - 1;
|
||||
if (*p == PATH_SEP && p > current_dir)
|
||||
*p = 0;
|
||||
}
|
||||
|
||||
g_free (trans_dir);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (new_dir);
|
||||
errno = vfs_ferrno (path_element->class);
|
||||
return -1;
|
||||
}
|
||||
|
||||
old_vfsid = vfs_getid (current_vfs, current_dir);
|
||||
old_vfs = current_vfs;
|
||||
|
||||
/* Actually change directory */
|
||||
g_free (current_dir);
|
||||
current_dir = vpath->unparsed;
|
||||
current_vfs = path_element->class;
|
||||
|
||||
/* This function uses the new current_dir implicitly */
|
||||
vfs_stamp_create (old_vfs, old_vfsid);
|
||||
|
||||
/* Sometimes we assume no trailing slash on cwd */
|
||||
if (*current_dir)
|
||||
{
|
||||
char *p;
|
||||
p = strchr (current_dir, 0) - 1;
|
||||
if (*p == PATH_SEP && p > current_dir)
|
||||
*p = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -77,24 +77,26 @@ vfs_path_to_str (const vfs_path_t * path)
|
||||
vfs_path_t *
|
||||
vfs_path_from_str (const char *path_str)
|
||||
{
|
||||
char *file;
|
||||
vfs_path_t *path;
|
||||
vfs_path_element_t *element;
|
||||
|
||||
if (path_str == NULL)
|
||||
return NULL;
|
||||
|
||||
file = vfs_canon_and_translate (path_str);
|
||||
if (file == NULL)
|
||||
return NULL;
|
||||
|
||||
path = vfs_path_new ();
|
||||
path->unparsed_encoding = g_strdup (vfs_get_encoding (path_str));
|
||||
|
||||
path->unparsed = vfs_canon_and_translate (path_str);
|
||||
if (path->unparsed == NULL)
|
||||
{
|
||||
vfs_path_free (path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
element = g_new0 (vfs_path_element_t, 1);
|
||||
element->class = vfs_get_class (file);
|
||||
element->class = vfs_get_class (path->unparsed);
|
||||
|
||||
g_ptr_array_add (path->path, element);
|
||||
path->unparsed = file;
|
||||
return path;
|
||||
}
|
||||
|
||||
@ -149,6 +151,7 @@ vfs_path_free (vfs_path_t * path)
|
||||
g_ptr_array_foreach (path->path, (GFunc) vfs_path_element_free, NULL);
|
||||
g_ptr_array_free (path->path, TRUE);
|
||||
g_free (path->unparsed);
|
||||
g_free (path->unparsed_encoding);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
|
@ -11,12 +11,15 @@
|
||||
|
||||
struct vfs_class;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
GPtrArray *path;
|
||||
char *unparsed;
|
||||
char *unparsed_encoding;
|
||||
} vfs_path_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
char *path;
|
||||
struct vfs_class *class;
|
||||
char *encoding;
|
||||
@ -29,15 +32,15 @@ typedef struct {
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
vfs_path_t *vfs_path_new(void);
|
||||
vfs_path_t *vfs_path_new (void);
|
||||
void vfs_path_free (vfs_path_t * path);
|
||||
size_t vfs_path_length (const vfs_path_t *path);
|
||||
size_t vfs_path_length (const vfs_path_t * path);
|
||||
|
||||
char *vfs_path_to_str (const vfs_path_t * path);
|
||||
vfs_path_t * vfs_path_from_str (const char * path_str);
|
||||
vfs_path_t *vfs_path_from_str (const char *path_str);
|
||||
|
||||
vfs_path_element_t *vfs_path_get_by_index (const vfs_path_t *path, size_t element_index);
|
||||
void vfs_path_element_free(vfs_path_element_t *element);
|
||||
vfs_path_element_t *vfs_path_get_by_index (const vfs_path_t * path, size_t element_index);
|
||||
void vfs_path_element_free (vfs_path_element_t * element);
|
||||
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
@ -156,12 +156,12 @@ typedef struct vfs_class
|
||||
ssize_t (*read) (void *vfs_info, char *buffer, size_t count);
|
||||
ssize_t (*write) (void *vfs_info, const char *buf, size_t count);
|
||||
|
||||
void *(*opendir) (struct vfs_class * me, const char *dirname);
|
||||
void *(*opendir) (const vfs_path_t * vpath);
|
||||
void *(*readdir) (void *vfs_info);
|
||||
int (*closedir) (void *vfs_info);
|
||||
|
||||
int (*stat) (struct vfs_class * me, const char *path, struct stat * buf);
|
||||
int (*lstat) (struct vfs_class * me, const char *path, struct stat * buf);
|
||||
int (*stat) (const vfs_path_t * vpath, struct stat * buf);
|
||||
int (*lstat) (const vfs_path_t * vpath, struct stat * buf);
|
||||
int (*fstat) (void *vfs_info, struct stat * buf);
|
||||
|
||||
int (*chmod) (const vfs_path_t * vpath, int mode);
|
||||
@ -173,7 +173,7 @@ typedef struct vfs_class
|
||||
int (*link) (struct vfs_class * me, const char *p1, const char *p2);
|
||||
int (*unlink) (struct vfs_class * me, const char *path);
|
||||
int (*rename) (struct vfs_class * me, const char *p1, const char *p2);
|
||||
int (*chdir) (struct vfs_class * me, const char *path);
|
||||
int (*chdir) (const vfs_path_t * vpath);
|
||||
int (*ferrno) (struct vfs_class * me);
|
||||
off_t (*lseek) (void *vfs_info, off_t offset, int whence);
|
||||
int (*mknod) (struct vfs_class * me, const char *path, mode_t mode, dev_t dev);
|
||||
|
@ -991,14 +991,15 @@ extfs_errno (struct vfs_class *me)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void *
|
||||
extfs_opendir (struct vfs_class *me, const char *dirname)
|
||||
extfs_opendir (const vfs_path_t * vpath)
|
||||
{
|
||||
struct archive *archive = NULL;
|
||||
char *q;
|
||||
struct entry *entry;
|
||||
struct entry **info;
|
||||
vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
|
||||
|
||||
q = extfs_get_path (me, dirname, &archive, FALSE);
|
||||
q = extfs_get_path (path_element->class, vpath->unparsed, &archive, FALSE);
|
||||
if (q == NULL)
|
||||
return NULL;
|
||||
entry = extfs_find_entry (archive->root_entry, q, FALSE, FALSE);
|
||||
@ -1075,16 +1076,18 @@ extfs_stat_move (struct stat *buf, const struct inode *inode)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
extfs_internal_stat (struct vfs_class *me, const char *path, struct stat *buf, gboolean resolve)
|
||||
extfs_internal_stat (const vfs_path_t * vpath, struct stat *buf, gboolean resolve)
|
||||
{
|
||||
struct archive *archive;
|
||||
char *q, *mpath;
|
||||
struct entry *entry;
|
||||
int result = -1;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
mpath = g_strdup (path);
|
||||
mpath = g_strdup (vpath->unparsed);
|
||||
|
||||
q = extfs_get_path_mangle (me, mpath, &archive, FALSE);
|
||||
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
|
||||
q = extfs_get_path_mangle (path_element->class, mpath, &archive, FALSE);
|
||||
if (q == NULL)
|
||||
goto cleanup;
|
||||
entry = extfs_find_entry (archive->root_entry, q, FALSE, FALSE);
|
||||
@ -1106,17 +1109,17 @@ extfs_internal_stat (struct vfs_class *me, const char *path, struct stat *buf, g
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
extfs_stat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||
extfs_stat (const vfs_path_t * vpath, struct stat *buf)
|
||||
{
|
||||
return extfs_internal_stat (me, path, buf, TRUE);
|
||||
return extfs_internal_stat (vpath, buf, TRUE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
extfs_lstat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||
extfs_lstat (const vfs_path_t * vpath, struct stat *buf)
|
||||
{
|
||||
return extfs_internal_stat (me, path, buf, FALSE);
|
||||
return extfs_internal_stat (vpath, buf, FALSE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1324,14 +1327,15 @@ extfs_rmdir (struct vfs_class *me, const char *path)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
extfs_chdir (struct vfs_class *me, const char *path)
|
||||
extfs_chdir (const vfs_path_t * vpath)
|
||||
{
|
||||
struct archive *archive = NULL;
|
||||
char *q;
|
||||
struct entry *entry;
|
||||
vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
|
||||
|
||||
my_errno = ENOTDIR;
|
||||
q = extfs_get_path (me, path, &archive, FALSE);
|
||||
q = extfs_get_path (path_element->class, vpath->unparsed, &archive, FALSE);
|
||||
if (q == NULL)
|
||||
return -1;
|
||||
entry = extfs_find_entry (archive->root_entry, q, FALSE, FALSE);
|
||||
|
@ -77,14 +77,12 @@ local_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void *
|
||||
local_opendir (struct vfs_class *me, const char *dirname)
|
||||
local_opendir (const vfs_path_t * vpath)
|
||||
{
|
||||
DIR **local_info;
|
||||
DIR *dir;
|
||||
|
||||
(void) me;
|
||||
|
||||
dir = opendir (dirname);
|
||||
dir = opendir (vpath->unparsed);
|
||||
if (!dir)
|
||||
return 0;
|
||||
|
||||
@ -117,24 +115,20 @@ local_closedir (void *data)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
local_stat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||
local_stat (const vfs_path_t * vpath, struct stat *buf)
|
||||
{
|
||||
(void) me;
|
||||
|
||||
return stat (path, buf);
|
||||
return stat (vpath->unparsed, buf);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
local_lstat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||
local_lstat (const vfs_path_t * vpath, struct stat *buf)
|
||||
{
|
||||
(void) me;
|
||||
|
||||
#ifndef HAVE_STATLSTAT
|
||||
return lstat (path, buf);
|
||||
return lstat (vpath->unparsed, buf);
|
||||
#else
|
||||
return statlstat (path, buf);
|
||||
return statlstat (vpath->unparsed, buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -232,11 +226,9 @@ local_rename (struct vfs_class *me, const char *a, const char *b)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
local_chdir (struct vfs_class *me, const char *path)
|
||||
local_chdir (const vfs_path_t * vpath)
|
||||
{
|
||||
(void) me;
|
||||
|
||||
return chdir (path);
|
||||
return chdir (vpath->unparsed);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -272,18 +272,26 @@ sfs_open (const vfs_path_t * vpath /*struct vfs_class *me, const char *path */ ,
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
sfs_stat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||
sfs_stat (const vfs_path_t * vpath, struct stat *buf)
|
||||
{
|
||||
path = sfs_redirect (me, path);
|
||||
vfs_path_element_t *path_element;
|
||||
const char *path;
|
||||
|
||||
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
|
||||
path = sfs_redirect (path_element->class, vpath->unparsed);
|
||||
return stat (path, buf);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
sfs_lstat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||
sfs_lstat (const vfs_path_t * vpath, struct stat *buf)
|
||||
{
|
||||
path = sfs_redirect (me, path);
|
||||
vfs_path_element_t *path_element;
|
||||
const char *path;
|
||||
|
||||
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
|
||||
path = sfs_redirect (path_element->class, vpath->unparsed);
|
||||
#ifndef HAVE_STATLSTAT
|
||||
return lstat (path, buf);
|
||||
#else
|
||||
|
@ -1374,23 +1374,21 @@ is_error (int result, int errno_num)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void *
|
||||
smbfs_opendir (struct vfs_class *me, const char *dirname)
|
||||
smbfs_opendir (const vfs_path_t * vpath)
|
||||
{
|
||||
opendir_info *smbfs_info;
|
||||
smbfs_connection *sc;
|
||||
char *remote_dir;
|
||||
|
||||
(void) me;
|
||||
DEBUG (3, ("smbfs_opendir(dirname:%s)\n", vpath->unparsed));
|
||||
|
||||
DEBUG (3, ("smbfs_opendir(dirname:%s)\n", dirname));
|
||||
|
||||
if (!(remote_dir = smbfs_get_path (&sc, dirname)))
|
||||
if (!(remote_dir = smbfs_get_path (&sc, vpath->unparsed)))
|
||||
return NULL;
|
||||
|
||||
/* FIXME: where freed? */
|
||||
smbfs_info = g_new (opendir_info, 1);
|
||||
smbfs_info->server_list = FALSE;
|
||||
smbfs_info->path = g_strdup (dirname); /* keep original */
|
||||
smbfs_info->path = g_strdup (vpath->unparsed); /* keep original */
|
||||
smbfs_info->dirname = remote_dir;
|
||||
smbfs_info->conn = sc;
|
||||
smbfs_info->entries = 0;
|
||||
@ -1649,15 +1647,13 @@ smbfs_get_stat_info (smbfs_connection * sc, const char *path, struct stat *buf)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
smbfs_chdir (struct vfs_class *me, const char *path)
|
||||
smbfs_chdir (const vfs_path_t * vpath)
|
||||
{
|
||||
char *remote_dir;
|
||||
smbfs_connection *sc;
|
||||
|
||||
(void) me;
|
||||
|
||||
DEBUG (3, ("smbfs_chdir(path:%s)\n", path));
|
||||
if (!(remote_dir = smbfs_get_path (&sc, path)))
|
||||
DEBUG (3, ("smbfs_chdir(path:%s)\n", vpath->unparsed));
|
||||
if (!(remote_dir = smbfs_get_path (&sc, vpath->unparsed)))
|
||||
return -1;
|
||||
g_free (remote_dir);
|
||||
|
||||
@ -1667,19 +1663,19 @@ smbfs_chdir (struct vfs_class *me, const char *path)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
smbfs_loaddir_by_name (struct vfs_class *me, const char *path)
|
||||
smbfs_loaddir_by_name (const vfs_path_t * vpath)
|
||||
{
|
||||
void *info;
|
||||
char *mypath, *p;
|
||||
|
||||
mypath = g_strdup (path);
|
||||
mypath = g_strdup (vpath->unparsed);
|
||||
p = strrchr (mypath, '/');
|
||||
|
||||
if (p > mypath)
|
||||
*p = 0;
|
||||
DEBUG (6, ("smbfs_loaddir_by_name(%s)\n", mypath));
|
||||
smbfs_chdir (me, mypath);
|
||||
info = smbfs_opendir (me, mypath);
|
||||
smbfs_chdir (vpath);
|
||||
info = smbfs_opendir (vpath);
|
||||
g_free (mypath);
|
||||
if (!info)
|
||||
return -1;
|
||||
@ -1691,24 +1687,24 @@ smbfs_loaddir_by_name (struct vfs_class *me, const char *path)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
smbfs_stat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||
smbfs_stat (const vfs_path_t * vpath, struct stat *buf)
|
||||
{
|
||||
smbfs_connection *sc;
|
||||
pstring server_url;
|
||||
char *service, *pp, *at;
|
||||
const char *p;
|
||||
|
||||
DEBUG (3, ("smbfs_stat(path:%s)\n", path));
|
||||
DEBUG (3, ("smbfs_stat(path:%s)\n", vpath->unparsed));
|
||||
|
||||
if (!current_info)
|
||||
{
|
||||
DEBUG (1, ("current_info = NULL: "));
|
||||
if (smbfs_loaddir_by_name (me, path) < 0)
|
||||
if (smbfs_loaddir_by_name (vpath) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* check if stating server */
|
||||
p = path;
|
||||
p = vpath->unparsed;
|
||||
if (strncmp (p, URL_HEADER, HEADER_LEN))
|
||||
{
|
||||
DEBUG (1, ("'%s' doesnt start with '%s' (length %d)\n", p, URL_HEADER, HEADER_LEN));
|
||||
@ -1741,19 +1737,19 @@ smbfs_stat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||
{
|
||||
if (!current_info->server_list)
|
||||
{
|
||||
if (smbfs_loaddir_by_name (me, path) < 0)
|
||||
if (smbfs_loaddir_by_name (vpath) < 0)
|
||||
return -1;
|
||||
}
|
||||
return smbfs_fake_server_stat (server_url, path, buf);
|
||||
return smbfs_fake_server_stat (server_url, vpath->unparsed, buf);
|
||||
}
|
||||
|
||||
if (!strchr (++pp, '/'))
|
||||
{
|
||||
return smbfs_fake_share_stat (server_url, path, buf);
|
||||
return smbfs_fake_share_stat (server_url, vpath->unparsed, buf);
|
||||
}
|
||||
|
||||
/* stating inside share at this point */
|
||||
if (!(service = smbfs_get_path (&sc, path))) /* connects if necessary */
|
||||
if (!(service = smbfs_get_path (&sc, vpath->unparsed))) /* connects if necessary */
|
||||
return -1;
|
||||
{
|
||||
int hostlen = strlen (current_bucket->host);
|
||||
@ -1788,7 +1784,7 @@ smbfs_stat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||
if (strncmp (p, pp, strlen (p)) != 0)
|
||||
{
|
||||
DEBUG (6, ("desired '%s' is not loaded, we have '%s'\n", p, pp));
|
||||
if (smbfs_loaddir_by_name (me, path) < 0)
|
||||
if (smbfs_loaddir_by_name (vpath) < 0)
|
||||
{
|
||||
g_free (service);
|
||||
return -1;
|
||||
@ -1797,7 +1793,7 @@ smbfs_stat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||
}
|
||||
g_free (service);
|
||||
/* stat dirs & files under shares now */
|
||||
return smbfs_get_stat_info (sc, path, buf);
|
||||
return smbfs_get_stat_info (sc, vpath->unparsed, buf);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -330,11 +330,13 @@ undelfs_loaddel (void)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void *
|
||||
undelfs_opendir (struct vfs_class *me, const char *dirname)
|
||||
undelfs_opendir (const vfs_path_t * vpath)
|
||||
{
|
||||
char *file, *f;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
undelfs_get_path (dirname, &file, &f);
|
||||
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
|
||||
undelfs_get_path (vpath->unparsed, &file, &f);
|
||||
if (!file)
|
||||
return 0;
|
||||
|
||||
@ -374,10 +376,10 @@ undelfs_opendir (struct vfs_class *me, const char *dirname)
|
||||
/* Now load the deleted information */
|
||||
if (!undelfs_loaddel ())
|
||||
goto quit_opendir;
|
||||
vfs_print_message (_("%s: done."), me->name);
|
||||
vfs_print_message (_("%s: done."), path_element->class->name);
|
||||
return fs;
|
||||
quit_opendir:
|
||||
vfs_print_message (_("%s: failure"), me->name);
|
||||
vfs_print_message (_("%s: failure"), path_element->class->name);
|
||||
ext2fs_close (fs);
|
||||
fs = NULL;
|
||||
return 0;
|
||||
@ -630,13 +632,12 @@ undelfs_stat_int (int inode_index, struct stat *buf)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
undelfs_lstat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||
undelfs_lstat (const vfs_path_t * vpath, struct stat *buf)
|
||||
{
|
||||
int inode_index;
|
||||
char *file, *f;
|
||||
(void) me;
|
||||
|
||||
undelfs_get_path (path, &file, &f);
|
||||
undelfs_get_path (vpath->unparsed, &file, &f);
|
||||
if (!file)
|
||||
return 0;
|
||||
|
||||
@ -683,13 +684,12 @@ undelfs_fstat (void *vfs_info, struct stat *buf)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
undelfs_chdir (struct vfs_class *me, const char *path)
|
||||
undelfs_chdir (const vfs_path_t * vpath)
|
||||
{
|
||||
char *file, *f;
|
||||
int fd;
|
||||
(void) me;
|
||||
|
||||
undelfs_get_path (path, &file, &f);
|
||||
undelfs_get_path (vpath->unparsed, &file, &f);
|
||||
if (!file)
|
||||
return -1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user