Following prototypes of functions was changed in VFS-module API:

* getid
 * mkdir
 * rmdir
 * setctl

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2011-04-21 13:27:56 +03:00
parent d67da5dfa8
commit 152124d9b7
13 changed files with 158 additions and 112 deletions

View File

@ -818,13 +818,17 @@ vfs_s_ungetlocalcopy (const vfs_path_t * vpath, const char *local, int has_chang
/* --------------------------------------------------------------------------------------------- */
static int
vfs_s_setctl (struct vfs_class *me, const char *path, int ctlop, void *arg)
vfs_s_setctl (const vfs_path_t * vpath, int ctlop, void *arg)
{
vfs_path_element_t *path_element;
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
switch (ctlop)
{
case VFS_SETCTL_STALE_DATA:
{
struct vfs_s_inode *ino = vfs_s_inode_from_path (me, path, 0);
struct vfs_s_inode *ino =
vfs_s_inode_from_path (path_element->class, vpath->unparsed, 0);
if (ino == NULL)
return 0;
@ -833,15 +837,15 @@ vfs_s_setctl (struct vfs_class *me, const char *path, int ctlop, void *arg)
else
{
ino->super->want_stale = 0;
vfs_s_invalidate (me, ino->super);
vfs_s_invalidate (path_element->class, ino->super);
}
return 1;
}
case VFS_SETCTL_LOGFILE:
MEDATA->logfile = fopen ((char *) arg, "w");
((struct vfs_s_subclass *) path_element->class->data)->logfile = fopen ((char *) arg, "w");
return 1;
case VFS_SETCTL_FLUSH:
MEDATA->flush = 1;
((struct vfs_s_subclass *) path_element->class->data)->flush = 1;
return 1;
}
return 0;
@ -851,12 +855,15 @@ vfs_s_setctl (struct vfs_class *me, const char *path, int ctlop, void *arg)
/* ----------------------------- Stamping support -------------------------- */
static vfsid
vfs_s_getid (struct vfs_class *me, const char *path)
vfs_s_getid (const vfs_path_t * vpath)
{
struct vfs_s_super *archive = NULL;
char *p;
vfs_path_element_t *path_element;
p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN);
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
p = vfs_s_get_path (path_element->class, vpath->unparsed, &archive, FL_NO_OPEN);
if (p == NULL)
return NULL;
g_free (p);
@ -1380,18 +1387,15 @@ vfs_s_init_class (struct vfs_class *vclass, struct vfs_s_subclass *sub)
/** Find VFS id for given directory name */
vfsid
vfs_getid (struct vfs_class *vclass, const char *dir)
vfs_getid (const vfs_path_t * vpath)
{
char *dir1;
vfsid id = NULL;
vfs_path_element_t *path_element;
/* append slash if needed */
dir1 = concat_dir_and_file (dir, "");
if (vclass->getid)
id = (*vclass->getid) (vclass, dir1);
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
if (path_element == NULL || path_element->class->getid == NULL)
return NULL;
g_free (dir1);
return id;
return (*path_element->class->getid) (vpath);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -153,12 +153,16 @@ vfs_rmstamp (struct vfs_class *v, vfsid id)
void
vfs_stamp_path (const char *path)
{
struct vfs_class *vfs;
vfsid id;
vfs_path_t *vpath;
vfs_path_element_t *path_element;
vfs = vfs_get_class (path);
id = vfs_getid (vfs, path);
vfs_addstamp (vfs, id);
vpath = vfs_path_from_str (path);
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
id = vfs_getid (vpath);
vfs_addstamp (path_element->class, id);
vfs_path_free (vpath);
}
/* --------------------------------------------------------------------------------------------- */
@ -169,10 +173,11 @@ vfs_stamp_path (const char *path)
void
vfs_stamp_create (struct vfs_class *vclass, vfsid id)
{
struct vfs_class *nvfs;
vfsid nvfsid;
ev_vfs_stamp_create_t event_data = { vclass, id, FALSE };
vfs_path_t *vpath;
vfs_path_element_t *path_element;
/* There are three directories we have to take care of: current_dir,
current_panel->cwd and other_panel->cwd. Athough most of the time either
@ -182,20 +187,21 @@ vfs_stamp_create (struct vfs_class *vclass, vfsid id)
if (!mc_event_present (MCEVENT_GROUP_CORE, "vfs_timestamp"))
return;
nvfs = vfs_get_class (vfs_get_current_dir ());
nvfsid = vfs_getid (nvfs, vfs_get_current_dir ());
vfs_rmstamp (nvfs, nvfsid);
vpath = vfs_path_from_str (vfs_get_current_dir ());
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
if (id == NULL || (nvfs == vclass && nvfsid == id))
return;
nvfsid = vfs_getid (vpath);
vfs_rmstamp (path_element->class, nvfsid);
mc_event_raise (MCEVENT_GROUP_CORE, "vfs_timestamp", (gpointer) &event_data);
if (!(id == NULL || (path_element->class == vclass && nvfsid == id)))
{
mc_event_raise (MCEVENT_GROUP_CORE, "vfs_timestamp", (gpointer) & event_data);
if (event_data.ret)
return;
if (vclass != NULL && vclass->nothingisopen != NULL && vclass->nothingisopen (id) != 0)
if (!event_data.ret && vclass != NULL && vclass->nothingisopen != NULL
&& vclass->nothingisopen (id) != 0)
vfs_addstamp (vclass, id);
}
vfs_path_free (vpath);
}
/* --------------------------------------------------------------------------------------------- */
@ -260,12 +266,13 @@ vfs_timeout_handler (void)
void
vfs_release_path (const char *dir)
{
struct vfs_class *oldvfs;
vfsid oldvfsid;
vfs_path_t *vpath;
vfs_path_element_t *path_element;
oldvfs = vfs_get_class (dir);
oldvfsid = vfs_getid (oldvfs, dir);
vfs_stamp_create (oldvfs, oldvfsid);
vpath = vfs_path_from_str (dir);
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
vfs_stamp_create (path_element->class, vfs_getid (vpath));
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -29,7 +29,6 @@ struct vfs_stamping
void vfs_stamp (struct vfs_class *vclass, vfsid id);
void vfs_rmstamp (struct vfs_class *vclass, vfsid id);
void vfs_stamp_create (struct vfs_class *vclass, vfsid id);
vfsid vfs_getid (struct vfs_class *vclass, const char *dir);
void vfs_gc_done (void);
/*** inline functions ****************************************************************************/

View File

@ -260,8 +260,8 @@ MC_NAMEOP (chown, (const char *path, uid_t owner, gid_t group), (vpath, owner, g
MC_NAMEOP (utime, (const char *path, struct utimbuf * times), (vpath, times))
MC_NAMEOP (readlink, (const char *path, char *buf, size_t bufsiz), (vpath, buf, bufsiz))
MC_NAMEOP (unlink, (const char *path), (vpath))
MC_NAMEOP (mkdir, (const char *path, mode_t mode), (path_element->class, vpath->unparsed, mode))
MC_NAMEOP (rmdir, (const char *path), (path_element->class, vpath->unparsed))
MC_NAMEOP (mkdir, (const char *path, mode_t mode), (vpath, mode))
MC_NAMEOP (rmdir, (const char *path), (vpath))
MC_NAMEOP (mknod, (const char *path, mode_t mode, dev_t dev), (vpath, mode, dev))
/* *INDENT-ON* */
@ -399,8 +399,7 @@ mc_setctl (const char *path, int ctlop, void *arg)
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
if (path_element != NULL && path_element->class != NULL)
result =
path_element->class->setctl != NULL ? path_element->class->setctl (path_element->class,
vpath->unparsed,
path_element->class->setctl != NULL ? path_element->class->setctl (vpath,
ctlop, arg) : 0;
vfs_path_free (vpath);
@ -729,8 +728,12 @@ mc_chdir (const char *path)
return -1;
}
old_vfsid = vfs_getid (current_vfs, current_dir);
{
vfs_path_t *current_vpath = vfs_path_from_str (current_dir);
old_vfsid = vfs_getid (current_vpath);
old_vfs = current_vfs;
vfs_path_free (current_vpath);
}
/* Actually change directory */
g_free (current_dir);

View File

@ -178,7 +178,7 @@ typedef struct vfs_class
off_t (*lseek) (void *vfs_info, off_t offset, int whence);
int (*mknod) (const vfs_path_t * vpath, mode_t mode, dev_t dev);
vfsid (*getid) (struct vfs_class * me, const char *path);
vfsid (*getid) (const vfs_path_t * vpath);
int (*nothingisopen) (vfsid id);
void (*free) (vfsid id);
@ -186,11 +186,11 @@ typedef struct vfs_class
char *(*getlocalcopy) (const vfs_path_t * vpath);
int (*ungetlocalcopy) (const vfs_path_t * vpath, const char *local, int has_changed);
int (*mkdir) (struct vfs_class * me, const char *path, mode_t mode);
int (*rmdir) (struct vfs_class * me, const char *path);
int (*mkdir) (const vfs_path_t * vpath, mode_t mode);
int (*rmdir) (const vfs_path_t * vpath);
int (*ctl) (void *vfs_info, int ctlop, void *arg);
int (*setctl) (struct vfs_class * me, const char *path, int ctlop, void *arg);
int (*setctl) (const vfs_path_t * vpath, int ctlop, void *arg);
} vfs_class;
/*
@ -216,7 +216,7 @@ extern int use_netrc;
/* lib/vfs/direntry.c: */
void *vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode);
vfsid vfs_getid (struct vfs_class *vclass, const char *dir);
vfsid vfs_getid (const vfs_path_t * vpath);
void vfs_init (void);
void vfs_shut (void);

View File

@ -491,14 +491,16 @@ check_panel_timestamp (const WPanel * panel, panel_view_mode_t mode, struct vfs_
{
if (mode == view_listing)
{
struct vfs_class *nvfs;
vfsid nvfsid;
vfs_path_t *vpath;
vfs_path_element_t *path_element;
nvfs = vfs_get_class (panel->cwd);
if (nvfs != vclass)
vpath = vfs_path_from_str (panel->cwd);
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
if (path_element->class != vclass)
return FALSE;
nvfsid = vfs_getid (nvfs, panel->cwd);
if (nvfsid != id)
if (vfs_getid (vpath) != id)
return FALSE;
}
return TRUE;

View File

@ -1245,24 +1245,25 @@ extfs_unlink (const vfs_path_t * vpath)
/* --------------------------------------------------------------------------------------------- */
static int
extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode)
extfs_mkdir (const vfs_path_t * vpath, mode_t mode)
{
struct archive *archive;
char *q, *mpath;
struct entry *entry;
int result = -1;
vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
(void) mode;
mpath = g_strdup (path);
mpath = g_strdup (vpath->unparsed);
q = extfs_get_path_mangle (me, mpath, &archive, FALSE);
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);
if (entry != NULL)
{
me->verrno = EEXIST;
path_element->class->verrno = EEXIST;
goto cleanup;
}
entry = extfs_find_entry (archive->root_entry, q, TRUE, FALSE);
@ -1273,7 +1274,7 @@ extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode)
goto cleanup;
if (!S_ISDIR (entry->inode->mode))
{
me->verrno = ENOTDIR;
path_element->class->verrno = ENOTDIR;
goto cleanup;
}
@ -1292,16 +1293,17 @@ extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode)
/* --------------------------------------------------------------------------------------------- */
static int
extfs_rmdir (struct vfs_class *me, const char *path)
extfs_rmdir (const vfs_path_t * vpath)
{
struct archive *archive;
char *q, *mpath;
struct entry *entry;
int result = -1;
vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
mpath = g_strdup (path);
mpath = g_strdup (vpath->unparsed);
q = extfs_get_path_mangle (me, mpath, &archive, FALSE);
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);
@ -1312,7 +1314,7 @@ extfs_rmdir (struct vfs_class *me, const char *path)
goto cleanup;
if (!S_ISDIR (entry->inode->mode))
{
me->verrno = ENOTDIR;
path_element->class->verrno = ENOTDIR;
goto cleanup;
}
@ -1366,12 +1368,13 @@ extfs_lseek (void *data, off_t offset, int whence)
/* --------------------------------------------------------------------------------------------- */
static vfsid
extfs_getid (struct vfs_class *me, const char *path)
extfs_getid (const vfs_path_t * vpath)
{
struct archive *archive = NULL;
char *p;
vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
p = extfs_get_path (me, path, &archive, TRUE);
p = extfs_get_path (path_element->class, vpath->unparsed, &archive, TRUE);
if (p == NULL)
return NULL;
g_free (p);
@ -1683,13 +1686,15 @@ extfs_done (struct vfs_class *me)
/* --------------------------------------------------------------------------------------------- */
static int
extfs_setctl (struct vfs_class *me, const char *path, int ctlop, void *arg)
extfs_setctl (const vfs_path_t * vpath, int ctlop, void *arg)
{
vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
(void) arg;
if (ctlop == VFS_SETCTL_RUN)
{
extfs_run (me, path);
extfs_run (path_element->class, vpath->unparsed);
return 1;
}
return 0;

View File

@ -1403,46 +1403,79 @@ fish_exists (struct vfs_class *me, const char *path)
/* --------------------------------------------------------------------------------------------- */
static int
fish_mkdir (struct vfs_class *me, const char *path, mode_t mode)
fish_mkdir (const vfs_path_t * vpath, mode_t mode)
{
gchar *shell_commands = NULL;
int ret_code;
PREFIX;
char buf[BUF_LARGE];
const char *crpath;
char *rpath, *mpath;
struct vfs_s_super *super;
vfs_path_element_t *path_element;
(void) mode;
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
mpath = g_strdup (vpath->unparsed);
crpath = vfs_s_get_path_mangle (path_element->class, mpath, &super, 0);
if (crpath == NULL)
{
g_free (mpath);
return -1;
}
rpath = strutils_shell_escape (crpath);
g_free (mpath);
shell_commands =
g_strconcat (SUP->scr_env, "FISH_FILENAME=%s;\n", SUP->scr_mkdir, (char *) NULL);
g_snprintf (buf, sizeof (buf), shell_commands, rpath);
g_free (shell_commands);
g_free (rpath);
ret_code = fish_send_command (me, super, buf, OPT_FLUSH);
ret_code = fish_send_command (path_element->class, super, buf, OPT_FLUSH);
if (ret_code != 0)
return ret_code;
if (!fish_exists (me, path))
ERRNOR (EACCES, -1);
if (!fish_exists (path_element->class, vpath->unparsed))
{
path_element->class->verrno = EACCES;
return -1;
}
return 0;
}
/* --------------------------------------------------------------------------------------------- */
static int
fish_rmdir (struct vfs_class *me, const char *path)
fish_rmdir (const vfs_path_t * vpath)
{
gchar *shell_commands = NULL;
char buf[BUF_LARGE];
const char *crpath;
char *rpath, *mpath;
struct vfs_s_super *super;
vfs_path_element_t *path_element;
PREFIX;
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
mpath = g_strdup (vpath->unparsed);
crpath = vfs_s_get_path_mangle (path_element->class, mpath, &super, 0);
if (crpath == NULL)
{
g_free (mpath);
return -1;
}
rpath = strutils_shell_escape (crpath);
g_free (mpath);
shell_commands =
g_strconcat (SUP->scr_env, "FISH_FILENAME=%s;\n", SUP->scr_rmdir, (char *) NULL);
g_snprintf (buf, sizeof (buf), shell_commands, rpath);
g_free (shell_commands);
g_free (rpath);
return fish_send_command (me, super, buf, OPT_FLUSH);
return fish_send_command (path_element->class, super, buf, OPT_FLUSH);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -2076,19 +2076,24 @@ ftpfs_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
/* --------------------------------------------------------------------------------------------- */
static int
ftpfs_mkdir (struct vfs_class *me, const char *path, mode_t mode)
ftpfs_mkdir (const vfs_path_t * vpath, mode_t mode)
{
vfs_path_element_t *path_element;
(void) mode; /* FIXME: should be used */
return ftpfs_send_command (me, path, "MKD /%s", OPT_FLUSH);
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
return ftpfs_send_command (path_element->class, vpath->unparsed, "MKD /%s", OPT_FLUSH);
}
/* --------------------------------------------------------------------------------------------- */
static int
ftpfs_rmdir (struct vfs_class *me, const char *path)
ftpfs_rmdir (const vfs_path_t * vpath)
{
return ftpfs_send_command (me, path, "RMD /%s", OPT_FLUSH);
vfs_path_element_t *path_element;
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
return ftpfs_send_command (path_element->class, vpath->unparsed, "RMD /%s", OPT_FLUSH);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -242,21 +242,17 @@ local_link (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
/* --------------------------------------------------------------------------------------------- */
static int
local_mkdir (struct vfs_class *me, const char *path, mode_t mode)
local_mkdir (const vfs_path_t * vpath, mode_t mode)
{
(void) me;
return mkdir (path, mode);
return mkdir (vpath->unparsed, mode);
}
/* --------------------------------------------------------------------------------------------- */
static int
local_rmdir (struct vfs_class *me, const char *path)
local_rmdir (const vfs_path_t * vpath)
{
(void) me;
return rmdir (path);
return rmdir (vpath->unparsed);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -355,13 +355,11 @@ sfs_readlink (const vfs_path_t * vpath, char *buf, size_t size)
/* --------------------------------------------------------------------------------------------- */
static vfsid
sfs_getid (struct vfs_class *me, const char *path)
sfs_getid (const vfs_path_t * vpath)
{
GSList *cur;
(void) me;
cur = g_slist_find_custom (head, path, cachedfile_compare);
cur = g_slist_find_custom (head, vpath->unparsed, cachedfile_compare);
return (vfsid) (cur != NULL ? cur->data : NULL);
}

View File

@ -1842,19 +1842,17 @@ smbfs_mknod (const vfs_path_t * vpath, mode_t mode, dev_t dev)
/* --------------------------------------------------------------------------------------------- */
static int
smbfs_mkdir (struct vfs_class *me, const char *path, mode_t mode)
smbfs_mkdir (const vfs_path_t * vpath, mode_t mode)
{
smbfs_connection *sc;
char *remote_file;
char *cpath;
(void) me;
DEBUG (3, ("smbfs_mkdir(path:%s, mode:%d)\n", path, (int) mode));
if ((remote_file = smbfs_get_path (&sc, path)) == 0)
DEBUG (3, ("smbfs_mkdir(path:%s, mode:%d)\n", vpath->unparsed, (int) mode));
if ((remote_file = smbfs_get_path (&sc, vpath->unparsed)) == 0)
return -1;
g_free (remote_file);
cpath = smbfs_convert_path (path, FALSE);
cpath = smbfs_convert_path (vpath->unparsed, FALSE);
if (!cli_mkdir (sc->cli, cpath))
{
@ -1871,19 +1869,17 @@ smbfs_mkdir (struct vfs_class *me, const char *path, mode_t mode)
/* --------------------------------------------------------------------------------------------- */
static int
smbfs_rmdir (struct vfs_class *me, const char *path)
smbfs_rmdir (const vfs_path_t * vpath)
{
smbfs_connection *sc;
char *remote_file;
char *cpath;
(void) me;
DEBUG (3, ("smbfs_rmdir(path:%s)\n", path));
if ((remote_file = smbfs_get_path (&sc, path)) == 0)
DEBUG (3, ("smbfs_rmdir(path:%s)\n", vpath->unparsed));
if ((remote_file = smbfs_get_path (&sc, vpath->unparsed)) == 0)
return -1;
g_free (remote_file);
cpath = smbfs_convert_path (path, FALSE);
cpath = smbfs_convert_path (vpath->unparsed, FALSE);
if (!cli_rmdir (sc->cli, cpath))
{
@ -1964,16 +1960,15 @@ smbfs_forget (const char *path)
/* --------------------------------------------------------------------------------------------- */
static int
smbfs_setctl (struct vfs_class *me, const char *path, int ctlop, void *arg)
smbfs_setctl (const vfs_path_t * vpath, int ctlop, void *arg)
{
(void) me;
(void) arg;
DEBUG (3, ("smbfs_setctl(path:%s, ctlop:%d)\n", path, ctlop));
DEBUG (3, ("smbfs_setctl(path:%s, ctlop:%d)\n", vpath->unparsed, ctlop));
switch (ctlop)
{
case VFS_SETCTL_FORGET:
smbfs_forget (path);
smbfs_forget (vpath->unparsed);
return 0;
}
return 0;

View File

@ -726,12 +726,11 @@ undelfs_lseek (void *vfs_info, off_t offset, int whence)
/* --------------------------------------------------------------------------------------------- */
static vfsid
undelfs_getid (struct vfs_class *me, const char *path)
undelfs_getid (const vfs_path_t * vpath)
{
char *fname, *fsname;
(void) me;
undelfs_get_path (path, &fsname, &fname);
undelfs_get_path (vpath->unparsed, &fsname, &fname);
if (!fsname)
return NULL;