{
return ops->brl_close(brl, brlh);
}
+
+/*
+ Get a number of locks associated with a open file.
+*/
+NTSTATUS brl_count(struct brl_context *brl,
+ struct brl_handle *brlh,
+ int *count)
+{
+ return ops->brl_count(brl, brlh, count);
+}
return status;
}
+static NTSTATUS brl_tdb_count(struct brl_context *brl, struct brl_handle *brlh,
+ int *count)
+{
+ TDB_DATA kbuf, dbuf;
+
+ kbuf.dptr = brlh->key.data;
+ kbuf.dsize = brlh->key.length;
+ *count = 0;
+
+ if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+
+ dbuf = tdb_fetch(brl->w->tdb, kbuf);
+ if (!dbuf.dptr) {
+ tdb_chainunlock(brl->w->tdb, kbuf);
+ return NT_STATUS_OK;
+ }
+
+ *count = dbuf.dsize / sizeof(struct lock_struct);
+
+ free(dbuf.dptr);
+ tdb_chainunlock(brl->w->tdb, kbuf);
+
+ return NT_STATUS_OK;
+}
static const struct brlock_ops brlock_tdb_ops = {
.brl_init = brl_tdb_init,
.brl_unlock = brl_tdb_unlock,
.brl_remove_pending = brl_tdb_remove_pending,
.brl_locktest = brl_tdb_locktest,
- .brl_close = brl_tdb_close
+ .brl_close = brl_tdb_close,
+ .brl_count = brl_tdb_count
};
struct pvfs_file *f;
struct ntvfs_handle *h;
NTSTATUS status;
- int fd;
+ int fd, count;
struct odb_lock *lck;
uint32_t create_options;
uint32_t create_options_must_ignore_mask;
f->handle->fd = fd;
+ status = brl_count(f->pvfs->brl_context, f->brl_handle, &count);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(lck);
+ return status;
+ }
+
+ if (count != 0) {
+ oplock_level = OPLOCK_NONE;
+ }
+
/* now really mark the file as open */
status = odb_open_file(lck, f->handle, name->full_name,
&f->handle->fd, name->dos.write_time,