From f589410ced9f7a145df426c2077395df0711fa17 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Tue, 20 Oct 2009 13:04:30 +0300 Subject: [PATCH] Ticket #1729: extfs: fail copying into arhive Test case: * create any zip-archive (or take exists) * run mc * enter into archive * try to copy any files inside archive. Fix issue: Try to open temporarry file twice: with O_CREATE flag; and without O_CREATE and with O_TRUNC flag Also, created extfs_chown() function for avoid chown-related warnings. Signed-off-by: Slava Zanko --- vfs/extfs.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/vfs/extfs.c b/vfs/extfs.c index 9cd00a146..726c8383c 100644 --- a/vfs/extfs.c +++ b/vfs/extfs.c @@ -720,6 +720,13 @@ extfs_open (struct vfs_class *me, const char *file, int flags, int mode) local_handle = open (entry->inode->local_filename, NO_LINEAR (flags), mode); + + if (local_handle == -1) { + /* file exists(may be). Need to drop O_CREAT flag and truncate file content */ + flags = ~O_CREAT & (NO_LINEAR (flags)|O_TRUNC); + local_handle = open (entry->inode->local_filename, flags , mode); + } + if (local_handle == -1) ERRNOR (EIO, NULL); @@ -1019,6 +1026,15 @@ cleanup: return result; } +static int extfs_chown (struct vfs_class *me, const char *path, int owner, int group) +{ + (void) me; + (void) path; + (void) owner; + (void) group; + return 0; +} + static int extfs_chmod (struct vfs_class *me, const char *path, int mode) { (void) me; @@ -1414,6 +1430,7 @@ init_extfs (void) vfs_extfs_ops.lstat = extfs_lstat; vfs_extfs_ops.fstat = extfs_fstat; vfs_extfs_ops.chmod = extfs_chmod; + vfs_extfs_ops.chown = extfs_chown; vfs_extfs_ops.readlink = extfs_readlink; vfs_extfs_ops.unlink = extfs_unlink; vfs_extfs_ops.chdir = extfs_chdir;