summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2015-05-07 09:20:44 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2015-05-07 09:20:44 +0200
commit56f70fa76186e99d067380fb71530ec259365ba6 (patch)
treeee289b2a08af8b818f751661dba97b2c4f1db531
parent01c955fdb6f84d39ce8c87eb609ba7616f3fdf2f (diff)
downloadpgfuse-56f70fa76186e99d067380fb71530ec259365ba6.tar.gz
pgfuse-56f70fa76186e99d067380fb71530ec259365ba6.tar.bz2
printing more open flags. hadling of O_CREAT and O_EXCL
-rw-r--r--pgfuse.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/pgfuse.c b/pgfuse.c
index 553e9e4..f41e6b7 100644
--- a/pgfuse.c
+++ b/pgfuse.c
@@ -274,12 +274,15 @@ static char *flags_to_string( int flags )
s = (char *)malloc( 100 );
if( s == NULL ) return "<memory allocation failed>";
- snprintf( s, 100, "access_mode=%s, flags=%s%s%s%s",
+ snprintf( s, 100, "access_mode=%s, flags=%s%s%s%s%s%s%s",
mode_s,
( flags & O_CREAT ) ? "O_CREAT " : "",
( flags & O_TRUNC ) ? "O_TRUNC " : "",
( flags & O_EXCL ) ? "O_EXCL " : "",
- ( flags & O_APPEND ) ? "O_APPEND " : "");
+ ( flags & O_NOFOLLOW ) ? "O_NOFOLLOW " : "",
+ ( flags & O_CLOEXEC ) ? "O_CLOEXEC " : "",
+ ( flags & O_DIRECTORY ) ? "O_DIRECTORY " : "",
+ ( flags & O_APPEND ) ? "O_APPEND " : "" );
return s;
}
@@ -323,13 +326,29 @@ static int pgfuse_create( const char *path, mode_t mode, struct fuse_file_info *
path, id, THREAD_ID );
}
- if( S_ISDIR(meta.mode ) ) {
+ if( S_ISDIR( meta.mode ) ) {
PSQL_ROLLBACK( conn ); RELEASE( conn );
return -EISDIR;
}
+
+ if( ( fi->flags & O_CREAT ) && (fi->flags & O_EXCL ) ) {
+ PSQL_ROLLBACK( conn ); RELEASE( conn );
+ return -EEXIST;
+ }
+
+ res = psql_truncate( conn, data->block_size, id, path, 0 );
+ if( res < 0 ) {
+ PSQL_ROLLBACK( conn ); RELEASE( conn );
+ return res;
+ }
+
+ meta.size = 0;
+ res = psql_write_meta( conn, id, path, meta );
+ if( res < 0 ) {
+ PSQL_ROLLBACK( conn ); RELEASE( conn );
+ return res;
+ }
- PSQL_ROLLBACK( conn ); RELEASE( conn );
- return -EEXIST;
}
copy_path = strdup( path );