summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2015-06-11 15:31:58 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2015-06-11 15:31:58 +0200
commit23284e9ac4733b0d1f9bd18a6a73d75ca71cdf81 (patch)
treed8ed31b8545663c97dac3291f71b5faa04d67f1f
parent1660640c50c4c6add3de83a263346a456c7f8b11 (diff)
downloadpgfuse-23284e9ac4733b0d1f9bd18a6a73d75ca71cdf81.tar.gz
pgfuse-23284e9ac4733b0d1f9bd18a6a73d75ca71cdf81.tar.bz2
fixed some simpler cases of ctime/mtime/atime handling
-rw-r--r--pgfuse.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/pgfuse.c b/pgfuse.c
index c05eaa3..0bdcf94 100644
--- a/pgfuse.c
+++ b/pgfuse.c
@@ -549,6 +549,15 @@ static int pgfuse_readdir( const char *path, void *buf, fuse_fill_dir_t filler,
PSQL_ROLLBACK( conn ); RELEASE( conn );
return res;
}
+
+ if( !data->noatime ) {
+ meta.atime = now( );
+ res = psql_write_meta( conn, id, path, meta );
+ if( res < 0 ) {
+ PSQL_ROLLBACK( conn ); RELEASE( conn );
+ return res;
+ }
+ }
PSQL_COMMIT( conn ); RELEASE( conn );
@@ -691,6 +700,9 @@ static int pgfuse_rmdir( const char *path )
return res;
}
+ // TODO: update ctime/mtime of parent directory, have functions to
+ // get the parent directory
+
PSQL_COMMIT( conn ); RELEASE( conn );
return 0;
@@ -737,6 +749,9 @@ static int pgfuse_unlink( const char *path )
PSQL_ROLLBACK( conn ); RELEASE( conn );
return res;
}
+
+ // TODO: update ctime/mtime of parent directory, have functions to
+ // get the parent directory
PSQL_COMMIT( conn ); RELEASE( conn );
@@ -786,6 +801,32 @@ static int pgfuse_release( const char *path, struct fuse_file_info *fi )
path, data->mountpoint, THREAD_ID );
}
+ if( !data->noatime ) {
+ int64_t id;
+ int res;
+ PgMeta meta;
+ PGconn *conn;
+
+ ACQUIRE( conn );
+ PSQL_BEGIN( conn );
+
+ id = psql_read_meta_from_path( conn, path, &meta );
+ if( id < 0 ) {
+ PSQL_ROLLBACK( conn ); RELEASE( conn );
+ return id;
+ }
+
+ meta.atime = now( );
+
+ res = psql_write_meta( conn, id, path, meta );
+ if( res < 0 ) {
+ PSQL_ROLLBACK( conn ); RELEASE( conn );
+ return res;
+ }
+
+ PSQL_COMMIT( conn ); RELEASE( conn );
+ }
+
return 0;
}
@@ -947,6 +988,9 @@ static int pgfuse_truncate( const char* path, off_t offset )
}
meta.size = offset;
+ meta.ctime = now( );
+ meta.mtime = meta.ctime;
+
res = psql_write_meta( conn, id, path, meta );
if( res < 0 ) {
PSQL_ROLLBACK( conn ); RELEASE( conn );
@@ -998,7 +1042,8 @@ static int pgfuse_ftruncate( const char *path, off_t offset, struct fuse_file_in
}
meta.size = offset;
- meta.mtime = now( );
+ meta.ctime = now( );
+ meta.mtime = meta.ctime;
res = psql_write_meta( conn, fi->fh, path, meta );
if( res < 0 ) {
@@ -1354,6 +1399,9 @@ static int pgfuse_symlink( const char *from, const char *to )
return -EIO;
}
+ // TODO: update ctime/mtime of parent directory, have functions to
+ // get the parent directory
+
free( copy_to );
PSQL_COMMIT( conn ); RELEASE( conn );
@@ -1361,6 +1409,9 @@ static int pgfuse_symlink( const char *from, const char *to )
return 0;
}
+// TODO: handle mtime/ctime of original and receiving folder, handle
+// mtime/ctime of file/directory being moved
+
static int pgfuse_rename( const char *from, const char *to )
{
PgFuseData *data = (PgFuseData *)fuse_get_context( )->private_data;