Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932241AbWAWTsx (ORCPT ); Mon, 23 Jan 2006 14:48:53 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932445AbWAWTsx (ORCPT ); Mon, 23 Jan 2006 14:48:53 -0500 Received: from twinlark.arctic.org ([207.7.145.18]:6375 "EHLO twinlark.arctic.org") by vger.kernel.org with ESMTP id S932241AbWAWTsx (ORCPT ); Mon, 23 Jan 2006 14:48:53 -0500 Date: Mon, 23 Jan 2006 11:48:52 -0800 (PST) From: dean gaudet To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Subject: [PATCH] fix fcntl(F_SETFL) on append-only files (repost) Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1727 Lines: 43 hi, there is code in setfl() which attempts to preserve the O_APPEND flag on IS_APPEND files... however IS_APPEND files could also be opened O_RDONLY and in that case setfl() should not require O_APPEND... coreutils 5.93 tail -f attempts to set O_NONBLOCK even on regular files... unfortunately if you try this on an append-only log file the result is this: fcntl64(3, F_GETFL) = 0x8000 (flags O_RDONLY|O_LARGEFILE) fcntl64(3, F_SETFL, O_RDONLY|O_NONBLOCK|O_LARGEFILE) = -1 EPERM (Operation not permitted) i offer up the patch below as one way of fixing the problem... i've tested it fixes the problem with tail -f but haven't really tested beyond that. (i also reported the coreutils bug upstream... it shouldn't fail imho... ) -dean Signed-off-by: dean gaudet --- linux-2.6.14.4.orig/fs/fcntl.c 2005-10-27 17:02:08.000000000 -0700 +++ linux-2.6.14.4/fs/fcntl.c 2006-01-18 10:33:38.000000000 -0800 @@ -207,8 +207,10 @@ struct inode * inode = filp->f_dentry->d_inode; int error = 0; - /* O_APPEND cannot be cleared if the file is marked as append-only */ - if (!(arg & O_APPEND) && IS_APPEND(inode)) + /* O_APPEND cannot be cleared if the file is marked as append-only + * and the file is open for write. + */ + if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) return -EPERM; /* O_NOATIME can only be set by the owner or superuser */ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/