public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jean-Pierre André" <jean-pierre.andre@wanadoo.fr>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Eric Blake <ebb9@byu.net>,
	fuse-devel@lists.sourceforge.net,
	Miklos Szeredi <miklos@szeredi.hu>,
	Christoph Hellwig <hch@lst.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	xfs@oss.sgi.com
Subject: Re: [fuse-devel] utimensat fails to update ctime
Date: Wed, 23 Dec 2009 15:28:52 +0100	[thread overview]
Message-ID: <4B322924.1030406@wanadoo.fr> (raw)
In-Reply-To: <87my1aevro.fsf@devron.myhome.or.jp>

[-- Attachment #1: Type: text/plain, Size: 775 bytes --]

Hi,

OGAWA Hirofumi wrote:
>> I suggest I port Miklos patch to fuse-lite soon,
>> and delay the low-level case (and microsecond
>> precision) until January. Does that suit your needs ?
>>      
> Thanks. Sounds good. I'm not using ntfs-3g actually, I just bridged the
> bug report on lkml to others. Eric?

As my Christmas present to any real non-bridging
user, here is, ahead of schedule, the patch for the
low level fuse interface of ntfs-3g.

The good news is that for this interface, no update
of fuse is needed. So there is no compilation issue with
unpatched versions of fuse, and the attached patch
is independent of the one for the high-level interface
posted previously, except for the configuration.ac file
for which I duplicate the patch.

Regards

Jean-Pierre




[-- Attachment #2: lowutimensat.patch --]
[-- Type: text/plain, Size: 5838 bytes --]

--- ntfs-3g-2009.11.14AC.2/configure.ac	2009-12-16 08:33:26.000000000 +0100
+++ ntfslow/configure.ac	2009-12-23 10:24:29.000000000 +0100
@@ -314,7 +314,7 @@
 	atexit basename daemon dup2 fdatasync ffs getopt_long hasmntopt \
 	mbsinit memmove memset realpath regcomp setlocale setxattr \
 	strcasecmp strchr strdup strerror strnlen strsep strtol strtoul \
-	sysconf utime fork \
+	sysconf utime utimensat fork \
 ])
 AC_SYS_LARGEFILE
 
--- ntfs-3g-2009.11.14AC.2/src/lowntfs-3g.c	2009-12-19 09:58:22.000000000 +0100
+++ ntfslow/src/lowntfs-3g.c	2009-12-23 15:06:14.000000000 +0100
@@ -1527,8 +1527,54 @@
 	return res;
 }
 
+#ifdef HAVE_UTIMENSAT
+
+static int ntfs_fuse_utimens(struct SECURITY_CONTEXT *scx, fuse_ino_t ino,
+		struct stat *stin, struct stat *stbuf, int to_set)
+{
+	ntfs_inode *ni;
+	int res = 0;
+
+	ni = ntfs_inode_open(ctx->vol, INODE(ino));
+	if (!ni)
+		return -errno;
+
+			/* no check or update if both UTIME_OMIT */
+	if (to_set & (FUSE_SET_ATTR_ATIME + FUSE_SET_ATTR_MTIME)) {
+#if !KERNELPERMS | (POSIXACLS & !KERNELACLS)
+		if (ntfs_allowed_access(scx, ni, S_IWRITE)
+		    || ((to_set & FUSE_SET_ATTR_ATIME_NOW)
+			&& (to_set & FUSE_SET_ATTR_MTIME_NOW)
+			&& ntfs_allowed_as_owner(scx, ni))) {
+#endif
+			ntfs_time_update_flags mask = NTFS_UPDATE_CTIME;
+
+			if (to_set & FUSE_SET_ATTR_ATIME_NOW)
+				mask |= NTFS_UPDATE_ATIME;
+			else
+				if (to_set & FUSE_SET_ATTR_ATIME)
+					ni->last_access_time = stin->st_atime;
+			if (to_set & FUSE_SET_ATTR_MTIME_NOW)
+				mask |= NTFS_UPDATE_MTIME;
+			else
+				if (to_set & FUSE_SET_ATTR_MTIME)
+					ni->last_data_change_time = stin->st_mtime;;
+			ntfs_inode_update_times(ni, mask);
+#if !KERNELPERMS | (POSIXACLS & !KERNELACLS)
+		} else
+			res = -errno;
+#endif
+	}
+	res = ntfs_fuse_getstat(scx, ni, stbuf);
+	if (ntfs_inode_close(ni))
+		set_fuse_error(&res);
+	return res;
+}
+
+#else /* HAVE_UTIMENSAT */
+
 static int ntfs_fuse_utime(struct SECURITY_CONTEXT *scx, fuse_ino_t ino,
-		struct stat *stin, struct stat *stbuf)
+		struct stat *stin, struct stat *stbuf, int to_set)
 {
 	ntfs_inode *ni;
 	int res = 0;
@@ -1586,6 +1632,8 @@
 	return res;
 }
 
+#endif /* HAVE_UTIMENSAT */
+
 static void ntfs_fuse_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,
 			 int to_set, struct fuse_file_info *fi __attribute__((unused)))
 {
@@ -1594,13 +1642,14 @@
 	int res;
 	struct SECURITY_CONTEXT security;
 
+	res = 0;
 	ntfs_fuse_fill_security_context(req, &security);
-	switch (to_set
+						/* no flags */
+	if (!(to_set
 		    & (FUSE_SET_ATTR_MODE
 			| FUSE_SET_ATTR_UID | FUSE_SET_ATTR_GID
 			| FUSE_SET_ATTR_SIZE
-			| FUSE_SET_ATTR_ATIME | FUSE_SET_ATTR_MTIME)) {
-	case 0 :
+			| FUSE_SET_ATTR_ATIME | FUSE_SET_ATTR_MTIME))) {
 		ni = ntfs_inode_open(ctx->vol, INODE(ino));
 		if (!ni)
 			res = -errno;
@@ -1609,46 +1658,60 @@
 			if (ntfs_inode_close(ni))
 				set_fuse_error(&res);
 		}
-		break;
-	case FUSE_SET_ATTR_MODE :
-		res = ntfs_fuse_chmod(&security, ino, attr->st_mode & 07777,
-					&stbuf);
-		break;
-	case FUSE_SET_ATTR_UID :
-		res = ntfs_fuse_chown(&security, ino, attr->st_uid,
-					(gid_t)-1, &stbuf);
-		break;
-	case FUSE_SET_ATTR_GID :
-		res = ntfs_fuse_chown(&security, ino, (uid_t)-1,
-					attr->st_gid, &stbuf);
-		break;
-	case FUSE_SET_ATTR_UID + FUSE_SET_ATTR_GID :
-		res = ntfs_fuse_chown(&security, ino, attr->st_uid,
-					attr->st_gid, &stbuf);
-		break;
-	case FUSE_SET_ATTR_UID + FUSE_SET_ATTR_MODE:
-		res = ntfs_fuse_chownmod(&security, ino, attr->st_uid,
-					(gid_t)-1,attr->st_mode, &stbuf);
-		break;
-	case FUSE_SET_ATTR_GID + FUSE_SET_ATTR_MODE:
-		res = ntfs_fuse_chownmod(&security, ino, (uid_t)-1,
-					attr->st_gid,attr->st_mode, &stbuf);
-		break;
-	case FUSE_SET_ATTR_UID + FUSE_SET_ATTR_GID + FUSE_SET_ATTR_MODE:
-		res = ntfs_fuse_chownmod(&security, ino, attr->st_uid,
+	}
+						/* some set of uid/gid/mode */
+	if (to_set
+		    & (FUSE_SET_ATTR_MODE
+			| FUSE_SET_ATTR_UID | FUSE_SET_ATTR_GID)) {
+		switch (to_set
+			    & (FUSE_SET_ATTR_MODE
+				| FUSE_SET_ATTR_UID | FUSE_SET_ATTR_GID)) {
+		case FUSE_SET_ATTR_MODE :
+			res = ntfs_fuse_chmod(&security, ino,
+						attr->st_mode & 07777, &stbuf);
+			break;
+		case FUSE_SET_ATTR_UID :
+			res = ntfs_fuse_chown(&security, ino, attr->st_uid,
+						(gid_t)-1, &stbuf);
+			break;
+		case FUSE_SET_ATTR_GID :
+			res = ntfs_fuse_chown(&security, ino, (uid_t)-1,
+						attr->st_gid, &stbuf);
+			break;
+		case FUSE_SET_ATTR_UID + FUSE_SET_ATTR_GID :
+			res = ntfs_fuse_chown(&security, ino, attr->st_uid,
+						attr->st_gid, &stbuf);
+			break;
+		case FUSE_SET_ATTR_UID + FUSE_SET_ATTR_MODE:
+			res = ntfs_fuse_chownmod(&security, ino, attr->st_uid,
+						(gid_t)-1,attr->st_mode,
+						&stbuf);
+			break;
+		case FUSE_SET_ATTR_GID + FUSE_SET_ATTR_MODE:
+			res = ntfs_fuse_chownmod(&security, ino, (uid_t)-1,
+						attr->st_gid,attr->st_mode,
+						&stbuf);
+			break;
+		case FUSE_SET_ATTR_UID + FUSE_SET_ATTR_GID + FUSE_SET_ATTR_MODE:
+			res = ntfs_fuse_chownmod(&security, ino, attr->st_uid,
 					attr->st_gid,attr->st_mode, &stbuf);
-		break;
-	case FUSE_SET_ATTR_SIZE :
+			break;
+		default :
+			break;
+		}
+	}
+						/* size */
+	if (!res && (to_set & FUSE_SET_ATTR_SIZE)) {
 		res = ntfs_fuse_trunc(&security, ino, attr->st_size,
 					!fi, &stbuf);
-		break;
-	case FUSE_SET_ATTR_ATIME + FUSE_SET_ATTR_MTIME :
+	}
+						/* some set of atime/mtime */
+	if (!res && (to_set & (FUSE_SET_ATTR_ATIME + FUSE_SET_ATTR_MTIME))) {
+#ifdef HAVE_UTIMENSAT
+		res = ntfs_fuse_utimens(&security, ino, attr, &stbuf, to_set);
+#else /* HAVE_UTIMENSAT */
 		res = ntfs_fuse_utime(&security, ino, attr, &stbuf);
-		break;
-	default:
-		ntfs_log_error("Unsupported setattr mode 0x%x\n",(int)to_set);
-		res = -EOPNOTSUPP;
-		break;
+#endif /* HAVE_UTIMENSAT */
 	}
 	if (res)
 		fuse_reply_err(req, -res);

  parent reply	other threads:[~2009-12-23 14:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-18  5:38 utimensat fails to update ctime Eric Blake
2009-12-21  7:31 ` OGAWA Hirofumi
2009-12-21 13:12   ` Eric Blake
2009-12-21 13:39     ` Eric Blake
2009-12-21 15:05       ` OGAWA Hirofumi
2009-12-22  4:37         ` Eric Blake
2009-12-22  9:00           ` OGAWA Hirofumi
2009-12-22  9:56             ` [fuse-devel] " Jean-Pierre André
2009-12-22 10:43               ` OGAWA Hirofumi
2009-12-22 12:07                 ` Jean-Pierre André
2009-12-22 13:00                   ` Miklos Szeredi
2009-12-22 13:30                   ` OGAWA Hirofumi
2009-12-22 16:16                     ` Jean-Pierre André
2009-12-22 17:58                       ` OGAWA Hirofumi
2009-12-23  9:43                         ` Jean-Pierre André
2009-12-23 11:08                           ` OGAWA Hirofumi
2009-12-23 12:54                         ` Eric Blake
2009-12-23 19:23                           ` OGAWA Hirofumi
     [not found]                           ` <4B32B303.6070807@gmail.com>
2009-12-24  0:50                             ` Eric Blake
2009-12-23 14:28                         ` Jean-Pierre André [this message]
2009-12-22 12:34           ` Dave Chinner
2009-12-22 12:42             ` Eric Blake
2009-12-23  7:53               ` Christoph Hellwig
2009-12-22 17:45         ` Christoph Hellwig
2009-12-22 19:06           ` OGAWA Hirofumi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B322924.1030406@wanadoo.fr \
    --to=jean-pierre.andre@wanadoo.fr \
    --cc=ebb9@byu.net \
    --cc=fuse-devel@lists.sourceforge.net \
    --cc=hch@lst.de \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox