mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
VFS: make vfs_file_handler related macros more readable.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
6d21416672
commit
533cbbd971
@ -561,25 +561,26 @@ vfs_s_readlink (const vfs_path_t * vpath, char *buf, size_t size)
|
||||
static ssize_t
|
||||
vfs_s_read (void *fh, char *buffer, size_t count)
|
||||
{
|
||||
struct vfs_class *me = FH_SUPER->me;
|
||||
vfs_file_handler_t *file = VFS_FILE_HANDLER (fh);
|
||||
struct vfs_class *me = VFS_FILE_HANDLER_SUPER (fh)->me;
|
||||
|
||||
if (FH->linear == LS_LINEAR_PREOPEN)
|
||||
if (file->linear == LS_LINEAR_PREOPEN)
|
||||
{
|
||||
if (VFS_SUBCLASS (me)->linear_start (me, FH, FH->pos) == 0)
|
||||
if (VFS_SUBCLASS (me)->linear_start (me, file, file->pos) == 0)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (FH->linear == LS_LINEAR_CLOSED)
|
||||
if (file->linear == LS_LINEAR_CLOSED)
|
||||
vfs_die ("linear_start() did not set linear_state!");
|
||||
|
||||
if (FH->linear == LS_LINEAR_OPEN)
|
||||
return VFS_SUBCLASS (me)->linear_read (me, FH, buffer, count);
|
||||
if (file->linear == LS_LINEAR_OPEN)
|
||||
return VFS_SUBCLASS (me)->linear_read (me, file, buffer, count);
|
||||
|
||||
if (FH->handle != -1)
|
||||
if (file->handle != -1)
|
||||
{
|
||||
ssize_t n;
|
||||
|
||||
n = read (FH->handle, buffer, count);
|
||||
n = read (file->handle, buffer, count);
|
||||
if (n < 0)
|
||||
me->verrno = errno;
|
||||
return n;
|
||||
@ -593,17 +594,18 @@ vfs_s_read (void *fh, char *buffer, size_t count)
|
||||
static ssize_t
|
||||
vfs_s_write (void *fh, const char *buffer, size_t count)
|
||||
{
|
||||
struct vfs_class *me = FH_SUPER->me;
|
||||
vfs_file_handler_t *file = VFS_FILE_HANDLER (fh);
|
||||
struct vfs_class *me = VFS_FILE_HANDLER_SUPER (fh)->me;
|
||||
|
||||
if (FH->linear != LS_NOT_LINEAR)
|
||||
if (file->linear != LS_NOT_LINEAR)
|
||||
vfs_die ("no writing to linear files, please");
|
||||
|
||||
FH->changed = TRUE;
|
||||
if (FH->handle != -1)
|
||||
file->changed = TRUE;
|
||||
if (file->handle != -1)
|
||||
{
|
||||
ssize_t n;
|
||||
|
||||
n = write (FH->handle, buffer, count);
|
||||
n = write (file->handle, buffer, count);
|
||||
if (n < 0)
|
||||
me->verrno = errno;
|
||||
return n;
|
||||
@ -617,25 +619,26 @@ vfs_s_write (void *fh, const char *buffer, size_t count)
|
||||
static off_t
|
||||
vfs_s_lseek (void *fh, off_t offset, int whence)
|
||||
{
|
||||
off_t size = FH->ino->st.st_size;
|
||||
vfs_file_handler_t *file = VFS_FILE_HANDLER (fh);
|
||||
off_t size = file->ino->st.st_size;
|
||||
|
||||
if (FH->linear == LS_LINEAR_OPEN)
|
||||
if (file->linear == LS_LINEAR_OPEN)
|
||||
vfs_die ("cannot lseek() after linear_read!");
|
||||
|
||||
if (FH->handle != -1)
|
||||
if (file->handle != -1)
|
||||
{ /* If we have local file opened, we want to work with it */
|
||||
off_t retval;
|
||||
|
||||
retval = lseek (FH->handle, offset, whence);
|
||||
retval = lseek (file->handle, offset, whence);
|
||||
if (retval == -1)
|
||||
FH->ino->super->me->verrno = errno;
|
||||
VFS_FILE_HANDLER_SUPER (fh)->me->verrno = errno;
|
||||
return retval;
|
||||
}
|
||||
|
||||
switch (whence)
|
||||
{
|
||||
case SEEK_CUR:
|
||||
offset += FH->pos;
|
||||
offset += file->pos;
|
||||
break;
|
||||
case SEEK_END:
|
||||
offset += size;
|
||||
@ -644,12 +647,12 @@ vfs_s_lseek (void *fh, off_t offset, int whence)
|
||||
break;
|
||||
}
|
||||
if (offset < 0)
|
||||
FH->pos = 0;
|
||||
file->pos = 0;
|
||||
else if (offset < size)
|
||||
FH->pos = offset;
|
||||
file->pos = offset;
|
||||
else
|
||||
FH->pos = size;
|
||||
return FH->pos;
|
||||
file->pos = size;
|
||||
return file->pos;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -657,40 +660,42 @@ vfs_s_lseek (void *fh, off_t offset, int whence)
|
||||
static int
|
||||
vfs_s_close (void *fh)
|
||||
{
|
||||
int res = 0;
|
||||
struct vfs_class *me = FH_SUPER->me;
|
||||
vfs_file_handler_t *file = VFS_FILE_HANDLER (fh);
|
||||
struct vfs_s_super *super = VFS_FILE_HANDLER_SUPER (fh);
|
||||
struct vfs_class *me = super->me;
|
||||
struct vfs_s_subclass *sub = VFS_SUBCLASS (me);
|
||||
int res = 0;
|
||||
|
||||
if (me == NULL)
|
||||
return (-1);
|
||||
|
||||
FH_SUPER->fd_usage--;
|
||||
if (FH_SUPER->fd_usage == 0)
|
||||
vfs_stamp_create (me, FH_SUPER);
|
||||
super->fd_usage--;
|
||||
if (super->fd_usage == 0)
|
||||
vfs_stamp_create (me, VFS_FILE_HANDLER_SUPER (fh));
|
||||
|
||||
if (FH->linear == LS_LINEAR_OPEN)
|
||||
if (file->linear == LS_LINEAR_OPEN)
|
||||
sub->linear_close (me, fh);
|
||||
if (sub->fh_close != NULL)
|
||||
res = sub->fh_close (me, fh);
|
||||
if ((me->flags & VFS_USETMP) != 0 && FH->changed && sub->file_store != NULL)
|
||||
if ((me->flags & VFS_USETMP) != 0 && file->changed && sub->file_store != NULL)
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = vfs_s_fullpath (me, FH->ino);
|
||||
s = vfs_s_fullpath (me, file->ino);
|
||||
|
||||
if (s == NULL)
|
||||
res = -1;
|
||||
else
|
||||
{
|
||||
res = sub->file_store (me, fh, s, FH->ino->localname);
|
||||
res = sub->file_store (me, fh, s, file->ino->localname);
|
||||
g_free (s);
|
||||
}
|
||||
vfs_s_invalidate (me, FH_SUPER);
|
||||
vfs_s_invalidate (me, super);
|
||||
}
|
||||
if (FH->handle != -1)
|
||||
close (FH->handle);
|
||||
if (file->handle != -1)
|
||||
close (file->handle);
|
||||
|
||||
vfs_s_free_inode (me, FH->ino);
|
||||
vfs_s_free_inode (me, file->ino);
|
||||
vfs_s_free_fh (sub, fh);
|
||||
|
||||
return res;
|
||||
@ -1403,7 +1408,7 @@ vfs_s_lstat (const vfs_path_t * vpath, struct stat *buf)
|
||||
int
|
||||
vfs_s_fstat (void *fh, struct stat *buf)
|
||||
{
|
||||
*buf = FH->ino->st;
|
||||
*buf = VFS_FILE_HANDLER (fh)->ino->st;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,8 @@
|
||||
|
||||
#define VFS_SUPER(a) ((struct vfs_s_super *) (a))
|
||||
|
||||
#define FH ((vfs_file_handler_t *) fh)
|
||||
#define FH_SUPER FH->ino->super
|
||||
#define VFS_FILE_HANDLER(a) ((vfs_file_handler_t *) a)
|
||||
#define VFS_FILE_HANDLER_SUPER(a) VFS_FILE_HANDLER (a)->ino->super
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
|
@ -848,21 +848,22 @@ cpio_super_same (const vfs_path_element_t * vpath_element, struct vfs_s_super *p
|
||||
static ssize_t
|
||||
cpio_read (void *fh, char *buffer, size_t count)
|
||||
{
|
||||
off_t begin = FH->ino->data_offset;
|
||||
int fd = CPIO_SUPER (FH_SUPER)->fd;
|
||||
struct vfs_class *me = FH_SUPER->me;
|
||||
vfs_file_handler_t *file = VFS_FILE_HANDLER (fh);
|
||||
struct vfs_class *me = VFS_FILE_HANDLER_SUPER (fh)->me;
|
||||
int fd = CPIO_SUPER (VFS_FILE_HANDLER_SUPER (fh))->fd;
|
||||
off_t begin = file->ino->data_offset;
|
||||
ssize_t res;
|
||||
|
||||
if (mc_lseek (fd, begin + FH->pos, SEEK_SET) != begin + FH->pos)
|
||||
if (mc_lseek (fd, begin + file->pos, SEEK_SET) != begin + file->pos)
|
||||
ERRNOR (EIO, -1);
|
||||
|
||||
count = MIN (count, (size_t) (FH->ino->st.st_size - FH->pos));
|
||||
count = MIN (count, (size_t) (file->ino->st.st_size - file->pos));
|
||||
|
||||
res = mc_read (fd, buffer, count);
|
||||
if (res == -1)
|
||||
ERRNOR (errno, -1);
|
||||
|
||||
FH->pos += res;
|
||||
file->pos += res;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ int fish_directory_timeout = 900;
|
||||
#define FISH_HAVE_TAIL 64
|
||||
|
||||
#define FISH_SUPER(super) ((fish_super_t *) (super))
|
||||
#define FISH_FH ((fish_file_handler_t *) fh)
|
||||
#define FISH_FILE_HANDLER(fh) ((fish_file_handler_t *) fh)
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
@ -968,8 +968,8 @@ fish_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
static int
|
||||
fish_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, char *localname)
|
||||
{
|
||||
fish_file_handler_t *fish = FISH_FH;
|
||||
struct vfs_s_super *super = FH_SUPER;
|
||||
fish_file_handler_t *fish = FISH_FILE_HANDLER (fh);
|
||||
struct vfs_s_super *super = VFS_FILE_HANDLER_SUPER (fh);
|
||||
fish_super_t *fish_super = FISH_SUPER (super);
|
||||
int code;
|
||||
off_t total = 0;
|
||||
@ -1080,8 +1080,8 @@ fish_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, char
|
||||
static int
|
||||
fish_linear_start (struct vfs_class *me, vfs_file_handler_t * fh, off_t offset)
|
||||
{
|
||||
fish_file_handler_t *fish = FISH_FH;
|
||||
struct vfs_s_super *super = FH_SUPER;
|
||||
fish_file_handler_t *fish = FISH_FILE_HANDLER (fh);
|
||||
struct vfs_s_super *super = VFS_FILE_HANDLER_SUPER (fh);
|
||||
char *name;
|
||||
char *quoted_name;
|
||||
|
||||
@ -1125,8 +1125,8 @@ fish_linear_start (struct vfs_class *me, vfs_file_handler_t * fh, off_t offset)
|
||||
static void
|
||||
fish_linear_abort (struct vfs_class *me, vfs_file_handler_t * fh)
|
||||
{
|
||||
fish_file_handler_t *fish = FISH_FH;
|
||||
struct vfs_s_super *super = FH_SUPER;
|
||||
fish_file_handler_t *fish = FISH_FILE_HANDLER (fh);
|
||||
struct vfs_s_super *super = VFS_FILE_HANDLER_SUPER (fh);
|
||||
char buffer[BUF_8K];
|
||||
ssize_t n;
|
||||
|
||||
@ -1156,8 +1156,8 @@ fish_linear_abort (struct vfs_class *me, vfs_file_handler_t * fh)
|
||||
static ssize_t
|
||||
fish_linear_read (struct vfs_class *me, vfs_file_handler_t * fh, void *buf, size_t len)
|
||||
{
|
||||
fish_file_handler_t *fish = FISH_FH;
|
||||
struct vfs_s_super *super = FH_SUPER;
|
||||
fish_file_handler_t *fish = FISH_FILE_HANDLER (fh);
|
||||
struct vfs_s_super *super = VFS_FILE_HANDLER_SUPER (fh);
|
||||
ssize_t n = 0;
|
||||
|
||||
len = MIN ((size_t) (fish->total - fish->got), len);
|
||||
@ -1184,7 +1184,7 @@ fish_linear_read (struct vfs_class *me, vfs_file_handler_t * fh, void *buf, size
|
||||
static void
|
||||
fish_linear_close (struct vfs_class *me, vfs_file_handler_t * fh)
|
||||
{
|
||||
fish_file_handler_t *fish = FISH_FH;
|
||||
fish_file_handler_t *fish = FISH_FILE_HANDLER (fh);
|
||||
|
||||
if (fish->total != fish->got)
|
||||
fish_linear_abort (me, fh);
|
||||
@ -1206,14 +1206,15 @@ fish_ctl (void *fh, int ctlop, void *arg)
|
||||
{
|
||||
case VFS_CTL_IS_NOTREADY:
|
||||
{
|
||||
vfs_file_handler_t *file = VFS_FILE_HANDLER (fh);
|
||||
int v;
|
||||
|
||||
if (FH->linear == LS_NOT_LINEAR)
|
||||
if (file->linear == LS_NOT_LINEAR)
|
||||
vfs_die ("You may not do this");
|
||||
if (FH->linear == LS_LINEAR_CLOSED || FH->linear == LS_LINEAR_PREOPEN)
|
||||
if (file->linear == LS_LINEAR_CLOSED || file->linear == LS_LINEAR_PREOPEN)
|
||||
return 0;
|
||||
|
||||
v = vfs_s_select_on_two (FH_SUPER->u.fish.sockr, 0);
|
||||
v = vfs_s_select_on_two (VFS_FILE_HANDLER_SUPER (fh)->u.fish.sockr, 0);
|
||||
|
||||
return (((v < 0) && (errno == EINTR)) || v == 0) ? 1 : 0;
|
||||
}
|
||||
@ -1641,9 +1642,9 @@ fish_fh_new (struct vfs_s_inode *ino, gboolean changed)
|
||||
fish_file_handler_t *fh;
|
||||
|
||||
fh = g_new0 (fish_file_handler_t, 1);
|
||||
vfs_s_init_fh ((vfs_file_handler_t *) fh, ino, changed);
|
||||
vfs_s_init_fh (VFS_FILE_HANDLER (fh), ino, changed);
|
||||
|
||||
return FH;
|
||||
return VFS_FILE_HANDLER (fh);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1651,7 +1652,7 @@ fish_fh_new (struct vfs_s_inode *ino, gboolean changed)
|
||||
static int
|
||||
fish_fh_open (struct vfs_class *me, vfs_file_handler_t * fh, int flags, mode_t mode)
|
||||
{
|
||||
fish_file_handler_t *fish = FISH_FH;
|
||||
fish_file_handler_t *fish = FISH_FILE_HANDLER (fh);
|
||||
|
||||
(void) mode;
|
||||
|
||||
|
@ -154,8 +154,8 @@ gboolean ftpfs_ignore_chattr_errors = TRUE;
|
||||
#endif
|
||||
|
||||
#define FTP_SUPER(super) ((ftp_super_t *) (super))
|
||||
#define FTP_FH ((ftp_file_handler_t *) fh)
|
||||
#define FH_SOCK FTP_FH->sock
|
||||
#define FTP_FILE_HANDLER(fh) ((ftp_file_handler_t *) (fh))
|
||||
#define FH_SOCK FTP_FILE_HANDLER(fh)->sock
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE 0xffffffff
|
||||
@ -1468,7 +1468,7 @@ ftpfs_open_data_connection (struct vfs_class *me, struct vfs_s_super *super, con
|
||||
static void
|
||||
ftpfs_linear_abort (struct vfs_class *me, vfs_file_handler_t * fh)
|
||||
{
|
||||
struct vfs_s_super *super = FH_SUPER;
|
||||
struct vfs_s_super *super = VFS_FILE_HANDLER_SUPER (fh);
|
||||
ftp_super_t *ftp_super = FTP_SUPER (super);
|
||||
static unsigned char const ipbuf[3] = { IAC, IP, IAC };
|
||||
fd_set mask;
|
||||
@ -1856,6 +1856,10 @@ ftpfs_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path
|
||||
static int
|
||||
ftpfs_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, char *localname)
|
||||
{
|
||||
struct vfs_s_super *super = VFS_FILE_HANDLER_SUPER (fh);
|
||||
ftp_super_t *ftp_super = FTP_SUPER (super);
|
||||
ftp_file_handler_t *ftp = FTP_FILE_HANDLER (fh);
|
||||
|
||||
int h, sock;
|
||||
off_t n_stored;
|
||||
#ifdef HAVE_STRUCT_LINGER_L_LINGER
|
||||
@ -1866,9 +1870,6 @@ ftpfs_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, cha
|
||||
char lc_buffer[BUF_8K];
|
||||
struct stat s;
|
||||
char *w_buf;
|
||||
struct vfs_s_super *super = FH_SUPER;
|
||||
ftp_super_t *ftp_super = FTP_SUPER (super);
|
||||
ftp_file_handler_t *ftp = FTP_FH;
|
||||
|
||||
h = open (localname, O_RDONLY);
|
||||
if (h == -1)
|
||||
@ -1955,12 +1956,14 @@ ftpfs_linear_start (struct vfs_class *me, vfs_file_handler_t * fh, off_t offset)
|
||||
name = vfs_s_fullpath (me, fh->ino);
|
||||
if (name == NULL)
|
||||
return 0;
|
||||
FH_SOCK = ftpfs_open_data_connection (me, FH_SUPER, "RETR", name, TYPE_BINARY, offset);
|
||||
FH_SOCK =
|
||||
ftpfs_open_data_connection (me, VFS_FILE_HANDLER_SUPER (fh), "RETR", name, TYPE_BINARY,
|
||||
offset);
|
||||
g_free (name);
|
||||
if (FH_SOCK == -1)
|
||||
ERRNOR (EACCES, 0);
|
||||
fh->linear = LS_LINEAR_OPEN;
|
||||
FTP_FH->append = 0;
|
||||
FTP_FILE_HANDLER (fh)->append = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1970,7 +1973,7 @@ static ssize_t
|
||||
ftpfs_linear_read (struct vfs_class *me, vfs_file_handler_t * fh, void *buf, size_t len)
|
||||
{
|
||||
ssize_t n;
|
||||
struct vfs_s_super *super = FH_SUPER;
|
||||
struct vfs_s_super *super = VFS_FILE_HANDLER_SUPER (fh);
|
||||
|
||||
while ((n = read (FH_SOCK, buf, len)) < 0)
|
||||
{
|
||||
@ -2014,11 +2017,12 @@ ftpfs_ctl (void *fh, int ctlop, void *arg)
|
||||
{
|
||||
case VFS_CTL_IS_NOTREADY:
|
||||
{
|
||||
vfs_file_handler_t *file = VFS_FILE_HANDLER (fh);
|
||||
int v;
|
||||
|
||||
if (FH->linear == LS_NOT_LINEAR)
|
||||
if (file->linear == LS_NOT_LINEAR)
|
||||
vfs_die ("You may not do this");
|
||||
if (FH->linear == LS_LINEAR_CLOSED || FH->linear == LS_LINEAR_PREOPEN)
|
||||
if (file->linear == LS_LINEAR_CLOSED || file->linear == LS_LINEAR_PREOPEN)
|
||||
return 0;
|
||||
|
||||
v = vfs_s_select_on_two (FH_SOCK, 0);
|
||||
@ -2219,10 +2223,10 @@ ftpfs_fh_new (struct vfs_s_inode *ino, gboolean changed)
|
||||
ftp_file_handler_t *fh;
|
||||
|
||||
fh = g_new0 (ftp_file_handler_t, 1);
|
||||
vfs_s_init_fh ((vfs_file_handler_t *) fh, ino, changed);
|
||||
vfs_s_init_fh (VFS_FILE_HANDLER (fh), ino, changed);
|
||||
fh->sock = -1;
|
||||
|
||||
return FH;
|
||||
return VFS_FILE_HANDLER (fh);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -2230,7 +2234,7 @@ ftpfs_fh_new (struct vfs_s_inode *ino, gboolean changed)
|
||||
static int
|
||||
ftpfs_fh_open (struct vfs_class *me, vfs_file_handler_t * fh, int flags, mode_t mode)
|
||||
{
|
||||
ftp_file_handler_t *ftp = FTP_FH;
|
||||
ftp_file_handler_t *ftp = FTP_FILE_HANDLER (fh);
|
||||
|
||||
(void) mode;
|
||||
|
||||
@ -2248,7 +2252,7 @@ ftpfs_fh_open (struct vfs_class *me, vfs_file_handler_t * fh, int flags, mode_t
|
||||
* to local temporary file and stored to ftp server
|
||||
* by vfs_s_close later
|
||||
*/
|
||||
if (FTP_SUPER (FH_SUPER)->ctl_connection_busy)
|
||||
if (FTP_SUPER (VFS_FILE_HANDLER_SUPER (fh))->ctl_connection_busy)
|
||||
{
|
||||
if (!fh->ino->localname)
|
||||
{
|
||||
@ -2272,7 +2276,7 @@ ftpfs_fh_open (struct vfs_class *me, vfs_file_handler_t * fh, int flags, mode_t
|
||||
if (name == NULL)
|
||||
goto fail;
|
||||
fh->handle =
|
||||
ftpfs_open_data_connection (me, fh->ino->super,
|
||||
ftpfs_open_data_connection (me, VFS_FILE_HANDLER_SUPER (fh),
|
||||
(flags & O_APPEND) ? "APPE" : "STOR", name, TYPE_BINARY, 0);
|
||||
g_free (name);
|
||||
|
||||
@ -2309,18 +2313,18 @@ ftpfs_fh_close (struct vfs_class *me, vfs_file_handler_t * fh)
|
||||
{
|
||||
if (fh->handle != -1 && !fh->ino->localname)
|
||||
{
|
||||
ftp_super_t *ftp = FTP_SUPER (fh->ino->super);
|
||||
ftp_super_t *ftp = FTP_SUPER (VFS_FILE_HANDLER_SUPER (fh));
|
||||
|
||||
close (fh->handle);
|
||||
fh->handle = -1;
|
||||
ftp->ctl_connection_busy = 0;
|
||||
/* File is stored to destination already, so
|
||||
* we prevent MEDATA->ftpfs_file_store() call from vfs_s_close ()
|
||||
* we prevent VFS_SUBCLASS (me)->ftpfs_file_store() call from vfs_s_close ()
|
||||
*/
|
||||
fh->changed = 0;
|
||||
if (ftpfs_get_reply (me, ftp->sock, NULL, 0) != COMPLETE)
|
||||
ERRNOR (EIO, -1);
|
||||
vfs_s_invalidate (me, FH_SUPER);
|
||||
vfs_s_invalidate (me, VFS_FILE_HANDLER_SUPER (fh));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
#define SFTP_FH ((sftpfs_file_handler_t *) fh)
|
||||
#define SFTP_FILE_HANDLER(a) ((sftpfs_file_handler_t *) a)
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
@ -66,7 +66,7 @@ typedef struct
|
||||
static void
|
||||
sftpfs_reopen (vfs_file_handler_t * fh, GError ** mcerror)
|
||||
{
|
||||
sftpfs_file_handler_t *file = SFTP_FH;
|
||||
sftpfs_file_handler_t *file = SFTP_FILE_HANDLER (fh);
|
||||
int flags;
|
||||
mode_t mode;
|
||||
|
||||
@ -106,9 +106,9 @@ sftpfs_fh_new (struct vfs_s_inode * ino, gboolean changed)
|
||||
sftpfs_file_handler_t *fh;
|
||||
|
||||
fh = g_new0 (sftpfs_file_handler_t, 1);
|
||||
vfs_s_init_fh ((vfs_file_handler_t *) fh, ino, changed);
|
||||
vfs_s_init_fh (VFS_FILE_HANDLER (fh), ino, changed);
|
||||
|
||||
return FH;
|
||||
return VFS_FILE_HANDLER (fh);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -128,7 +128,7 @@ sftpfs_open_file (vfs_file_handler_t * fh, int flags, mode_t mode, GError ** mce
|
||||
unsigned long sftp_open_flags = 0;
|
||||
int sftp_open_mode = 0;
|
||||
gboolean do_append = FALSE;
|
||||
sftpfs_file_handler_t *file = SFTP_FH;
|
||||
sftpfs_file_handler_t *file = SFTP_FILE_HANDLER (fh);
|
||||
sftpfs_super_t *super = SFTP_SUPER (fh->ino->super);
|
||||
char *name;
|
||||
|
||||
@ -223,9 +223,9 @@ sftpfs_fstat (void *data, struct stat *buf, GError ** mcerror)
|
||||
{
|
||||
int res;
|
||||
LIBSSH2_SFTP_ATTRIBUTES attrs;
|
||||
vfs_file_handler_t *fh = (vfs_file_handler_t *) data;
|
||||
vfs_file_handler_t *fh = VFS_FILE_HANDLER (data);
|
||||
sftpfs_file_handler_t *sftpfs_fh = (sftpfs_file_handler_t *) data;
|
||||
struct vfs_s_super *super = fh->ino->super;
|
||||
struct vfs_s_super *super = VFS_FILE_HANDLER_SUPER (fh);
|
||||
sftpfs_super_t *sftpfs_super = SFTP_SUPER (super);
|
||||
|
||||
mc_return_val_if_error (mcerror, -1);
|
||||
@ -268,7 +268,7 @@ ssize_t
|
||||
sftpfs_read_file (vfs_file_handler_t * fh, char *buffer, size_t count, GError ** mcerror)
|
||||
{
|
||||
ssize_t rc;
|
||||
sftpfs_file_handler_t *file = SFTP_FH;
|
||||
sftpfs_file_handler_t *file = SFTP_FILE_HANDLER (fh);
|
||||
sftpfs_super_t *super;
|
||||
|
||||
mc_return_val_if_error (mcerror, -1);
|
||||
@ -280,7 +280,7 @@ sftpfs_read_file (vfs_file_handler_t * fh, char *buffer, size_t count, GError **
|
||||
return -1;
|
||||
}
|
||||
|
||||
super = SFTP_SUPER (fh->ino->super);
|
||||
super = SFTP_SUPER (VFS_FILE_HANDLER_SUPER (fh));
|
||||
|
||||
do
|
||||
{
|
||||
@ -318,8 +318,8 @@ ssize_t
|
||||
sftpfs_write_file (vfs_file_handler_t * fh, const char *buffer, size_t count, GError ** mcerror)
|
||||
{
|
||||
ssize_t rc;
|
||||
sftpfs_file_handler_t *file = SFTP_FH;
|
||||
sftpfs_super_t *super = SFTP_SUPER (fh->ino->super);
|
||||
sftpfs_file_handler_t *file = SFTP_FILE_HANDLER (fh);
|
||||
sftpfs_super_t *super = SFTP_SUPER (VFS_FILE_HANDLER_SUPER (fh));
|
||||
|
||||
mc_return_val_if_error (mcerror, -1);
|
||||
|
||||
@ -360,7 +360,7 @@ sftpfs_close_file (vfs_file_handler_t * fh, GError ** mcerror)
|
||||
|
||||
mc_return_val_if_error (mcerror, -1);
|
||||
|
||||
ret = libssh2_sftp_close (SFTP_FH->handle);
|
||||
ret = libssh2_sftp_close (SFTP_FILE_HANDLER (fh)->handle);
|
||||
|
||||
return ret == 0 ? 0 : -1;
|
||||
}
|
||||
@ -381,7 +381,7 @@ sftpfs_close_file (vfs_file_handler_t * fh, GError ** mcerror)
|
||||
off_t
|
||||
sftpfs_lseek (vfs_file_handler_t * fh, off_t offset, int whence, GError ** mcerror)
|
||||
{
|
||||
sftpfs_file_handler_t *file = SFTP_FH;
|
||||
sftpfs_file_handler_t *file = SFTP_FILE_HANDLER (fh);
|
||||
|
||||
mc_return_val_if_error (mcerror, 0);
|
||||
|
||||
|
@ -432,7 +432,7 @@ sftpfs_cb_read (void *data, char *buffer, size_t count)
|
||||
{
|
||||
int rc;
|
||||
GError *mcerror = NULL;
|
||||
vfs_file_handler_t *fh = (vfs_file_handler_t *) data;
|
||||
vfs_file_handler_t *fh = VFS_FILE_HANDLER (data);
|
||||
|
||||
if (tty_got_interrupt ())
|
||||
{
|
||||
@ -460,7 +460,7 @@ sftpfs_cb_write (void *data, const char *buf, size_t nbyte)
|
||||
{
|
||||
int rc;
|
||||
GError *mcerror = NULL;
|
||||
vfs_file_handler_t *fh = (vfs_file_handler_t *) data;
|
||||
vfs_file_handler_t *fh = VFS_FILE_HANDLER (data);
|
||||
|
||||
rc = sftpfs_write_file (fh, buf, nbyte, &mcerror);
|
||||
mc_error_message (&mcerror, NULL);
|
||||
@ -480,10 +480,8 @@ sftpfs_cb_close (void *data)
|
||||
{
|
||||
int rc;
|
||||
GError *mcerror = NULL;
|
||||
struct vfs_s_super *super;
|
||||
vfs_file_handler_t *fh = (vfs_file_handler_t *) data;
|
||||
|
||||
super = fh->ino->super;
|
||||
struct vfs_s_super *super = VFS_FILE_HANDLER_SUPER (data);
|
||||
vfs_file_handler_t *fh = VFS_FILE_HANDLER (data);
|
||||
|
||||
super->fd_usage--;
|
||||
if (super->fd_usage == 0)
|
||||
@ -573,7 +571,7 @@ static off_t
|
||||
sftpfs_cb_lseek (void *data, off_t offset, int whence)
|
||||
{
|
||||
off_t ret_offset;
|
||||
vfs_file_handler_t *fh = (vfs_file_handler_t *) data;
|
||||
vfs_file_handler_t *fh = VFS_FILE_HANDLER (data);
|
||||
GError *mcerror = NULL;
|
||||
|
||||
ret_offset = sftpfs_lseek (fh, offset, whence, &mcerror);
|
||||
|
@ -880,21 +880,22 @@ tar_super_same (const vfs_path_element_t * vpath_element, struct vfs_s_super *pa
|
||||
static ssize_t
|
||||
tar_read (void *fh, char *buffer, size_t count)
|
||||
{
|
||||
off_t begin = FH->ino->data_offset;
|
||||
int fd = TAR_SUPER (FH_SUPER)->fd;
|
||||
struct vfs_class *me = FH_SUPER->me;
|
||||
struct vfs_class *me = VFS_FILE_HANDLER_SUPER (fh)->me;
|
||||
vfs_file_handler_t *file = VFS_FILE_HANDLER (fh);
|
||||
off_t begin = file->ino->data_offset;
|
||||
int fd = TAR_SUPER (VFS_FILE_HANDLER_SUPER (fh))->fd;
|
||||
ssize_t res;
|
||||
|
||||
if (mc_lseek (fd, begin + FH->pos, SEEK_SET) != begin + FH->pos)
|
||||
if (mc_lseek (fd, begin + file->pos, SEEK_SET) != begin + file->pos)
|
||||
ERRNOR (EIO, -1);
|
||||
|
||||
count = MIN (count, (size_t) (FH->ino->st.st_size - FH->pos));
|
||||
count = MIN (count, (size_t) (file->ino->st.st_size - file->pos));
|
||||
|
||||
res = mc_read (fd, buffer, count);
|
||||
if (res == -1)
|
||||
ERRNOR (errno, -1);
|
||||
|
||||
FH->pos += res;
|
||||
file->pos += res;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user