From dd19ca201df2bc15d0270a39966bd6f55130461e Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Wed, 20 Apr 2011 12:03:56 +0300 Subject: [PATCH] Following prototypes of functions was changed in VFS-module API: * chmod * chown * utime Signed-off-by: Slava Zanko --- lib/vfs/interface.c | 6 +++--- lib/vfs/vfs.h | 6 +++--- src/vfs/extfs/extfs.c | 10 ++++------ src/vfs/fish/fish.c | 45 ++++++++++++++++++++++++++++++++++++------- src/vfs/ftpfs/ftpfs.c | 16 ++++++++++----- src/vfs/local/local.c | 18 ++++++----------- src/vfs/sfs/sfs.c | 27 ++++++++++++++++++++------ src/vfs/smbfs/smbfs.c | 17 ++++++---------- 8 files changed, 92 insertions(+), 53 deletions(-) diff --git a/lib/vfs/interface.c b/lib/vfs/interface.c index b56f31618..76767c790 100644 --- a/lib/vfs/interface.c +++ b/lib/vfs/interface.c @@ -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)) diff --git a/lib/vfs/vfs.h b/lib/vfs/vfs.h index 6f8f98104..623de0eed 100644 --- a/lib/vfs/vfs.h +++ b/lib/vfs/vfs.h @@ -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); diff --git a/src/vfs/extfs/extfs.c b/src/vfs/extfs/extfs.c index 6a2ae2dc2..702eeb1b1 100644 --- a/src/vfs/extfs/extfs.c +++ b/src/vfs/extfs/extfs.c @@ -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; } diff --git a/src/vfs/fish/fish.c b/src/vfs/fish/fish.c index 7c636ccb2..1045225cf 100644 --- a/src/vfs/fish/fish.c +++ b/src/vfs/fish/fish.c @@ -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); } } diff --git a/src/vfs/ftpfs/ftpfs.c b/src/vfs/ftpfs/ftpfs.c index ffc0e1b6b..aa021427f 100644 --- a/src/vfs/ftpfs/ftpfs.c +++ b/src/vfs/ftpfs/ftpfs.c @@ -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; diff --git a/src/vfs/local/local.c b/src/vfs/local/local.c index f41246f5a..7270c2640 100644 --- a/src/vfs/local/local.c +++ b/src/vfs/local/local.c @@ -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); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/vfs/sfs/sfs.c b/src/vfs/sfs/sfs.c index 1b1b83c86..1884a1177 100644 --- a/src/vfs/sfs/sfs.c +++ b/src/vfs/sfs/sfs.c @@ -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); } diff --git a/src/vfs/smbfs/smbfs.c b/src/vfs/smbfs/smbfs.c index cacbe630a..6a61e80c1 100644 --- a/src/vfs/smbfs/smbfs.c +++ b/src/vfs/smbfs/smbfs.c @@ -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; }