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

* chmod
 * chown
 * utime

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2011-04-20 12:03:56 +03:00
parent 479902f83e
commit dd19ca201d
8 changed files with 92 additions and 53 deletions

View File

@ -255,9 +255,9 @@ int mc_##name inarg \
return result; \
}
MC_NAMEOP (chmod, (const char *path, mode_t mode), (path_element->class, vpath->unparsed, mode))
MC_NAMEOP (chown, (const char *path, uid_t owner, gid_t group), (path_element->class, vpath->unparsed, owner, group))
MC_NAMEOP (utime, (const char *path, struct utimbuf * times), (path_element->class, vpath->unparsed, times))
MC_NAMEOP (chmod, (const char *path, mode_t mode), (vpath, mode))
MC_NAMEOP (chown, (const char *path, uid_t owner, gid_t group), (vpath, owner, group))
MC_NAMEOP (utime, (const char *path, struct utimbuf * times), (vpath, times))
MC_NAMEOP (readlink, (const char *path, char *buf, size_t bufsiz), (path_element->class, vpath->unparsed, buf, bufsiz))
MC_NAMEOP (unlink, (const char *path), (path_element->class, vpath->unparsed))
MC_NAMEOP (mkdir, (const char *path, mode_t mode), (path_element->class, vpath->unparsed, mode))

View File

@ -164,9 +164,9 @@ typedef struct vfs_class
int (*lstat) (struct vfs_class * me, const char *path, struct stat * buf);
int (*fstat) (void *vfs_info, struct stat * buf);
int (*chmod) (struct vfs_class * me, const char *path, int mode);
int (*chown) (struct vfs_class * me, const char *path, uid_t owner, gid_t group);
int (*utime) (struct vfs_class * me, const char *path, struct utimbuf * times);
int (*chmod) (const vfs_path_t * vpath, int mode);
int (*chown) (const vfs_path_t * vpath, uid_t owner, gid_t group);
int (*utime) (const vfs_path_t * vpath, struct utimbuf * times);
int (*readlink) (struct vfs_class * me, const char *path, char *buf, size_t size);
int (*symlink) (struct vfs_class * me, const char *n1, const char *n2);

View File

@ -1168,10 +1168,9 @@ extfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size)
/* --------------------------------------------------------------------------------------------- */
static int
extfs_chown (struct vfs_class *me, const char *path, uid_t owner, gid_t group)
extfs_chown (const vfs_path_t * vpath, uid_t owner, gid_t group)
{
(void) me;
(void) path;
(void) vpath;
(void) owner;
(void) group;
return 0;
@ -1180,10 +1179,9 @@ extfs_chown (struct vfs_class *me, const char *path, uid_t owner, gid_t group)
/* --------------------------------------------------------------------------------------------- */
static int
extfs_chmod (struct vfs_class *me, const char *path, int mode)
extfs_chmod (const vfs_path_t * vpath, int mode)
{
(void) me;
(void) path;
(void) vpath;
(void) mode;
return 0;
}

View File

@ -1261,24 +1261,39 @@ fish_symlink (struct vfs_class *me, const char *setto, const char *path)
/* --------------------------------------------------------------------------------------------- */
static int
fish_chmod (struct vfs_class *me, const char *path, int mode)
fish_chmod (const vfs_path_t * vpath, int mode)
{
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 FISH_FILEMODE=%4.4o;\n",
SUP->scr_chmod, (char *) NULL);
g_snprintf (buf, sizeof (buf), shell_commands, rpath, mode & 07777);
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);
}
/* --------------------------------------------------------------------------------------------- */
static int
fish_chown (struct vfs_class *me, const char *path, uid_t owner, gid_t group)
fish_chown (const vfs_path_t * vpath, uid_t owner, gid_t group)
{
char *sowner, *sgroup;
struct passwd *pw;
@ -1297,19 +1312,35 @@ fish_chown (struct vfs_class *me, const char *path, uid_t owner, gid_t group)
{
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 FISH_FILEOWNER=%s FISH_FILEGROUP=%s;\n",
SUP->scr_chown, (char *) NULL);
g_snprintf (buf, sizeof (buf), shell_commands, rpath, sowner, sgroup);
g_free (shell_commands);
fish_send_command (me, super, buf, OPT_FLUSH);
fish_send_command (path_element->class, super, buf, OPT_FLUSH);
/* FIXME: what should we report if chgrp succeeds but chown fails? */
/* fish_send_command(me, super, buf, OPT_FLUSH); */
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

@ -1974,14 +1974,17 @@ ftpfs_send_command (struct vfs_class *me, const char *filename, const char *cmd,
/* --------------------------------------------------------------------------------------------- */
static int
ftpfs_chmod (struct vfs_class *me, const char *path, int mode)
ftpfs_chmod (const vfs_path_t * vpath, int mode)
{
char buf[BUF_SMALL];
int ret;
vfs_path_element_t *path_element;
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
g_snprintf (buf, sizeof (buf), "SITE CHMOD %4.4o /%%s", mode & 07777);
ret = ftpfs_send_command (me, path, buf, OPT_FLUSH);
ret = ftpfs_send_command (path_element->class, vpath->unparsed, buf, OPT_FLUSH);
return ftpfs_ignore_chattr_errors ? 0 : ret;
}
@ -1989,16 +1992,19 @@ ftpfs_chmod (struct vfs_class *me, const char *path, int mode)
/* --------------------------------------------------------------------------------------------- */
static int
ftpfs_chown (struct vfs_class *me, const char *path, uid_t owner, gid_t group)
ftpfs_chown (const vfs_path_t * vpath, uid_t owner, gid_t group)
{
#if 0
(void) vpath;
(void) owner;
(void) group;
ftpfs_errno = EPERM;
return -1;
#else
/* Everyone knows it is not possible to chown remotely, so why bother them.
If someone's root, then copy/move will always try to chown it... */
(void) me;
(void) path;
(void) vpath;
(void) owner;
(void) group;
return 0;

View File

@ -141,31 +141,25 @@ local_lstat (struct vfs_class *me, const char *path, struct stat *buf)
/* --------------------------------------------------------------------------------------------- */
static int
local_chmod (struct vfs_class *me, const char *path, int mode)
local_chmod (const vfs_path_t * vpath, int mode)
{
(void) me;
return chmod (path, mode);
return chmod (vpath->unparsed, mode);
}
/* --------------------------------------------------------------------------------------------- */
static int
local_chown (struct vfs_class *me, const char *path, uid_t owner, gid_t group)
local_chown (const vfs_path_t * vpath, uid_t owner, gid_t group)
{
(void) me;
return chown (path, owner, group);
return chown (vpath->unparsed, owner, group);
}
/* --------------------------------------------------------------------------------------------- */
static int
local_utime (struct vfs_class *me, const char *path, struct utimbuf *times)
local_utime (const vfs_path_t * vpath, struct utimbuf *times)
{
(void) me;
return utime (path, times);
return utime (vpath->unparsed, times);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -294,27 +294,42 @@ sfs_lstat (struct vfs_class *me, const char *path, struct stat *buf)
/* --------------------------------------------------------------------------------------------- */
static int
sfs_chmod (struct vfs_class *me, const char *path, int mode)
sfs_chmod (const vfs_path_t * vpath, int mode)
{
path = sfs_redirect (me, path);
const char *path;
vfs_path_element_t *path_element;
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
path = sfs_redirect (path_element->class, vpath->unparsed);
return chmod (path, mode);
}
/* --------------------------------------------------------------------------------------------- */
static int
sfs_chown (struct vfs_class *me, const char *path, uid_t owner, gid_t group)
sfs_chown (const vfs_path_t * vpath, uid_t owner, gid_t group)
{
path = sfs_redirect (me, path);
const char *path;
vfs_path_element_t *path_element;
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
path = sfs_redirect (path_element->class, vpath->unparsed);
return chown (path, owner, group);
}
/* --------------------------------------------------------------------------------------------- */
static int
sfs_utime (struct vfs_class *me, const char *path, struct utimbuf *times)
sfs_utime (const vfs_path_t * vpath, struct utimbuf *times)
{
path = sfs_redirect (me, path);
const char *path;
vfs_path_element_t *path_element;
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
path = sfs_redirect (path_element->class, vpath->unparsed);
return utime (path, times);
}

View File

@ -964,11 +964,9 @@ smbfs_closedir (void *info)
/* --------------------------------------------------------------------------------------------- */
static int
smbfs_chmod (struct vfs_class *me, const char *path, int mode)
smbfs_chmod (const vfs_path_t * vpath, int mode)
{
(void) me;
DEBUG (3, ("smbfs_chmod(path:%s, mode:%d)\n", path, mode));
DEBUG (3, ("smbfs_chmod(path:%s, mode:%d)\n", vpath->unparsed, mode));
/* my_errno = EOPNOTSUPP;
return -1; *//* cannot chmod on smb filesystem */
return 0; /* make mc happy */
@ -977,11 +975,9 @@ smbfs_chmod (struct vfs_class *me, const char *path, int mode)
/* --------------------------------------------------------------------------------------------- */
static int
smbfs_chown (struct vfs_class *me, const char *path, uid_t owner, gid_t group)
smbfs_chown (const vfs_path_t * vpath, uid_t owner, gid_t group)
{
(void) me;
DEBUG (3, ("smbfs_chown(path:%s, owner:%d, group:%d)\n", path, owner, group));
DEBUG (3, ("smbfs_chown(path:%s, owner:%d, group:%d)\n", vpath->unparsed, owner, group));
my_errno = EOPNOTSUPP; /* ready for your labotomy? */
return -1;
}
@ -989,12 +985,11 @@ smbfs_chown (struct vfs_class *me, const char *path, uid_t owner, gid_t group)
/* --------------------------------------------------------------------------------------------- */
static int
smbfs_utime (struct vfs_class *me, const char *path, struct utimbuf *times)
smbfs_utime (const vfs_path_t * vpath, struct utimbuf *times)
{
(void) me;
(void) times;
DEBUG (3, ("smbfs_utime(path:%s)\n", path));
DEBUG (3, ("smbfs_utime(path:%s)\n", vpath->unparsed));
my_errno = EOPNOTSUPP;
return -1;
}