[vhffs-dev] [1538] updating mtime on create, useful when creating empty files (touch) |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1538
Author: gradator
Date: 2010-01-10 20:29:24 +0100 (Sun, 10 Jan 2010)
Log Message:
-----------
updating mtime on create, useful when creating empty files (touch)
Modified Paths:
--------------
trunk/vhffs-fssync/vhffsfssync_master.c
trunk/vhffs-fssync/vhffsfssync_slave.c
Modified: trunk/vhffs-fssync/vhffsfssync_master.c
===================================================================
--- trunk/vhffs-fssync/vhffsfssync_master.c 2010-01-10 17:46:05 UTC (rev 1537)
+++ trunk/vhffs-fssync/vhffsfssync_master.c 2010-01-10 19:29:24 UTC (rev 1538)
@@ -1327,7 +1327,7 @@
printf("==> CREATE %s\n", pathname);
#endif
if(!st.st_size) {
- vhffsfssync_net_broadcast_event( g_strdup_printf("create%c%s%c", '\0', pathname, '\0') , VHFFSFSSYNC_NET_PRIO_MEDIUM);
+ vhffsfssync_net_broadcast_event( g_strdup_printf("create%c%s%c%ld%c", '\0', pathname, '\0', st.st_mtime, '\0') , VHFFSFSSYNC_NET_PRIO_MEDIUM);
vhffsfssync_net_broadcast_event( vhffsfssync_net_parent_mtime(pathname) , VHFFSFSSYNC_NET_PRIO_MEDIUM);
}
else {
Modified: trunk/vhffs-fssync/vhffsfssync_slave.c
===================================================================
--- trunk/vhffs-fssync/vhffsfssync_slave.c 2010-01-10 17:46:05 UTC (rev 1537)
+++ trunk/vhffs-fssync/vhffsfssync_slave.c 2010-01-10 19:29:24 UTC (rev 1538)
@@ -396,10 +396,22 @@
}
else if(!strcmp(args[0], "create")) {
char *pathname = args[1];
+ int long long mtime = atoll(args[2]);
int fd;
fd = open(pathname, O_CREAT|O_WRONLY|O_TRUNC, 0644);
if(fd >= 0) {
+ struct timeval tv[2];
+
+ tv[0].tv_sec = (time_t)mtime;
+ tv[0].tv_usec = 0;
+ tv[1].tv_sec = (time_t)mtime;
+ tv[1].tv_usec = 0;
+
+ if( futimes(fd, tv) ) {
+ fprintf(stderr, "futimes() failed on %s: %s\n", pathname, strerror(errno));
+ }
+
close(fd);
}
else {