mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Use vfs_path_get_last_path_vfs() where it is resonable.
This commit is contained in:
parent
e20d9acecb
commit
978ce6d0dd
@ -396,22 +396,22 @@ vfs_s_inode_from_path (const vfs_path_t * vpath, int flags)
|
|||||||
struct vfs_s_super *super;
|
struct vfs_s_super *super;
|
||||||
struct vfs_s_inode *ino;
|
struct vfs_s_inode *ino;
|
||||||
const char *q;
|
const char *q;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
|
|
||||||
q = vfs_s_get_path (vpath, &super, 0);
|
q = vfs_s_get_path (vpath, &super, 0);
|
||||||
if (q == NULL)
|
if (q == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
ino =
|
ino =
|
||||||
vfs_s_find_inode (path_element->class, super, q,
|
vfs_s_find_inode (me, super, q,
|
||||||
(flags & FL_FOLLOW) != 0 ? LINK_FOLLOW : LINK_NO_FOLLOW,
|
(flags & FL_FOLLOW) != 0 ? LINK_FOLLOW : LINK_NO_FOLLOW,
|
||||||
flags & ~FL_FOLLOW);
|
flags & ~FL_FOLLOW);
|
||||||
if (ino == NULL && *q == '\0')
|
if (ino == NULL && *q == '\0')
|
||||||
/* We are asking about / directory of ftp server: assume it exists */
|
/* We are asking about / directory of ftp server: assume it exists */
|
||||||
ino =
|
ino =
|
||||||
vfs_s_find_inode (path_element->class, super, q,
|
vfs_s_find_inode (me, super, q,
|
||||||
(flags & FL_FOLLOW) != 0 ? LINK_FOLLOW : LINK_NO_FOLLOW,
|
(flags & FL_FOLLOW) != 0 ? LINK_FOLLOW : LINK_NO_FOLLOW,
|
||||||
FL_DIR | (flags & ~FL_FOLLOW));
|
FL_DIR | (flags & ~FL_FOLLOW));
|
||||||
return ino;
|
return ino;
|
||||||
@ -424,17 +424,17 @@ vfs_s_opendir (const vfs_path_t * vpath)
|
|||||||
{
|
{
|
||||||
struct vfs_s_inode *dir;
|
struct vfs_s_inode *dir;
|
||||||
struct dirhandle *info;
|
struct dirhandle *info;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
|
|
||||||
dir = vfs_s_inode_from_path (vpath, FL_DIR | FL_FOLLOW);
|
dir = vfs_s_inode_from_path (vpath, FL_DIR | FL_FOLLOW);
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
if (!S_ISDIR (dir->st.st_mode))
|
if (!S_ISDIR (dir->st.st_mode))
|
||||||
{
|
{
|
||||||
path_element->class->verrno = ENOTDIR;
|
me->verrno = ENOTDIR;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,7 +442,7 @@ vfs_s_opendir (const vfs_path_t * vpath)
|
|||||||
#if 0
|
#if 0
|
||||||
if (dir->subdir == NULL) /* This can actually happen if we allow empty directories */
|
if (dir->subdir == NULL) /* This can actually happen if we allow empty directories */
|
||||||
{
|
{
|
||||||
path_element->class->verrno = EAGAIN;
|
me->verrno = EAGAIN;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -525,23 +525,23 @@ vfs_s_readlink (const vfs_path_t * vpath, char *buf, size_t size)
|
|||||||
{
|
{
|
||||||
struct vfs_s_inode *ino;
|
struct vfs_s_inode *ino;
|
||||||
size_t len;
|
size_t len;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
|
|
||||||
ino = vfs_s_inode_from_path (vpath, 0);
|
ino = vfs_s_inode_from_path (vpath, 0);
|
||||||
if (ino == NULL)
|
if (ino == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
if (!S_ISLNK (ino->st.st_mode))
|
if (!S_ISLNK (ino->st.st_mode))
|
||||||
{
|
{
|
||||||
path_element->class->verrno = EINVAL;
|
me->verrno = EINVAL;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ino->linkname == NULL)
|
if (ino->linkname == NULL)
|
||||||
{
|
{
|
||||||
path_element->class->verrno = EFAULT;
|
me->verrno = EFAULT;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,7 +765,7 @@ vfs_s_getlocalcopy (const vfs_path_t * vpath)
|
|||||||
{
|
{
|
||||||
const struct vfs_class *me;
|
const struct vfs_class *me;
|
||||||
|
|
||||||
me = vfs_path_get_by_index (vpath, -1)->class;
|
me = vfs_path_get_last_path_vfs (vpath);
|
||||||
if ((me->flags & VFSF_USETMP) != 0 && fh->ino != NULL)
|
if ((me->flags & VFSF_USETMP) != 0 && fh->ino != NULL)
|
||||||
local = vfs_path_from_str_flags (fh->ino->localname, VPF_NO_CANON);
|
local = vfs_path_from_str_flags (fh->ino->localname, VPF_NO_CANON);
|
||||||
|
|
||||||
@ -795,9 +795,9 @@ vfs_s_ungetlocalcopy (const vfs_path_t * vpath, const vfs_path_t * local, gboole
|
|||||||
static int
|
static int
|
||||||
vfs_s_setctl (const vfs_path_t * vpath, int ctlop, void *arg)
|
vfs_s_setctl (const vfs_path_t * vpath, int ctlop, void *arg)
|
||||||
{
|
{
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
switch (ctlop)
|
switch (ctlop)
|
||||||
{
|
{
|
||||||
@ -813,15 +813,15 @@ vfs_s_setctl (const vfs_path_t * vpath, int ctlop, void *arg)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ino->super->want_stale = FALSE;
|
ino->super->want_stale = FALSE;
|
||||||
vfs_s_invalidate (path_element->class, ino->super);
|
vfs_s_invalidate (me, ino->super);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
case VFS_SETCTL_LOGFILE:
|
case VFS_SETCTL_LOGFILE:
|
||||||
path_element->class->logfile = fopen ((char *) arg, "w");
|
me->logfile = fopen ((char *) arg, "w");
|
||||||
return 1;
|
return 1;
|
||||||
case VFS_SETCTL_FLUSH:
|
case VFS_SETCTL_FLUSH:
|
||||||
path_element->class->flush = TRUE;
|
me->flush = TRUE;
|
||||||
return 1;
|
return 1;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
@ -1300,23 +1300,23 @@ vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
|||||||
struct vfs_s_super *super;
|
struct vfs_s_super *super;
|
||||||
const char *q;
|
const char *q;
|
||||||
struct vfs_s_inode *ino;
|
struct vfs_s_inode *ino;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
struct vfs_s_subclass *s;
|
struct vfs_s_subclass *s;
|
||||||
|
|
||||||
q = vfs_s_get_path (vpath, &super, 0);
|
q = vfs_s_get_path (vpath, &super, 0);
|
||||||
if (q == NULL)
|
if (q == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
ino = vfs_s_find_inode (path_element->class, super, q, LINK_FOLLOW, FL_NONE);
|
ino = vfs_s_find_inode (me, super, q, LINK_FOLLOW, FL_NONE);
|
||||||
if (ino != NULL && (flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
|
if (ino != NULL && (flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
|
||||||
{
|
{
|
||||||
path_element->class->verrno = EEXIST;
|
me->verrno = EEXIST;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = VFS_SUBCLASS (path_element->class);
|
s = VFS_SUBCLASS (me);
|
||||||
|
|
||||||
if (ino == NULL)
|
if (ino == NULL)
|
||||||
{
|
{
|
||||||
@ -1325,25 +1325,25 @@ vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
|||||||
struct vfs_s_inode *dir;
|
struct vfs_s_inode *dir;
|
||||||
|
|
||||||
/* If the filesystem is read-only, disable file creation */
|
/* If the filesystem is read-only, disable file creation */
|
||||||
if ((flags & O_CREAT) == 0 || path_element->class->write == NULL)
|
if ((flags & O_CREAT) == 0 || me->write == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
name = g_path_get_dirname (q);
|
name = g_path_get_dirname (q);
|
||||||
dir = vfs_s_find_inode (path_element->class, super, name, LINK_FOLLOW, FL_DIR);
|
dir = vfs_s_find_inode (me, super, name, LINK_FOLLOW, FL_DIR);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
name = g_path_get_basename (q);
|
name = g_path_get_basename (q);
|
||||||
ent = vfs_s_generate_entry (path_element->class, name, dir, 0755);
|
ent = vfs_s_generate_entry (me, name, dir, 0755);
|
||||||
ino = ent->ino;
|
ino = ent->ino;
|
||||||
vfs_s_insert_entry (path_element->class, dir, ent);
|
vfs_s_insert_entry (me, dir, ent);
|
||||||
if ((VFS_CLASS (s)->flags & VFSF_USETMP) != 0)
|
if ((VFS_CLASS (s)->flags & VFSF_USETMP) != 0)
|
||||||
{
|
{
|
||||||
int tmp_handle;
|
int tmp_handle;
|
||||||
vfs_path_t *tmp_vpath;
|
vfs_path_t *tmp_vpath;
|
||||||
|
|
||||||
tmp_handle = vfs_mkstemps (&tmp_vpath, path_element->class->name, name);
|
tmp_handle = vfs_mkstemps (&tmp_vpath, me->name, name);
|
||||||
ino->localname = vfs_path_free (tmp_vpath, FALSE);
|
ino->localname = vfs_path_free (tmp_vpath, FALSE);
|
||||||
if (tmp_handle == -1)
|
if (tmp_handle == -1)
|
||||||
{
|
{
|
||||||
@ -1360,7 +1360,7 @@ vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
|||||||
|
|
||||||
if (S_ISDIR (ino->st.st_mode))
|
if (S_ISDIR (ino->st.st_mode))
|
||||||
{
|
{
|
||||||
path_element->class->verrno = EISDIR;
|
me->verrno = EISDIR;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1376,7 +1376,7 @@ vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (s->fh_open != NULL && s->fh_open (path_element->class, fh, flags, mode) != 0)
|
if (s->fh_open != NULL && s->fh_open (me, fh, flags, mode) != 0)
|
||||||
{
|
{
|
||||||
vfs_s_free_fh (s, fh);
|
vfs_s_free_fh (s, fh);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1389,13 +1389,13 @@ vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
|||||||
if (fh->handle == -1)
|
if (fh->handle == -1)
|
||||||
{
|
{
|
||||||
vfs_s_free_fh (s, fh);
|
vfs_s_free_fh (s, fh);
|
||||||
path_element->class->verrno = errno;
|
me->verrno = errno;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* i.e. we had no open files and now we have one */
|
/* i.e. we had no open files and now we have one */
|
||||||
vfs_rmstamp (path_element->class, (vfsid) super);
|
vfs_rmstamp (me, (vfsid) super);
|
||||||
super->fd_usage++;
|
super->fd_usage++;
|
||||||
fh->ino->st.st_nlink++;
|
fh->ino->st.st_nlink++;
|
||||||
return fh;
|
return fh;
|
||||||
@ -1573,13 +1573,13 @@ vfs_init_subclass (struct vfs_s_subclass *sub, const char *name, vfs_flags_t fla
|
|||||||
vfsid
|
vfsid
|
||||||
vfs_getid (const vfs_path_t * vpath)
|
vfs_getid (const vfs_path_t * vpath)
|
||||||
{
|
{
|
||||||
const vfs_path_element_t *path_element;
|
const struct vfs_class *me;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
me = vfs_path_get_last_path_vfs (vpath);
|
||||||
if (!vfs_path_element_valid (path_element) || path_element->class->getid == NULL)
|
if (me == NULL || me->getid == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return (*path_element->class->getid) (vpath);
|
return me->getid (vpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
23
lib/vfs/gc.c
23
lib/vfs/gc.c
@ -186,12 +186,11 @@ void
|
|||||||
vfs_stamp_path (const vfs_path_t * vpath)
|
vfs_stamp_path (const vfs_path_t * vpath)
|
||||||
{
|
{
|
||||||
vfsid id;
|
vfsid id;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
|
||||||
|
|
||||||
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
id = vfs_getid (vpath);
|
id = vfs_getid (vpath);
|
||||||
vfs_addstamp (path_element->class, id);
|
vfs_addstamp (me, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -206,7 +205,7 @@ vfs_stamp_create (struct vfs_class *vclass, vfsid id)
|
|||||||
|
|
||||||
ev_vfs_stamp_create_t event_data = { vclass, id, FALSE };
|
ev_vfs_stamp_create_t event_data = { vclass, id, FALSE };
|
||||||
const vfs_path_t *vpath;
|
const vfs_path_t *vpath;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
|
|
||||||
/* There are three directories we have to take care of: current_dir,
|
/* There are three directories we have to take care of: current_dir,
|
||||||
current_panel->cwd and other_panel->cwd. Although most of the time either
|
current_panel->cwd and other_panel->cwd. Although most of the time either
|
||||||
@ -217,12 +216,12 @@ vfs_stamp_create (struct vfs_class *vclass, vfsid id)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
vpath = vfs_get_raw_current_dir ();
|
vpath = vfs_get_raw_current_dir ();
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
nvfsid = vfs_getid (vpath);
|
nvfsid = vfs_getid (vpath);
|
||||||
vfs_rmstamp (path_element->class, nvfsid);
|
vfs_rmstamp (me, nvfsid);
|
||||||
|
|
||||||
if (!(id == NULL || (path_element->class == vclass && nvfsid == id)))
|
if (!(id == NULL || (me == vclass && nvfsid == id)))
|
||||||
{
|
{
|
||||||
mc_event_raise (MCEVENT_GROUP_CORE, "vfs_timestamp", (gpointer) & event_data);
|
mc_event_raise (MCEVENT_GROUP_CORE, "vfs_timestamp", (gpointer) & event_data);
|
||||||
|
|
||||||
@ -316,10 +315,12 @@ vfs_timeout_handler (void)
|
|||||||
void
|
void
|
||||||
vfs_release_path (const vfs_path_t * vpath)
|
vfs_release_path (const vfs_path_t * vpath)
|
||||||
{
|
{
|
||||||
const vfs_path_element_t *path_element;
|
vfsid id;
|
||||||
|
struct vfs_class *me;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
vfs_stamp_create (path_element->class, vfs_getid (vpath));
|
id = vfs_getid (vpath);
|
||||||
|
vfs_stamp_create (me, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -192,7 +192,7 @@ mc_open (const vfs_path_t * vpath, int flags, ...)
|
|||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
mode_t mode = 0;
|
mode_t mode = 0;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
|
|
||||||
if (vpath == NULL)
|
if (vpath == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -210,17 +210,17 @@ mc_open (const vfs_path_t * vpath, int flags, ...)
|
|||||||
va_end (ap);
|
va_end (ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
if (vfs_path_element_valid (path_element) && path_element->class->open != NULL)
|
if (me != NULL && me->open != NULL)
|
||||||
{
|
{
|
||||||
void *info;
|
void *info;
|
||||||
|
|
||||||
/* open must be supported */
|
/* open must be supported */
|
||||||
info = path_element->class->open (vpath, flags, mode);
|
info = me->open (vpath, flags, mode);
|
||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
errno = vfs_ferrno (path_element->class);
|
errno = vfs_ferrno (me);
|
||||||
else
|
else
|
||||||
result = vfs_new_handle (path_element->class, info);
|
result = vfs_new_handle (me, info);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
errno = ENOTSUP;
|
errno = ENOTSUP;
|
||||||
@ -236,18 +236,18 @@ mc_open (const vfs_path_t * vpath, int flags, ...)
|
|||||||
int mc_##name inarg \
|
int mc_##name inarg \
|
||||||
{ \
|
{ \
|
||||||
int result; \
|
int result; \
|
||||||
const vfs_path_element_t *path_element; \
|
struct vfs_class *me; \
|
||||||
\
|
\
|
||||||
if (vpath == NULL) \
|
if (vpath == NULL) \
|
||||||
return (-1); \
|
return (-1); \
|
||||||
\
|
\
|
||||||
path_element = vfs_path_get_by_index (vpath, -1); \
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath)); \
|
||||||
if (!vfs_path_element_valid (path_element)) \
|
if (me == NULL) \
|
||||||
return (-1); \
|
return (-1); \
|
||||||
\
|
\
|
||||||
result = path_element->class->name != NULL ? path_element->class->name callarg : -1; \
|
result = me->name != NULL ? me->name callarg : -1; \
|
||||||
if (result == -1) \
|
if (result == -1) \
|
||||||
errno = path_element->class->name != NULL ? vfs_ferrno (path_element->class) : ENOTSUP; \
|
errno = me->name != NULL ? vfs_ferrno (me) : ENOTSUP; \
|
||||||
return result; \
|
return result; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,19 +273,14 @@ mc_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
|||||||
|
|
||||||
if (vpath1 != NULL && vpath2 != NULL)
|
if (vpath1 != NULL && vpath2 != NULL)
|
||||||
{
|
{
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath2, -1);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath2));
|
||||||
if (vfs_path_element_valid (path_element))
|
if (me != NULL)
|
||||||
{
|
{
|
||||||
result =
|
result = me->symlink != NULL ? me->symlink (vpath1, vpath2) : -1;
|
||||||
path_element->class->symlink != NULL ?
|
|
||||||
path_element->class->symlink (vpath1, vpath2) : -1;
|
|
||||||
|
|
||||||
if (result == -1)
|
if (result == -1)
|
||||||
errno =
|
errno = me->symlink != NULL ? vfs_ferrno (me) : ENOTSUP;
|
||||||
path_element->class->symlink != NULL ?
|
|
||||||
vfs_ferrno (path_element->class) : ENOTSUP;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -325,26 +320,23 @@ MC_HANDLEOP (int, fstat, (int handle, struct stat *buf), (fsinfo, buf))
|
|||||||
int mc_##name (const vfs_path_t *vpath1, const vfs_path_t *vpath2) \
|
int mc_##name (const vfs_path_t *vpath1, const vfs_path_t *vpath2) \
|
||||||
{ \
|
{ \
|
||||||
int result; \
|
int result; \
|
||||||
const vfs_path_element_t *path_element1; \
|
struct vfs_class *me1, *me2; \
|
||||||
const vfs_path_element_t *path_element2; \
|
|
||||||
\
|
\
|
||||||
if (vpath1 == NULL || vpath2 == NULL) \
|
if (vpath1 == NULL || vpath2 == NULL) \
|
||||||
return (-1); \
|
return (-1); \
|
||||||
\
|
\
|
||||||
path_element1 = vfs_path_get_by_index (vpath1, (-1)); \
|
me1 = VFS_CLASS (vfs_path_get_last_path_vfs (vpath1)); \
|
||||||
path_element2 = vfs_path_get_by_index (vpath2, (-1)); \
|
me2 = VFS_CLASS (vfs_path_get_last_path_vfs (vpath2)); \
|
||||||
\
|
\
|
||||||
if (!vfs_path_element_valid (path_element1) || !vfs_path_element_valid (path_element2) || \
|
if (me1 == NULL || me2 == NULL || me1 != me2) \
|
||||||
path_element1->class != path_element2->class) \
|
|
||||||
{ \
|
{ \
|
||||||
errno = EXDEV; \
|
errno = EXDEV; \
|
||||||
return (-1); \
|
return (-1); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
result = path_element1->class->name != NULL \
|
result = me1->name != NULL ? me1->name (vpath1, vpath2) : -1; \
|
||||||
? path_element1->class->name (vpath1, vpath2) : -1; \
|
|
||||||
if (result == -1) \
|
if (result == -1) \
|
||||||
errno = path_element1->class->name != NULL ? vfs_ferrno (path_element1->class) : ENOTSUP; \
|
errno = me1->name != NULL ? vfs_ferrno (me1) : ENOTSUP; \
|
||||||
return result; \
|
return result; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,16 +364,14 @@ int
|
|||||||
mc_setctl (const vfs_path_t * vpath, int ctlop, void *arg)
|
mc_setctl (const vfs_path_t * vpath, int ctlop, void *arg)
|
||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
|
|
||||||
if (vpath == NULL)
|
if (vpath == NULL)
|
||||||
vfs_die ("You don't want to pass NULL to mc_setctl.");
|
vfs_die ("You don't want to pass NULL to mc_setctl.");
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
if (vfs_path_element_valid (path_element))
|
if (me != NULL)
|
||||||
result =
|
result = me->setctl != NULL ? me->setctl (vpath, ctlop, arg) : 0;
|
||||||
path_element->class->setctl != NULL ? path_element->class->setctl (vpath,
|
|
||||||
ctlop, arg) : 0;
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -545,17 +535,17 @@ mc_closedir (DIR * dirp)
|
|||||||
int mc_##name (const vfs_path_t *vpath, struct stat *buf) \
|
int mc_##name (const vfs_path_t *vpath, struct stat *buf) \
|
||||||
{ \
|
{ \
|
||||||
int result = -1; \
|
int result = -1; \
|
||||||
const vfs_path_element_t *path_element; \
|
struct vfs_class *me; \
|
||||||
\
|
\
|
||||||
if (vpath == NULL) \
|
if (vpath == NULL) \
|
||||||
return (-1); \
|
return (-1); \
|
||||||
\
|
\
|
||||||
path_element = vfs_path_get_by_index (vpath, -1); \
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath)); \
|
||||||
if (vfs_path_element_valid (path_element)) \
|
if (me != NULL) \
|
||||||
{ \
|
{ \
|
||||||
result = path_element->class->name ? path_element->class->name (vpath, buf) : -1; \
|
result = me->name ? me->name (vpath, buf) : -1; \
|
||||||
if (result == -1) \
|
if (result == -1) \
|
||||||
errno = path_element->class->name ? vfs_ferrno (path_element->class) : ENOTSUP; \
|
errno = me->name ? vfs_ferrno (me) : ENOTSUP; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
return result; \
|
return result; \
|
||||||
@ -564,27 +554,24 @@ int mc_##name (const vfs_path_t *vpath, struct stat *buf) \
|
|||||||
MC_STATOP (stat)
|
MC_STATOP (stat)
|
||||||
MC_STATOP (lstat)
|
MC_STATOP (lstat)
|
||||||
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
vfs_path_t *
|
vfs_path_t *
|
||||||
mc_getlocalcopy (const vfs_path_t * pathname_vpath)
|
mc_getlocalcopy (const vfs_path_t * pathname_vpath)
|
||||||
{
|
{
|
||||||
vfs_path_t *result = NULL;
|
vfs_path_t *result = NULL;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
|
|
||||||
if (pathname_vpath == NULL)
|
if (pathname_vpath == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (pathname_vpath, -1);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (pathname_vpath));
|
||||||
if (vfs_path_element_valid (path_element))
|
if (me != NULL)
|
||||||
{
|
{
|
||||||
result = path_element->class->getlocalcopy != NULL ?
|
result = me->getlocalcopy != NULL ?
|
||||||
path_element->class->getlocalcopy (pathname_vpath) :
|
me->getlocalcopy (pathname_vpath) : mc_def_getlocalcopy (pathname_vpath);
|
||||||
mc_def_getlocalcopy (pathname_vpath);
|
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
errno = vfs_ferrno (path_element->class);
|
errno = vfs_ferrno (me);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -596,15 +583,15 @@ mc_ungetlocalcopy (const vfs_path_t * pathname_vpath, const vfs_path_t * local_v
|
|||||||
gboolean has_changed)
|
gboolean has_changed)
|
||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
const vfs_path_element_t *path_element;
|
const struct vfs_class *me;
|
||||||
|
|
||||||
if (pathname_vpath == NULL)
|
if (pathname_vpath == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (pathname_vpath, -1);
|
me = vfs_path_get_last_path_vfs (pathname_vpath);
|
||||||
if (vfs_path_element_valid (path_element))
|
if (me != NULL)
|
||||||
result = path_element->class->ungetlocalcopy != NULL ?
|
result = me->ungetlocalcopy != NULL ?
|
||||||
path_element->class->ungetlocalcopy (pathname_vpath, local_vpath, has_changed) :
|
me->ungetlocalcopy (pathname_vpath, local_vpath, has_changed) :
|
||||||
mc_def_ungetlocalcopy (pathname_vpath, local_vpath, has_changed);
|
mc_def_ungetlocalcopy (pathname_vpath, local_vpath, has_changed);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -626,6 +613,7 @@ mc_chdir (const vfs_path_t * vpath)
|
|||||||
struct vfs_class *old_vfs;
|
struct vfs_class *old_vfs;
|
||||||
vfsid old_vfsid;
|
vfsid old_vfsid;
|
||||||
int result;
|
int result;
|
||||||
|
struct vfs_class *me;
|
||||||
const vfs_path_element_t *path_element;
|
const vfs_path_element_t *path_element;
|
||||||
vfs_path_t *cd_vpath;
|
vfs_path_t *cd_vpath;
|
||||||
|
|
||||||
@ -640,23 +628,23 @@ mc_chdir (const vfs_path_t * vpath)
|
|||||||
else
|
else
|
||||||
cd_vpath = vfs_path_clone (vpath);
|
cd_vpath = vfs_path_clone (vpath);
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (cd_vpath, -1);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (cd_vpath));
|
||||||
if (!vfs_path_element_valid (path_element))
|
if (me == NULL)
|
||||||
{
|
{
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
goto error_end;
|
goto error_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path_element->class->chdir == NULL)
|
if (me->chdir == NULL)
|
||||||
{
|
{
|
||||||
errno = ENOTSUP;
|
errno = ENOTSUP;
|
||||||
goto error_end;
|
goto error_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = path_element->class->chdir (cd_vpath);
|
result = me->chdir (cd_vpath);
|
||||||
if (result == -1)
|
if (result == -1)
|
||||||
{
|
{
|
||||||
errno = vfs_ferrno (path_element->class);
|
errno = vfs_ferrno (me);
|
||||||
goto error_end;
|
goto error_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -665,8 +653,7 @@ mc_chdir (const vfs_path_t * vpath)
|
|||||||
|
|
||||||
/* Actually change directory */
|
/* Actually change directory */
|
||||||
vfs_set_raw_current_dir (cd_vpath);
|
vfs_set_raw_current_dir (cd_vpath);
|
||||||
|
current_vfs = me;
|
||||||
current_vfs = path_element->class;
|
|
||||||
|
|
||||||
/* This function uses the new current_dir implicitly */
|
/* This function uses the new current_dir implicitly */
|
||||||
vfs_stamp_create (old_vfs, old_vfsid);
|
vfs_stamp_create (old_vfs, old_vfsid);
|
||||||
|
@ -481,8 +481,6 @@ vfs_init (void)
|
|||||||
void
|
void
|
||||||
vfs_setup_work_dir (void)
|
vfs_setup_work_dir (void)
|
||||||
{
|
{
|
||||||
const vfs_path_element_t *path_element;
|
|
||||||
|
|
||||||
vfs_setup_cwd ();
|
vfs_setup_cwd ();
|
||||||
|
|
||||||
/* FIXME: is we really need for this check? */
|
/* FIXME: is we really need for this check? */
|
||||||
@ -491,8 +489,7 @@ vfs_setup_work_dir (void)
|
|||||||
vfs_die ("Current dir too long.\n");
|
vfs_die ("Current dir too long.\n");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (current_path, -1);
|
current_vfs = VFS_CLASS (vfs_path_get_last_path_vfs (current_path));
|
||||||
current_vfs = path_element->class;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -640,7 +637,7 @@ vfs_setup_cwd (void)
|
|||||||
{
|
{
|
||||||
char *current_dir;
|
char *current_dir;
|
||||||
vfs_path_t *tmp_vpath;
|
vfs_path_t *tmp_vpath;
|
||||||
const vfs_path_element_t *path_element;
|
const struct vfs_class *me;
|
||||||
|
|
||||||
if (vfs_get_raw_current_dir () == NULL)
|
if (vfs_get_raw_current_dir () == NULL)
|
||||||
{
|
{
|
||||||
@ -660,9 +657,8 @@ vfs_setup_cwd (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vfs_get_raw_current_dir (), -1);
|
me = vfs_path_get_last_path_vfs (vfs_get_raw_current_dir ());
|
||||||
|
if ((me->flags & VFSF_LOCAL) != 0)
|
||||||
if ((path_element->class->flags & VFSF_LOCAL) != 0)
|
|
||||||
{
|
{
|
||||||
current_dir = g_get_current_dir ();
|
current_dir = g_get_current_dir ();
|
||||||
tmp_vpath = vfs_path_from_str (current_dir);
|
tmp_vpath = vfs_path_from_str (current_dir);
|
||||||
|
@ -2919,7 +2919,7 @@ copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
lp = g_new0 (struct link, 1);
|
lp = g_new0 (struct link, 1);
|
||||||
lp->vfs = vfs_path_get_by_index (src_vpath, -1)->class;
|
lp->vfs = vfs_path_get_last_path_vfs (src_vpath);
|
||||||
lp->ino = src_stat.st_ino;
|
lp->ino = src_stat.st_ino;
|
||||||
lp->dev = src_stat.st_dev;
|
lp->dev = src_stat.st_dev;
|
||||||
parent_dirs = g_slist_prepend (parent_dirs, lp);
|
parent_dirs = g_slist_prepend (parent_dirs, lp);
|
||||||
@ -2995,7 +2995,7 @@ copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha
|
|||||||
|
|
||||||
lp = g_new0 (struct link, 1);
|
lp = g_new0 (struct link, 1);
|
||||||
mc_stat (dst_vpath, &dst_stat);
|
mc_stat (dst_vpath, &dst_stat);
|
||||||
lp->vfs = vfs_path_get_by_index (dst_vpath, -1)->class;
|
lp->vfs = vfs_path_get_last_path_vfs (dst_vpath);
|
||||||
lp->ino = dst_stat.st_ino;
|
lp->ino = dst_stat.st_ino;
|
||||||
lp->dev = dst_stat.st_dev;
|
lp->dev = dst_stat.st_dev;
|
||||||
dest_dirs = g_slist_prepend (dest_dirs, lp);
|
dest_dirs = g_slist_prepend (dest_dirs, lp);
|
||||||
|
@ -465,11 +465,10 @@ check_panel_timestamp (const WPanel * panel, panel_view_mode_t mode, struct vfs_
|
|||||||
{
|
{
|
||||||
if (mode == view_listing)
|
if (mode == view_listing)
|
||||||
{
|
{
|
||||||
const vfs_path_element_t *path_element;
|
const struct vfs_class *me;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (panel->cwd_vpath, -1);
|
me = vfs_path_get_last_path_vfs (panel->cwd_vpath);
|
||||||
|
if (me != vclass)
|
||||||
if (path_element->class != vclass)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (vfs_getid (panel->cwd_vpath) != id)
|
if (vfs_getid (panel->cwd_vpath) != id)
|
||||||
|
@ -1279,10 +1279,7 @@ extfs_readlink (const vfs_path_t * vpath, char *buf, size_t size)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (!S_ISLNK (entry->ino->st.st_mode))
|
if (!S_ISLNK (entry->ino->st.st_mode))
|
||||||
{
|
{
|
||||||
const vfs_path_element_t *path_element;
|
VFS_CLASS (vfs_path_get_last_path_vfs (vpath))->verrno = EINVAL;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
|
||||||
path_element->class->verrno = EINVAL;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
len = strlen (entry->ino->linkname);
|
len = strlen (entry->ino->linkname);
|
||||||
@ -1348,10 +1345,7 @@ extfs_unlink (const vfs_path_t * vpath)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (S_ISDIR (entry->ino->st.st_mode))
|
if (S_ISDIR (entry->ino->st.st_mode))
|
||||||
{
|
{
|
||||||
const vfs_path_element_t *path_element;
|
VFS_CLASS (vfs_path_get_last_path_vfs (vpath))->verrno = EISDIR;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
|
||||||
path_element->class->verrno = EISDIR;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (extfs_cmd (" rm ", archive, entry, ""))
|
if (extfs_cmd (" rm ", archive, entry, ""))
|
||||||
@ -1374,18 +1368,18 @@ extfs_mkdir (const vfs_path_t * vpath, mode_t mode)
|
|||||||
const char *q;
|
const char *q;
|
||||||
struct vfs_s_entry *entry;
|
struct vfs_s_entry *entry;
|
||||||
int result = -1;
|
int result = -1;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
|
|
||||||
(void) mode;
|
(void) mode;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
q = extfs_get_path (vpath, &archive, FL_NONE);
|
q = extfs_get_path (vpath, &archive, FL_NONE);
|
||||||
if (q == NULL)
|
if (q == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
entry = extfs_find_entry (VFS_SUPER (archive)->root, q, FL_NONE);
|
entry = extfs_find_entry (VFS_SUPER (archive)->root, q, FL_NONE);
|
||||||
if (entry != NULL)
|
if (entry != NULL)
|
||||||
{
|
{
|
||||||
path_element->class->verrno = EEXIST;
|
me->verrno = EEXIST;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
entry = extfs_find_entry (VFS_SUPER (archive)->root, q, FL_MKDIR);
|
entry = extfs_find_entry (VFS_SUPER (archive)->root, q, FL_MKDIR);
|
||||||
@ -1396,7 +1390,7 @@ extfs_mkdir (const vfs_path_t * vpath, mode_t mode)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (!S_ISDIR (entry->ino->st.st_mode))
|
if (!S_ISDIR (entry->ino->st.st_mode))
|
||||||
{
|
{
|
||||||
path_element->class->verrno = ENOTDIR;
|
me->verrno = ENOTDIR;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1432,10 +1426,7 @@ extfs_rmdir (const vfs_path_t * vpath)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (!S_ISDIR (entry->ino->st.st_mode))
|
if (!S_ISDIR (entry->ino->st.st_mode))
|
||||||
{
|
{
|
||||||
const vfs_path_element_t *path_element;
|
VFS_CLASS (vfs_path_get_last_path_vfs (vpath))->verrno = ENOTDIR;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
|
||||||
path_element->class->verrno = ENOTDIR;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1255,11 +1255,9 @@ fish_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
|||||||
const char *crpath1, *crpath2;
|
const char *crpath1, *crpath2;
|
||||||
char *rpath1, *rpath2;
|
char *rpath1, *rpath2;
|
||||||
struct vfs_s_super *super, *super2;
|
struct vfs_s_super *super, *super2;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath1, -1);
|
|
||||||
|
|
||||||
crpath1 = vfs_s_get_path (vpath1, &super, 0);
|
crpath1 = vfs_s_get_path (vpath1, &super, 0);
|
||||||
if (crpath1 == NULL)
|
if (crpath1 == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1271,8 +1269,10 @@ fish_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
|||||||
rpath1 = strutils_shell_escape (crpath1);
|
rpath1 = strutils_shell_escape (crpath1);
|
||||||
rpath2 = strutils_shell_escape (crpath2);
|
rpath2 = strutils_shell_escape (crpath2);
|
||||||
|
|
||||||
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath1));
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
fish_send_command (path_element->class, super2, OPT_FLUSH, FISH_SUPER (super)->scr_mv,
|
fish_send_command (me, super2, OPT_FLUSH, FISH_SUPER (super)->scr_mv,
|
||||||
"FISH_FILEFROM=%s FISH_FILETO=%s;\n", rpath1, rpath2);
|
"FISH_FILEFROM=%s FISH_FILETO=%s;\n", rpath1, rpath2);
|
||||||
|
|
||||||
g_free (rpath1);
|
g_free (rpath1);
|
||||||
@ -1289,11 +1289,9 @@ fish_link (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
|||||||
const char *crpath1, *crpath2;
|
const char *crpath1, *crpath2;
|
||||||
char *rpath1, *rpath2;
|
char *rpath1, *rpath2;
|
||||||
struct vfs_s_super *super, *super2;
|
struct vfs_s_super *super, *super2;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath1, -1);
|
|
||||||
|
|
||||||
crpath1 = vfs_s_get_path (vpath1, &super, 0);
|
crpath1 = vfs_s_get_path (vpath1, &super, 0);
|
||||||
if (crpath1 == NULL)
|
if (crpath1 == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1305,8 +1303,10 @@ fish_link (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
|||||||
rpath1 = strutils_shell_escape (crpath1);
|
rpath1 = strutils_shell_escape (crpath1);
|
||||||
rpath2 = strutils_shell_escape (crpath2);
|
rpath2 = strutils_shell_escape (crpath2);
|
||||||
|
|
||||||
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath1));
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
fish_send_command (path_element->class, super2, OPT_FLUSH, FISH_SUPER (super)->scr_hardlink,
|
fish_send_command (me, super2, OPT_FLUSH, FISH_SUPER (super)->scr_hardlink,
|
||||||
"FISH_FILEFROM=%s FISH_FILETO=%s;\n", rpath1, rpath2);
|
"FISH_FILEFROM=%s FISH_FILETO=%s;\n", rpath1, rpath2);
|
||||||
|
|
||||||
g_free (rpath1);
|
g_free (rpath1);
|
||||||
@ -1324,11 +1324,9 @@ fish_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
|||||||
const char *crpath;
|
const char *crpath;
|
||||||
char *rpath;
|
char *rpath;
|
||||||
struct vfs_s_super *super;
|
struct vfs_s_super *super;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath2, -1);
|
|
||||||
|
|
||||||
crpath = vfs_s_get_path (vpath2, &super, 0);
|
crpath = vfs_s_get_path (vpath2, &super, 0);
|
||||||
if (crpath == NULL)
|
if (crpath == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1336,8 +1334,10 @@ fish_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
|||||||
rpath = strutils_shell_escape (crpath);
|
rpath = strutils_shell_escape (crpath);
|
||||||
qsetto = strutils_shell_escape (vfs_path_get_last_path_str (vpath1));
|
qsetto = strutils_shell_escape (vfs_path_get_last_path_str (vpath1));
|
||||||
|
|
||||||
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath2));
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
fish_send_command (path_element->class, super, OPT_FLUSH, FISH_SUPER (super)->scr_ln,
|
fish_send_command (me, super, OPT_FLUSH, FISH_SUPER (super)->scr_ln,
|
||||||
"FISH_FILEFROM=%s FISH_FILETO=%s;\n", qsetto, rpath);
|
"FISH_FILEFROM=%s FISH_FILETO=%s;\n", qsetto, rpath);
|
||||||
|
|
||||||
g_free (qsetto);
|
g_free (qsetto);
|
||||||
@ -1390,19 +1390,19 @@ fish_chmod (const vfs_path_t * vpath, mode_t mode)
|
|||||||
const char *crpath;
|
const char *crpath;
|
||||||
char *rpath;
|
char *rpath;
|
||||||
struct vfs_s_super *super;
|
struct vfs_s_super *super;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
|
||||||
|
|
||||||
crpath = vfs_s_get_path (vpath, &super, 0);
|
crpath = vfs_s_get_path (vpath, &super, 0);
|
||||||
if (crpath == NULL)
|
if (crpath == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
rpath = strutils_shell_escape (crpath);
|
rpath = strutils_shell_escape (crpath);
|
||||||
|
|
||||||
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
fish_send_command (path_element->class, super, OPT_FLUSH, FISH_SUPER (super)->scr_chmod,
|
fish_send_command (me, super, OPT_FLUSH, FISH_SUPER (super)->scr_chmod,
|
||||||
"FISH_FILENAME=%s FISH_FILEMODE=%4.4o;\n", rpath,
|
"FISH_FILENAME=%s FISH_FILEMODE=%4.4o;\n", rpath,
|
||||||
(unsigned int) (mode & 07777));
|
(unsigned int) (mode & 07777));
|
||||||
|
|
||||||
@ -1422,7 +1422,7 @@ fish_chown (const vfs_path_t * vpath, uid_t owner, gid_t group)
|
|||||||
const char *crpath;
|
const char *crpath;
|
||||||
char *rpath;
|
char *rpath;
|
||||||
struct vfs_s_super *super;
|
struct vfs_s_super *super;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pw = getpwuid (owner);
|
pw = getpwuid (owner);
|
||||||
@ -1436,17 +1436,17 @@ fish_chown (const vfs_path_t * vpath, uid_t owner, gid_t group)
|
|||||||
sowner = pw->pw_name;
|
sowner = pw->pw_name;
|
||||||
sgroup = gr->gr_name;
|
sgroup = gr->gr_name;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
|
||||||
|
|
||||||
crpath = vfs_s_get_path (vpath, &super, 0);
|
crpath = vfs_s_get_path (vpath, &super, 0);
|
||||||
if (crpath == NULL)
|
if (crpath == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
rpath = strutils_shell_escape (crpath);
|
rpath = strutils_shell_escape (crpath);
|
||||||
|
|
||||||
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
/* FIXME: what should we report if chgrp succeeds but chown fails? */
|
/* FIXME: what should we report if chgrp succeeds but chown fails? */
|
||||||
ret =
|
ret =
|
||||||
fish_send_command (path_element->class, super, OPT_FLUSH, FISH_SUPER (super)->scr_chown,
|
fish_send_command (me, super, OPT_FLUSH, FISH_SUPER (super)->scr_chown,
|
||||||
"FISH_FILENAME=%s FISH_FILEOWNER=%s FISH_FILEGROUP=%s;\n", rpath, sowner,
|
"FISH_FILENAME=%s FISH_FILEOWNER=%s FISH_FILEGROUP=%s;\n", rpath, sowner,
|
||||||
sgroup);
|
sgroup);
|
||||||
|
|
||||||
@ -1496,11 +1496,9 @@ fish_utime (const vfs_path_t * vpath, mc_timesbuf_t * times)
|
|||||||
const char *crpath;
|
const char *crpath;
|
||||||
char *rpath;
|
char *rpath;
|
||||||
struct vfs_s_super *super;
|
struct vfs_s_super *super;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
|
||||||
|
|
||||||
crpath = vfs_s_get_path (vpath, &super, 0);
|
crpath = vfs_s_get_path (vpath, &super, 0);
|
||||||
if (crpath == NULL)
|
if (crpath == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1525,7 +1523,9 @@ fish_utime (const vfs_path_t * vpath, mc_timesbuf_t * times)
|
|||||||
gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday,
|
gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday,
|
||||||
gmt->tm_hour, gmt->tm_min, gmt->tm_sec, mtime_nsec);
|
gmt->tm_hour, gmt->tm_min, gmt->tm_sec, mtime_nsec);
|
||||||
|
|
||||||
ret = fish_send_command (path_element->class, super, OPT_FLUSH, FISH_SUPER (super)->scr_utime,
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
|
ret = fish_send_command (me, super, OPT_FLUSH, FISH_SUPER (super)->scr_utime,
|
||||||
"FISH_FILENAME=%s FISH_FILEATIME=%ld FISH_FILEMTIME=%ld "
|
"FISH_FILENAME=%s FISH_FILEATIME=%ld FISH_FILEMTIME=%ld "
|
||||||
"FISH_TOUCHATIME=%s FISH_TOUCHMTIME=%s FISH_TOUCHATIME_W_NSEC=\"%s\" "
|
"FISH_TOUCHATIME=%s FISH_TOUCHMTIME=%s FISH_TOUCHATIME_W_NSEC=\"%s\" "
|
||||||
"FISH_TOUCHMTIME_W_NSEC=\"%s\";\n", rpath, (long) atime, (long) mtime,
|
"FISH_TOUCHMTIME_W_NSEC=\"%s\";\n", rpath, (long) atime, (long) mtime,
|
||||||
@ -1544,19 +1544,19 @@ fish_unlink (const vfs_path_t * vpath)
|
|||||||
const char *crpath;
|
const char *crpath;
|
||||||
char *rpath;
|
char *rpath;
|
||||||
struct vfs_s_super *super;
|
struct vfs_s_super *super;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
|
||||||
|
|
||||||
crpath = vfs_s_get_path (vpath, &super, 0);
|
crpath = vfs_s_get_path (vpath, &super, 0);
|
||||||
if (crpath == NULL)
|
if (crpath == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
rpath = strutils_shell_escape (crpath);
|
rpath = strutils_shell_escape (crpath);
|
||||||
|
|
||||||
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
fish_send_command (path_element->class, super, OPT_FLUSH, FISH_SUPER (super)->scr_unlink,
|
fish_send_command (me, super, OPT_FLUSH, FISH_SUPER (super)->scr_unlink,
|
||||||
"FISH_FILENAME=%s;\n", rpath);
|
"FISH_FILENAME=%s;\n", rpath);
|
||||||
|
|
||||||
g_free (rpath);
|
g_free (rpath);
|
||||||
@ -1572,19 +1572,19 @@ fish_exists (const vfs_path_t * vpath)
|
|||||||
const char *crpath;
|
const char *crpath;
|
||||||
char *rpath;
|
char *rpath;
|
||||||
struct vfs_s_super *super;
|
struct vfs_s_super *super;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
|
||||||
|
|
||||||
crpath = vfs_s_get_path (vpath, &super, 0);
|
crpath = vfs_s_get_path (vpath, &super, 0);
|
||||||
if (crpath == NULL)
|
if (crpath == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
rpath = strutils_shell_escape (crpath);
|
rpath = strutils_shell_escape (crpath);
|
||||||
|
|
||||||
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
fish_send_command (path_element->class, super, OPT_FLUSH, FISH_SUPER (super)->scr_exists,
|
fish_send_command (me, super, OPT_FLUSH, FISH_SUPER (super)->scr_exists,
|
||||||
"FISH_FILENAME=%s;\n", rpath);
|
"FISH_FILENAME=%s;\n", rpath);
|
||||||
|
|
||||||
g_free (rpath);
|
g_free (rpath);
|
||||||
@ -1600,21 +1600,21 @@ fish_mkdir (const vfs_path_t * vpath, mode_t mode)
|
|||||||
const char *crpath;
|
const char *crpath;
|
||||||
char *rpath;
|
char *rpath;
|
||||||
struct vfs_s_super *super;
|
struct vfs_s_super *super;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
(void) mode;
|
(void) mode;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
|
||||||
|
|
||||||
crpath = vfs_s_get_path (vpath, &super, 0);
|
crpath = vfs_s_get_path (vpath, &super, 0);
|
||||||
if (crpath == NULL)
|
if (crpath == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
rpath = strutils_shell_escape (crpath);
|
rpath = strutils_shell_escape (crpath);
|
||||||
|
|
||||||
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
fish_send_command (path_element->class, super, OPT_FLUSH, FISH_SUPER (super)->scr_mkdir,
|
fish_send_command (me, super, OPT_FLUSH, FISH_SUPER (super)->scr_mkdir,
|
||||||
"FISH_FILENAME=%s;\n", rpath);
|
"FISH_FILENAME=%s;\n", rpath);
|
||||||
g_free (rpath);
|
g_free (rpath);
|
||||||
|
|
||||||
@ -1623,7 +1623,7 @@ fish_mkdir (const vfs_path_t * vpath, mode_t mode)
|
|||||||
|
|
||||||
if (fish_exists (vpath) == 0)
|
if (fish_exists (vpath) == 0)
|
||||||
{
|
{
|
||||||
path_element->class->verrno = EACCES;
|
me->verrno = EACCES;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -1637,19 +1637,19 @@ fish_rmdir (const vfs_path_t * vpath)
|
|||||||
const char *crpath;
|
const char *crpath;
|
||||||
char *rpath;
|
char *rpath;
|
||||||
struct vfs_s_super *super;
|
struct vfs_s_super *super;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
|
||||||
|
|
||||||
crpath = vfs_s_get_path (vpath, &super, 0);
|
crpath = vfs_s_get_path (vpath, &super, 0);
|
||||||
if (crpath == NULL)
|
if (crpath == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
rpath = strutils_shell_escape (crpath);
|
rpath = strutils_shell_escape (crpath);
|
||||||
|
|
||||||
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
fish_send_command (path_element->class, super, OPT_FLUSH, FISH_SUPER (super)->scr_rmdir,
|
fish_send_command (me, super, OPT_FLUSH, FISH_SUPER (super)->scr_rmdir,
|
||||||
"FISH_FILENAME=%s;\n", rpath);
|
"FISH_FILENAME=%s;\n", rpath);
|
||||||
|
|
||||||
g_free (rpath);
|
g_free (rpath);
|
||||||
|
@ -2121,28 +2121,28 @@ ftpfs_send_command (const vfs_path_t * vpath, const char *cmd, int flags)
|
|||||||
char *p;
|
char *p;
|
||||||
struct vfs_s_super *super;
|
struct vfs_s_super *super;
|
||||||
int r;
|
int r;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
gboolean flush_directory_cache = (flags & OPT_FLUSH) != 0;
|
gboolean flush_directory_cache = (flags & OPT_FLUSH) != 0;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
rpath = vfs_s_get_path (vpath, &super, 0);
|
rpath = vfs_s_get_path (vpath, &super, 0);
|
||||||
if (rpath == NULL)
|
if (rpath == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
p = ftpfs_translate_path (path_element->class, super, rpath);
|
p = ftpfs_translate_path (me, super, rpath);
|
||||||
r = ftpfs_command (path_element->class, super, WAIT_REPLY, cmd, p);
|
r = ftpfs_command (me, super, WAIT_REPLY, cmd, p);
|
||||||
g_free (p);
|
g_free (p);
|
||||||
vfs_stamp_create (vfs_ftpfs_ops, super);
|
vfs_stamp_create (vfs_ftpfs_ops, super);
|
||||||
if ((flags & OPT_IGNORE_ERROR) != 0)
|
if ((flags & OPT_IGNORE_ERROR) != 0)
|
||||||
r = COMPLETE;
|
r = COMPLETE;
|
||||||
if (r != COMPLETE)
|
if (r != COMPLETE)
|
||||||
{
|
{
|
||||||
path_element->class->verrno = EPERM;
|
me->verrno = EPERM;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (flush_directory_cache)
|
if (flush_directory_cache)
|
||||||
vfs_s_invalidate (path_element->class, super);
|
vfs_s_invalidate (me, super);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,7 +596,6 @@ sftpfs_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2, GError ** m
|
|||||||
tmp_path_len = ctmp_path->len;
|
tmp_path_len = ctmp_path->len;
|
||||||
|
|
||||||
path1 = vfs_path_get_last_path_str (vpath1);
|
path1 = vfs_path_get_last_path_str (vpath1);
|
||||||
|
|
||||||
fixfname = sftpfs_fix_filename (path1);
|
fixfname = sftpfs_fix_filename (path1);
|
||||||
|
|
||||||
do
|
do
|
||||||
|
@ -107,23 +107,23 @@ static void *
|
|||||||
sftpfs_cb_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
sftpfs_cb_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
vfs_file_handler_t *fh;
|
vfs_file_handler_t *fh;
|
||||||
const vfs_path_element_t *path_element;
|
struct vfs_class *me;
|
||||||
struct vfs_s_super *super;
|
struct vfs_s_super *super;
|
||||||
const char *path_super;
|
const char *path_super;
|
||||||
struct vfs_s_inode *path_inode;
|
struct vfs_s_inode *path_inode;
|
||||||
GError *mcerror = NULL;
|
GError *mcerror = NULL;
|
||||||
gboolean is_changed = FALSE;
|
gboolean is_changed = FALSE;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
|
||||||
|
|
||||||
path_super = vfs_s_get_path (vpath, &super, 0);
|
path_super = vfs_s_get_path (vpath, &super, 0);
|
||||||
if (path_super == NULL)
|
if (path_super == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
path_inode = vfs_s_find_inode (path_element->class, super, path_super, LINK_FOLLOW, FL_NONE);
|
me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath));
|
||||||
|
|
||||||
|
path_inode = vfs_s_find_inode (me, super, path_super, LINK_FOLLOW, FL_NONE);
|
||||||
if (path_inode != NULL && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)))
|
if (path_inode != NULL && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)))
|
||||||
{
|
{
|
||||||
path_element->class->verrno = EEXIST;
|
me->verrno = EEXIST;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,22 +134,22 @@ sftpfs_cb_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
|||||||
struct vfs_s_inode *dir;
|
struct vfs_s_inode *dir;
|
||||||
|
|
||||||
name = g_path_get_dirname (path_super);
|
name = g_path_get_dirname (path_super);
|
||||||
dir = vfs_s_find_inode (path_element->class, super, name, LINK_FOLLOW, FL_DIR);
|
dir = vfs_s_find_inode (me, super, name, LINK_FOLLOW, FL_DIR);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
name = g_path_get_basename (path_super);
|
name = g_path_get_basename (path_super);
|
||||||
ent = vfs_s_generate_entry (path_element->class, name, dir, 0755);
|
ent = vfs_s_generate_entry (me, name, dir, 0755);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
path_inode = ent->ino;
|
path_inode = ent->ino;
|
||||||
vfs_s_insert_entry (path_element->class, dir, ent);
|
vfs_s_insert_entry (me, dir, ent);
|
||||||
is_changed = TRUE;
|
is_changed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISDIR (path_inode->st.st_mode))
|
if (S_ISDIR (path_inode->st.st_mode))
|
||||||
{
|
{
|
||||||
path_element->class->verrno = EISDIR;
|
me->verrno = EISDIR;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ sftpfs_cb_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
vfs_rmstamp (path_element->class, (vfsid) super);
|
vfs_rmstamp (me, (vfsid) super);
|
||||||
super->fd_usage++;
|
super->fd_usage++;
|
||||||
fh->ino->st.st_nlink++;
|
fh->ino->st.st_nlink++;
|
||||||
return fh;
|
return fh;
|
||||||
|
@ -333,9 +333,9 @@ static void *
|
|||||||
undelfs_opendir (const vfs_path_t * vpath)
|
undelfs_opendir (const vfs_path_t * vpath)
|
||||||
{
|
{
|
||||||
char *file, *f = NULL;
|
char *file, *f = NULL;
|
||||||
const vfs_path_element_t *path_element;
|
const char *class_name;
|
||||||
|
|
||||||
path_element = vfs_path_get_by_index (vpath, -1);
|
class_name = vfs_path_get_last_path_vfs (vpath)->name;
|
||||||
undelfs_get_path (vpath, &file, &f);
|
undelfs_get_path (vpath, &file, &f);
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
@ -379,10 +379,10 @@ undelfs_opendir (const vfs_path_t * vpath)
|
|||||||
/* Now load the deleted information */
|
/* Now load the deleted information */
|
||||||
if (!undelfs_loaddel ())
|
if (!undelfs_loaddel ())
|
||||||
goto quit_opendir;
|
goto quit_opendir;
|
||||||
vfs_print_message (_("%s: done."), path_element->class->name);
|
vfs_print_message (_("%s: done."), class_name);
|
||||||
return fs;
|
return fs;
|
||||||
quit_opendir:
|
quit_opendir:
|
||||||
vfs_print_message (_("%s: failure"), path_element->class->name);
|
vfs_print_message (_("%s: failure"), class_name);
|
||||||
ext2fs_close (fs);
|
ext2fs_close (fs);
|
||||||
fs = NULL;
|
fs = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user