diff options
author | Stefan Metzmacher <metze@samba.org> | 2008-02-23 11:49:39 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2008-02-26 09:33:00 +0100 |
commit | 4eb0fcc5173ddf50305fa5094ec0d87d53d71a33 (patch) | |
tree | 6ea2ac5580e463df92ad90d2f2839d802ebf844e /source4 | |
parent | 61e17794c394d2c070ce7df9cee6c53d846e7b75 (diff) | |
download | samba-4eb0fcc5173ddf50305fa5094ec0d87d53d71a33.tar.gz samba-4eb0fcc5173ddf50305fa5094ec0d87d53d71a33.tar.bz2 samba-4eb0fcc5173ddf50305fa5094ec0d87d53d71a33.zip |
pvfs_open: add pvfs_can_update_file_size()
TODO: this is not complete, we need more tests to trigger this
metze
(This used to be commit 66ad1081f2be8a0caa16fb0d614b857a5bde751c)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/ntvfs/posix/pvfs_open.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c index 4110df292d..12b70c00fd 100644 --- a/source4/ntvfs/posix/pvfs_open.c +++ b/source4/ntvfs/posix/pvfs_open.c @@ -1621,6 +1621,68 @@ NTSTATUS pvfs_can_rename(struct pvfs_state *pvfs, } /* + determine if the file size of a file can be changed, + or if it is prevented by an already open file +*/ +NTSTATUS pvfs_can_update_file_size(struct pvfs_state *pvfs, + struct ntvfs_request *req, + struct pvfs_filename *name, + struct odb_lock **lckp) +{ + NTSTATUS status; + DATA_BLOB key; + struct odb_lock *lck; + uint32_t share_access; + uint32_t access_mask; + bool break_to_none; + bool delete_on_close; + + status = pvfs_locking_key(name, name, &key); + if (!NT_STATUS_IS_OK(status)) { + return NT_STATUS_NO_MEMORY; + } + + lck = odb_lock(req, pvfs->odb_context, &key); + if (lck == NULL) { + DEBUG(0,("Unable to lock opendb for can_stat\n")); + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + + /* TODO: this may needs some more flags */ + share_access = NTCREATEX_SHARE_ACCESS_WRITE; + access_mask = 0; + delete_on_close = false; + break_to_none = true; + + status = odb_can_open(lck, name->stream_id, + share_access, access_mask, delete_on_close, + 0, break_to_none); + + /* + * if it's a sharing violation or we got no oplock + * only keep the lock if the caller requested access + * to the lock + */ + if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION) || + NT_STATUS_EQUAL(status, NT_STATUS_OPLOCK_NOT_GRANTED)) { + if (lckp) { + *lckp = lck; + } else { + talloc_free(lck); + } + } else if (!NT_STATUS_IS_OK(status)) { + talloc_free(lck); + if (lckp) { + *lckp = NULL; + } + } else if (lckp) { + *lckp = lck; + } + + return status; +} + +/* determine if file meta data can be accessed, or if it is prevented by an already open file */ |