From patchwork Wed Sep 26 22:43:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Sorenson X-Patchwork-Id: 10617011 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24B6A175A for ; Wed, 26 Sep 2018 22:43:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 150202B202 for ; Wed, 26 Sep 2018 22:43:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 099A82B26E; Wed, 26 Sep 2018 22:43:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBD922B202 for ; Wed, 26 Sep 2018 22:43:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726653AbeI0E6w (ORCPT ); Thu, 27 Sep 2018 00:58:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39948 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726609AbeI0E6v (ORCPT ); Thu, 27 Sep 2018 00:58:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8A5378830B; Wed, 26 Sep 2018 22:43:40 +0000 (UTC) Received: from hut.sorensonfamily.com.com (ovpn-116-190.phx2.redhat.com [10.3.116.190]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 35010611C7; Wed, 26 Sep 2018 22:43:40 +0000 (UTC) From: Frank Sorenson To: linux-fsdevel@vger.kernel.org Cc: hirofumi@mail.parknet.co.jp Subject: [PATCH V4 4/4] fat: truncate inode timestamp updates in setattr Date: Wed, 26 Sep 2018 17:43:35 -0500 Message-Id: <20180926224335.5919-5-sorenson@redhat.com> In-Reply-To: <20180926224335.5919-1-sorenson@redhat.com> References: <20180926224335.5919-1-sorenson@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 26 Sep 2018 22:43:40 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP setattr_copy can't truncate timestamps correctly for msdos/vfat, so truncate and copy them ourselves. Signed-off-by: Frank Sorenson --- fs/fat/file.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/fat/file.c b/fs/fat/file.c index 4b5438405415..13935ee99e1e 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c @@ -542,6 +542,18 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr) up_write(&MSDOS_I(inode)->truncate_lock); } + /* + * setattr_copy can't truncate these appropriately, so we'll + * copy them ourselves + */ + if (attr->ia_valid & ATTR_ATIME) + fat_truncate_time(inode, &attr->ia_atime, S_ATIME); + if (attr->ia_valid & ATTR_CTIME) + fat_truncate_time(inode, &attr->ia_ctime, S_CTIME); + if (attr->ia_valid & ATTR_MTIME) + fat_truncate_time(inode, &attr->ia_mtime, S_MTIME); + attr->ia_valid &= ~(ATTR_ATIME|ATTR_CTIME|ATTR_MTIME); + setattr_copy(inode, attr); mark_inode_dirty(inode); out: