1
1

Merge branch '1395_copy_to_fish_broken'

* 1395_copy_to_fish_broken:
  Fixed segfault with fish operations
  Ticket #1395 (Copying to fish is broken)
Этот коммит содержится в:
Slava Zanko 2009-07-15 13:59:45 +03:00
родитель f830dcc0a8 33c0d6f022
Коммит ddad204341
4 изменённых файлов: 57 добавлений и 2 удалений

Просмотреть файл

@ -727,7 +727,7 @@ vfs_s_readlink (struct vfs_class *me, const char *path, char *buf, size_t size)
return len;
}
static void *
void *
vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode)
{
int was_changed = 0;

Просмотреть файл

@ -1045,8 +1045,31 @@ static int fish_unlink (struct vfs_class *me, const char *path)
POSTFIX(OPT_FLUSH);
}
static int fish_exists (struct vfs_class *me, const char *path)
{
int ret_code;
PREFIX
g_snprintf(buf, sizeof(buf),
"#ISEXISTS \"/%s\"\n"
"ls -l \"/%s\" >/dev/null 2>/dev/null\n"
"echo '### '$?\n",
rpath, rpath);
g_free (rpath);
if ( fish_send_command(me, super, buf, OPT_FLUSH) == 0 )
return 1;
return 0;
}
static int fish_mkdir (struct vfs_class *me, const char *path, mode_t mode)
{
int ret_code;
PREFIX
(void) mode;
@ -1056,7 +1079,17 @@ static int fish_mkdir (struct vfs_class *me, const char *path, mode_t mode)
"mkdir /%s 2>/dev/null\n"
"echo '### 000'\n",
rpath, rpath);
POSTFIX(OPT_FLUSH);
g_free (rpath);
ret_code = fish_send_command(me, super, buf, OPT_FLUSH);
if ( ret_code != 0 )
return ret_code;
if ( ! fish_exists (me, path) ){
ERRNOR (EACCES, -1);
}
return 0;
}
static int fish_rmdir (struct vfs_class *me, const char *path)
@ -1135,6 +1168,18 @@ fish_fill_names (struct vfs_class *me, fill_names_f func)
}
}
static void *
fish_open (struct vfs_class *me, const char *file, int flags, int 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);
}
void
init_fish (void)
{
@ -1157,6 +1202,7 @@ init_fish (void)
vfs_fish_ops.fill_names = fish_fill_names;
vfs_fish_ops.chmod = fish_chmod;
vfs_fish_ops.chown = fish_chown;
vfs_fish_ops.open = fish_open;
vfs_fish_ops.symlink = fish_symlink;
vfs_fish_ops.link = fish_link;
vfs_fish_ops.unlink = fish_unlink;

Просмотреть файл

@ -135,6 +135,9 @@ int vfs_file_class_flags (const char *filename);
void vfs_fill_names (fill_names_f);
char *vfs_translate_url (const char *);
/* vfs/direntry.c: */
void *vfs_s_open (struct vfs_class *, const char *, int, int);
#ifdef USE_NETCODE
extern int use_netrc;
#endif

Просмотреть файл

@ -564,6 +564,10 @@ int mc_##name inarg \
char *mpath = vfs_canon_and_translate (path); \
if (mpath != NULL) { \
vfs = vfs_get_class (mpath); \
if (vfs == NULL){ \
g_free (mpath); \
return -1; \
} \
result = vfs->name ? (*vfs->name)callarg : -1; \
g_free (mpath); \
if (result == -1) \
@ -618,6 +622,8 @@ ssize_t mc_##name inarg \
if (handle == -1) \
return -1; \
vfs = vfs_op (handle); \
if (vfs == NULL) \
return -1; \
result = vfs->name ? (*vfs->name)callarg : -1; \
if (result == -1) \
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \