diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2015-05-07 09:20:44 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2015-05-07 09:20:44 +0200 |
commit | 56f70fa76186e99d067380fb71530ec259365ba6 (patch) | |
tree | ee289b2a08af8b818f751661dba97b2c4f1db531 /pgfuse.c | |
parent | 01c955fdb6f84d39ce8c87eb609ba7616f3fdf2f (diff) | |
download | pgfuse-56f70fa76186e99d067380fb71530ec259365ba6.tar.gz pgfuse-56f70fa76186e99d067380fb71530ec259365ba6.tar.bz2 |
printing more open flags. hadling of O_CREAT and O_EXCL
Diffstat (limited to 'pgfuse.c')
-rw-r--r-- | pgfuse.c | 29 |
1 files changed, 24 insertions, 5 deletions
@@ -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 ); |