1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-24 02:04:21 +03:00

r3174: added pvfs_is_open() to allow us to check for open files on unlink. We

now pass BASE-UNLINK.
(This used to be commit f23a2f8538bda8f6790e86c93ee22436388b2975)
This commit is contained in:
Andrew Tridgell 2004-10-25 01:29:31 +00:00 committed by Gerald (Jerry) Carter
parent def9a12bcc
commit c1c696460b
3 changed files with 41 additions and 0 deletions

View File

@ -335,3 +335,23 @@ NTSTATUS odb_set_create_options(struct odb_lock *lck,
return status;
}
/*
determine if a file is open
*/
BOOL odb_is_open(struct odb_context *odb, DATA_BLOB *key)
{
TDB_DATA dbuf;
TDB_DATA kbuf;
kbuf.dptr = key->data;
kbuf.dsize = key->length;
dbuf = tdb_fetch(odb->w->tdb, kbuf);
if (dbuf.dptr == NULL) {
return False;
}
free(dbuf.dptr);
return True;
}

View File

@ -703,3 +703,20 @@ NTSTATUS pvfs_change_create_options(struct pvfs_state *pvfs,
return status;
}
/*
determine if a file is open - used to prevent some operations on open files
*/
BOOL pvfs_is_open(struct pvfs_state *pvfs, struct pvfs_filename *name)
{
NTSTATUS status;
DATA_BLOB key;
status = pvfs_locking_key(name, name, &key);
if (!NT_STATUS_IS_OK(status)) {
return False;
}
return odb_is_open(pvfs->odb_context, &key);
}

View File

@ -80,6 +80,10 @@ NTSTATUS pvfs_unlink(struct ntvfs_module_context *ntvfs,
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
if (pvfs_is_open(pvfs, name)) {
return NT_STATUS_SHARING_VIOLATION;
}
dir = talloc_p(req, struct pvfs_dir);
if (dir == NULL) {
return NT_STATUS_NO_MEMORY;