mirror of
https://github.com/MidnightCommander/mc
synced 2025-02-22 18:24:23 +03:00
Following prototypes of functions was changed in VFS-module API:
* open * getlocalcopy * ungetlocalcopy Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
41f2e27f8d
commit
479902f83e
@ -763,12 +763,12 @@ vfs_s_ferrno (struct vfs_class *me)
|
||||
*/
|
||||
|
||||
static char *
|
||||
vfs_s_getlocalcopy (struct vfs_class *me, const char *path)
|
||||
vfs_s_getlocalcopy (const vfs_path_t * vpath)
|
||||
{
|
||||
vfs_file_handler_t *fh;
|
||||
char *local = NULL;
|
||||
|
||||
fh = vfs_s_open (me, path, O_RDONLY, 0);
|
||||
fh = vfs_s_open (vpath, O_RDONLY, 0);
|
||||
|
||||
if (fh != NULL)
|
||||
{
|
||||
@ -788,10 +788,9 @@ vfs_s_getlocalcopy (struct vfs_class *me, const char *path)
|
||||
*/
|
||||
|
||||
static int
|
||||
vfs_s_ungetlocalcopy (struct vfs_class *me, const char *path, const char *local, int has_changed)
|
||||
vfs_s_ungetlocalcopy (const vfs_path_t * vpath, const char *local, int has_changed)
|
||||
{
|
||||
(void) me;
|
||||
(void) path;
|
||||
(void) vpath;
|
||||
(void) local;
|
||||
(void) has_changed;
|
||||
return 0;
|
||||
@ -1138,22 +1137,26 @@ vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino)
|
||||
/* --------------------------- stat and friends ---------------------------- */
|
||||
|
||||
void *
|
||||
vfs_s_open (struct vfs_class *me, const char *file, int flags, mode_t mode)
|
||||
vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
||||
{
|
||||
int was_changed = 0;
|
||||
vfs_file_handler_t *fh;
|
||||
struct vfs_s_super *super;
|
||||
char *q;
|
||||
struct vfs_s_inode *ino;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
q = vfs_s_get_path (me, file, &super, 0);
|
||||
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
|
||||
|
||||
q = vfs_s_get_path (path_element->class, vpath->unparsed, &super, 0);
|
||||
if (q == NULL)
|
||||
return NULL;
|
||||
ino = vfs_s_find_inode (me, super, q, LINK_FOLLOW, FL_NONE);
|
||||
ino = vfs_s_find_inode (path_element->class, super, q, LINK_FOLLOW, FL_NONE);
|
||||
if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)))
|
||||
{
|
||||
g_free (q);
|
||||
ERRNOR (EEXIST, NULL);
|
||||
path_element->class->verrno = EEXIST;
|
||||
return NULL;
|
||||
}
|
||||
if (!ino)
|
||||
{
|
||||
@ -1163,14 +1166,14 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, mode_t mode)
|
||||
int tmp_handle;
|
||||
|
||||
/* If the filesystem is read-only, disable file creation */
|
||||
if (!(flags & O_CREAT) || !(me->write))
|
||||
if (!(flags & O_CREAT) || !(path_element->class->write))
|
||||
{
|
||||
g_free (q);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
split_dir_name (me, q, &dirname, &name, &save);
|
||||
dir = vfs_s_find_inode (me, super, dirname, LINK_FOLLOW, FL_DIR);
|
||||
split_dir_name (path_element->class, q, &dirname, &name, &save);
|
||||
dir = vfs_s_find_inode (path_element->class, super, dirname, LINK_FOLLOW, FL_DIR);
|
||||
if (dir == NULL)
|
||||
{
|
||||
g_free (q);
|
||||
@ -1178,10 +1181,10 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, mode_t mode)
|
||||
}
|
||||
if (save)
|
||||
*save = PATH_SEP;
|
||||
ent = vfs_s_generate_entry (me, name, dir, 0755);
|
||||
ent = vfs_s_generate_entry (path_element->class, name, dir, 0755);
|
||||
ino = ent->ino;
|
||||
vfs_s_insert_entry (me, dir, ent);
|
||||
tmp_handle = vfs_mkstemps (&ino->localname, me->name, name);
|
||||
vfs_s_insert_entry (path_element->class, dir, ent);
|
||||
tmp_handle = vfs_mkstemps (&ino->localname, path_element->class->name, name);
|
||||
if (tmp_handle == -1)
|
||||
{
|
||||
g_free (q);
|
||||
@ -1194,7 +1197,10 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, mode_t mode)
|
||||
g_free (q);
|
||||
|
||||
if (S_ISDIR (ino->st.st_mode))
|
||||
ERRNOR (EISDIR, NULL);
|
||||
{
|
||||
path_element->class->verrno = EISDIR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fh = g_new (vfs_file_handler_t, 1);
|
||||
fh->pos = 0;
|
||||
@ -1206,13 +1212,14 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, mode_t mode)
|
||||
|
||||
if (IS_LINEAR (flags))
|
||||
{
|
||||
if (MEDATA->linear_start)
|
||||
if (VFSDATA (path_element)->linear_start)
|
||||
{
|
||||
vfs_print_message (_("Starting linear transfer..."));
|
||||
fh->linear = LS_LINEAR_PREOPEN;
|
||||
}
|
||||
}
|
||||
else if ((MEDATA->fh_open != NULL) && (MEDATA->fh_open (me, fh, flags, mode) != 0))
|
||||
else if ((VFSDATA (path_element)->fh_open != NULL)
|
||||
&& (VFSDATA (path_element)->fh_open (path_element->class, fh, flags, mode) != 0))
|
||||
{
|
||||
g_free (fh);
|
||||
return NULL;
|
||||
@ -1224,12 +1231,13 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, mode_t mode)
|
||||
if (fh->handle == -1)
|
||||
{
|
||||
g_free (fh);
|
||||
ERRNOR (errno, NULL);
|
||||
path_element->class->verrno = errno;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* i.e. we had no open files and now we have one */
|
||||
vfs_rmstamp (me, (vfsid) super);
|
||||
vfs_rmstamp (path_element->class, (vfsid) super);
|
||||
super->fd_usage++;
|
||||
fh->ino->st.st_nlink++;
|
||||
return fh;
|
||||
|
@ -207,7 +207,7 @@ mc_open (const char *filename, int flags, ...)
|
||||
{
|
||||
void *info;
|
||||
/* open must be supported */
|
||||
info = path_element->class->open (path_element->class, vpath->unparsed, flags, mode);
|
||||
info = path_element->class->open (vpath, flags, mode);
|
||||
if (info == NULL)
|
||||
errno = vfs_ferrno (path_element->class);
|
||||
else
|
||||
@ -296,8 +296,7 @@ mc_symlink (const char *name1, const char *path)
|
||||
{
|
||||
result =
|
||||
path_element->class->symlink !=
|
||||
NULL ? path_element->class->symlink (path_element->class, lpath,
|
||||
vpath->unparsed) : -1;
|
||||
NULL ? path_element->class->symlink (path_element->class, lpath, vpath->unparsed) : -1;
|
||||
if (result == -1)
|
||||
errno =
|
||||
path_element->class->symlink != NULL ? vfs_ferrno (path_element->class) : E_NOTSUPP;
|
||||
@ -618,8 +617,7 @@ mc_lstat (const char *filename, struct stat *buf)
|
||||
{
|
||||
result =
|
||||
path_element->class->lstat ? (*path_element->class->lstat) (path_element->class,
|
||||
vpath->unparsed,
|
||||
buf) : -1;
|
||||
vpath->unparsed, buf) : -1;
|
||||
if (result == -1)
|
||||
errno = path_element->class->name ? vfs_ferrno (path_element->class) : E_NOTSUPP;
|
||||
}
|
||||
@ -681,8 +679,7 @@ mc_getlocalcopy (const char *pathname)
|
||||
if (path_element != NULL)
|
||||
{
|
||||
result = path_element->class->getlocalcopy != NULL ?
|
||||
path_element->class->getlocalcopy (path_element->class,
|
||||
vpath->unparsed) : mc_def_getlocalcopy (vpath->unparsed);
|
||||
path_element->class->getlocalcopy (vpath) : mc_def_getlocalcopy (vpath->unparsed);
|
||||
if (result == NULL)
|
||||
errno = vfs_ferrno (path_element->class);
|
||||
}
|
||||
@ -707,7 +704,7 @@ mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed)
|
||||
if (path_element != NULL)
|
||||
{
|
||||
return_value = path_element->class->ungetlocalcopy != NULL ?
|
||||
path_element->class->ungetlocalcopy (path_element->class, vpath->unparsed, local,
|
||||
path_element->class->ungetlocalcopy (vpath, local,
|
||||
has_changed) :
|
||||
mc_def_ungetlocalcopy (path_element->class, vpath->unparsed, local, has_changed);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "lib/fs.h" /* MC_MAXPATHLEN */
|
||||
|
||||
#include "interface.h"
|
||||
#include "path.h"
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
@ -150,7 +151,7 @@ typedef struct vfs_class
|
||||
*/
|
||||
int (*which) (struct vfs_class * me, const char *path);
|
||||
|
||||
void *(*open) (struct vfs_class * me, const char *fname, int flags, mode_t mode);
|
||||
void *(*open) (const vfs_path_t * vpath, int flags, mode_t mode);
|
||||
int (*close) (void *vfs_info);
|
||||
ssize_t (*read) (void *vfs_info, char *buffer, size_t count);
|
||||
ssize_t (*write) (void *vfs_info, const char *buf, size_t count);
|
||||
@ -182,9 +183,8 @@ typedef struct vfs_class
|
||||
int (*nothingisopen) (vfsid id);
|
||||
void (*free) (vfsid id);
|
||||
|
||||
char *(*getlocalcopy) (struct vfs_class * me, const char *filename);
|
||||
int (*ungetlocalcopy) (struct vfs_class * me, const char *filename,
|
||||
const char *local, int has_changed);
|
||||
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);
|
||||
@ -214,7 +214,7 @@ extern int use_netrc;
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
/* lib/vfs/direntry.c: */
|
||||
void *vfs_s_open (struct vfs_class *me, const char *file, int flags, mode_t mode);
|
||||
void *vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode);
|
||||
|
||||
vfsid vfs_getid (struct vfs_class *vclass, const char *dir);
|
||||
|
||||
@ -268,7 +268,7 @@ int vfs_ferrno (struct vfs_class *vfs);
|
||||
|
||||
int vfs_new_handle (struct vfs_class *vclass, void *fsinfo);
|
||||
|
||||
struct vfs_class * vfs_class_find_by_handle (int handle);
|
||||
struct vfs_class *vfs_class_find_by_handle (int handle);
|
||||
|
||||
void *vfs_class_data_find_by_handle (int handle);
|
||||
|
||||
|
@ -39,6 +39,8 @@
|
||||
|
||||
#define MEDATA ((struct vfs_s_subclass *) me->data)
|
||||
|
||||
#define VFSDATA(a) ((struct vfs_s_subclass *) a->class->data)
|
||||
|
||||
#define FH ((vfs_file_handler_t *) fh)
|
||||
#define FH_SUPER FH->ino->super
|
||||
|
||||
|
@ -857,7 +857,7 @@ extfs_run (struct vfs_class *me, const char *file)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void *
|
||||
extfs_open (struct vfs_class *me, const char *file, int flags, mode_t mode)
|
||||
extfs_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
||||
{
|
||||
struct pseudofile *extfs_info;
|
||||
struct archive *archive = NULL;
|
||||
@ -865,8 +865,9 @@ extfs_open (struct vfs_class *me, const char *file, int flags, mode_t mode)
|
||||
struct entry *entry;
|
||||
int local_handle;
|
||||
gboolean created = FALSE;
|
||||
vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
|
||||
|
||||
q = extfs_get_path (me, file, &archive, FALSE);
|
||||
q = extfs_get_path (path_element->class, vpath->unparsed, &archive, FALSE);
|
||||
if (q == NULL)
|
||||
return NULL;
|
||||
entry = extfs_find_entry (archive->root_entry, q, FALSE, FALSE);
|
||||
@ -1481,12 +1482,12 @@ extfs_free (vfsid id)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static char *
|
||||
extfs_getlocalcopy (struct vfs_class *me, const char *path)
|
||||
extfs_getlocalcopy (const vfs_path_t * vpath)
|
||||
{
|
||||
struct pseudofile *fp;
|
||||
char *p;
|
||||
|
||||
fp = (struct pseudofile *) extfs_open (me, path, O_RDONLY, 0);
|
||||
fp = (struct pseudofile *) extfs_open (vpath, O_RDONLY, 0);
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
if (fp->entry->inode->local_filename == NULL)
|
||||
@ -1503,11 +1504,11 @@ extfs_getlocalcopy (struct vfs_class *me, const char *path)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
extfs_ungetlocalcopy (struct vfs_class *me, const char *path, const char *local, int has_changed)
|
||||
extfs_ungetlocalcopy (const vfs_path_t * vpath, const char *local, int has_changed)
|
||||
{
|
||||
struct pseudofile *fp;
|
||||
|
||||
fp = (struct pseudofile *) extfs_open (me, path, O_RDONLY, 0);
|
||||
fp = (struct pseudofile *) extfs_open (vpath, O_RDONLY, 0);
|
||||
if (fp == NULL)
|
||||
return 0;
|
||||
|
||||
|
@ -1483,14 +1483,14 @@ fish_fill_names (struct vfs_class *me, fill_names_f func)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void *
|
||||
fish_open (struct vfs_class *me, const char *file, int flags, mode_t mode)
|
||||
fish_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
||||
{
|
||||
/*
|
||||
sorry, i've places hack here
|
||||
cause fish don't able to open files with O_EXCL flag
|
||||
*/
|
||||
flags &= ~O_EXCL;
|
||||
return vfs_s_open (me, file, flags, mode);
|
||||
return vfs_s_open (vpath, flags, mode);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -59,14 +59,12 @@ static struct vfs_class vfs_local_ops;
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void *
|
||||
local_open (struct vfs_class *me, const char *file, int flags, mode_t mode)
|
||||
local_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
||||
{
|
||||
int *local_info;
|
||||
int fd;
|
||||
|
||||
(void) me;
|
||||
|
||||
fd = open (file, NO_LINEAR (flags), mode);
|
||||
fd = open (vpath->unparsed, NO_LINEAR (flags), mode);
|
||||
if (fd == -1)
|
||||
return 0;
|
||||
|
||||
@ -290,20 +288,17 @@ local_rmdir (struct vfs_class *me, const char *path)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static char *
|
||||
local_getlocalcopy (struct vfs_class *me, const char *path)
|
||||
local_getlocalcopy (const vfs_path_t * vpath)
|
||||
{
|
||||
(void) me;
|
||||
|
||||
return g_strdup (path);
|
||||
return g_strdup (vpath->unparsed);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
local_ungetlocalcopy (struct vfs_class *me, const char *path, const char *local, int has_changed)
|
||||
local_ungetlocalcopy (const vfs_path_t * vpath, const char *local, int has_changed)
|
||||
{
|
||||
(void) me;
|
||||
(void) path;
|
||||
(void) vpath;
|
||||
(void) local;
|
||||
(void) has_changed;
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
||||
#include "lib/vfs/vfs.h"
|
||||
#include "lib/vfs/utilvfs.h"
|
||||
#include "src/vfs/local/local.h"
|
||||
#include "lib/vfs/gc.h" /* vfs_stamp_create */
|
||||
#include "lib/vfs/gc.h" /* vfs_stamp_create */
|
||||
|
||||
#include "sfs.h"
|
||||
|
||||
@ -218,10 +218,10 @@ sfs_redirect (struct vfs_class *me, const char *name)
|
||||
cur = g_slist_find_custom (head, name, cachedfile_compare);
|
||||
if (cur != NULL)
|
||||
{
|
||||
cf = (cachedfile *) cur->data;
|
||||
vfs_stamp (&vfs_sfs_ops, cf);
|
||||
return cf->cache;
|
||||
}
|
||||
cf = (cachedfile *) cur->data;
|
||||
vfs_stamp (&vfs_sfs_ops, cf);
|
||||
return cf->cache;
|
||||
}
|
||||
|
||||
handle = vfs_mkstemps (&cache, "sfs", name);
|
||||
|
||||
@ -249,12 +249,16 @@ sfs_redirect (struct vfs_class *me, const char *name)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void *
|
||||
sfs_open (struct vfs_class *me, const char *path, int flags, mode_t mode)
|
||||
sfs_open (const vfs_path_t * vpath /*struct vfs_class *me, const char *path */ , int flags,
|
||||
mode_t mode)
|
||||
{
|
||||
int *sfs_info;
|
||||
int fd;
|
||||
const char *path;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
path = sfs_redirect (me, path);
|
||||
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
|
||||
path = sfs_redirect (path_element->class, vpath->unparsed);
|
||||
fd = open (path, NO_LINEAR (flags), mode);
|
||||
if (fd == -1)
|
||||
return 0;
|
||||
@ -348,7 +352,7 @@ sfs_free (vfsid id)
|
||||
which = (struct cachedfile *) id;
|
||||
cur = g_slist_find (head, which);
|
||||
if (cur == NULL)
|
||||
vfs_die ("Free of thing which is unknown to me\n");
|
||||
vfs_die ("Free of thing which is unknown to me\n");
|
||||
|
||||
which = (struct cachedfile *) cur->data;
|
||||
unlink (which->cache);
|
||||
@ -386,19 +390,22 @@ sfs_nothingisopen (vfsid id)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static char *
|
||||
sfs_getlocalcopy (struct vfs_class *me, const char *path)
|
||||
sfs_getlocalcopy (const vfs_path_t * vpath)
|
||||
{
|
||||
path = sfs_redirect (me, path);
|
||||
vfs_path_element_t *path_element;
|
||||
const char *path;
|
||||
|
||||
path_element = vfs_path_get_by_index (vpath, vfs_path_length (vpath) - 1);
|
||||
path = sfs_redirect (path_element->class, vpath->unparsed);
|
||||
return g_strdup (path);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
sfs_ungetlocalcopy (struct vfs_class *me, const char *path, const char *local, int has_changed)
|
||||
sfs_ungetlocalcopy (const vfs_path_t * vpath, const char *local, int has_changed)
|
||||
{
|
||||
(void) me;
|
||||
(void) path;
|
||||
(void) vpath;
|
||||
(void) local;
|
||||
(void) has_changed;
|
||||
return 0;
|
||||
|
@ -2054,18 +2054,16 @@ smbfs_open_readwrite (smbfs_handle * remote_handle, char *rname, int flags, mode
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void *
|
||||
smbfs_open (struct vfs_class *me, const char *file, int flags, mode_t mode)
|
||||
smbfs_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
||||
{
|
||||
char *remote_file;
|
||||
void *ret;
|
||||
smbfs_connection *sc;
|
||||
smbfs_handle *remote_handle;
|
||||
|
||||
(void) me;
|
||||
DEBUG (3, ("smbfs_open(file:%s, flags:%d, mode:%o)\n", vpath->unparsed, flags, mode));
|
||||
|
||||
DEBUG (3, ("smbfs_open(file:%s, flags:%d, mode:%o)\n", file, flags, mode));
|
||||
|
||||
if (!(remote_file = smbfs_get_path (&sc, file)))
|
||||
if (!(remote_file = smbfs_get_path (&sc, vpath->unparsed)))
|
||||
return 0;
|
||||
|
||||
remote_file = free_after (smbfs_convert_path (remote_file, FALSE), remote_file);
|
||||
|
@ -423,17 +423,16 @@ undelfs_closedir (void *vfs_info)
|
||||
/* We do not support lseek */
|
||||
|
||||
static void *
|
||||
undelfs_open (struct vfs_class *me, const char *fname, int flags, mode_t mode)
|
||||
undelfs_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
||||
{
|
||||
char *file, *f;
|
||||
ext2_ino_t inode, i;
|
||||
undelfs_file *p = NULL;
|
||||
(void) me;
|
||||
(void) flags;
|
||||
(void) mode;
|
||||
|
||||
/* Only allow reads on this file system */
|
||||
undelfs_get_path (fname, &file, &f);
|
||||
undelfs_get_path (vpath->unparsed, &file, &f);
|
||||
if (!file)
|
||||
return 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user