summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix/pvfs_open.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-17 02:55:47 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:57 -0500
commitfef617c31bd4a8be09449d6bc726c729ae758423 (patch)
tree4951f62b04442e046f786b88e76dc48aac901e3f /source4/ntvfs/posix/pvfs_open.c
parentf6da6a10de7d7f101f6485f4a34ef4ef5b6ab6c0 (diff)
downloadsamba-fef617c31bd4a8be09449d6bc726c729ae758423.tar.gz
samba-fef617c31bd4a8be09449d6bc726c729ae758423.tar.bz2
samba-fef617c31bd4a8be09449d6bc726c729ae758423.zip
r3012: added initial support for byte range locking in the posix vfs. This is
enough for us to pass locktest, but does not yet support lock timeouts and some of the other esoteric features. (This used to be commit 58a92abd88f190bc60894a68e0528e95ae33fe39)
Diffstat (limited to 'source4/ntvfs/posix/pvfs_open.c')
-rw-r--r--source4/ntvfs/posix/pvfs_open.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c
index 29e57e5a08..51526461e0 100644
--- a/source4/ntvfs/posix/pvfs_open.c
+++ b/source4/ntvfs/posix/pvfs_open.c
@@ -51,6 +51,9 @@ struct pvfs_file *pvfs_find_fd(struct pvfs_state *pvfs,
static int pvfs_fd_destructor(void *p)
{
struct pvfs_file *f = p;
+
+ brl_close(f->pvfs->brl_context, &f->locking_key, f->fnum);
+
if (f->fd != -1) {
close(f->fd);
f->fd = -1;
@@ -71,6 +74,10 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
struct pvfs_filename *name;
struct pvfs_file *f;
NTSTATUS status;
+ struct {
+ dev_t device;
+ ino_t inode;
+ } lock_context;
if (io->generic.level != RAW_OPEN_GENERIC) {
return ntvfs_map_open(req, io, ntvfs);
@@ -161,6 +168,13 @@ do_open:
f->name = talloc_steal(f, name);
f->session = req->session;
f->smbpid = req->smbpid;
+ f->pvfs = pvfs;
+
+ /* we must zero here to take account of padding */
+ ZERO_STRUCT(lock_context);
+ lock_context.device = name->st.st_dev;
+ lock_context.inode = name->st.st_ino;
+ f->locking_key = data_blob_talloc(f, &lock_context, sizeof(lock_context));
/* setup a destructor to avoid file descriptor leaks on
abnormal termination */
@@ -204,6 +218,11 @@ NTSTATUS pvfs_close(struct ntvfs_module_context *ntvfs,
return NT_STATUS_INVALID_HANDLE;
}
+ status = brl_close(pvfs->brl_context, &f->locking_key, f->fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
if (close(f->fd) != 0) {
status = pvfs_map_errno(pvfs, errno);
} else {