summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/vfs.h6
-rw-r--r--source3/include/vfs_macros.h3
-rw-r--r--source3/lib/file_id.c7
-rw-r--r--source3/modules/vfs_default.c7
-rw-r--r--source3/printing/printfsp.c2
-rw-r--r--source3/smbd/close.c2
-rw-r--r--source3/smbd/filename.c3
-rw-r--r--source3/smbd/open.c10
-rw-r--r--source3/smbd/reply.c3
-rw-r--r--source3/smbd/trans2.c14
10 files changed, 39 insertions, 18 deletions
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index b136750e7c..768c9fbcab 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -71,6 +71,7 @@
/* Changed to version21 to add chflags operation -- jpeach */
/* Changed to version22 to add lchown operation -- jra */
/* Leave at 22 - not yet released. But change set_nt_acl to return an NTSTATUS. jra. */
+/* Leave at 22 - not yet released. Add file_id_create operation. --metze */
#define SMB_VFS_INTERFACE_VERSION 22
@@ -162,6 +163,7 @@ typedef enum _vfs_op_type {
SMB_VFS_OP_REALPATH,
SMB_VFS_OP_NOTIFY_WATCH,
SMB_VFS_OP_CHFLAGS,
+ SMB_VFS_OP_FILE_ID_CREATE,
/* NT ACL operations. */
@@ -295,7 +297,8 @@ struct vfs_ops {
struct notify_event *ev),
void *private_data, void *handle_p);
int (*chflags)(struct vfs_handle_struct *handle, const char *path, uint flags);
-
+ struct file_id (*file_id_create)(struct vfs_handle_struct *handle, SMB_DEV_T dev, SMB_INO_T inode);
+
/* NT ACL operations. */
size_t (*fget_nt_acl)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, uint32 security_info, struct security_descriptor **ppdesc);
@@ -414,6 +417,7 @@ struct vfs_ops {
struct vfs_handle_struct *realpath;
struct vfs_handle_struct *notify_watch;
struct vfs_handle_struct *chflags;
+ struct vfs_handle_struct *file_id_create;
/* NT ACL operations. */
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index 9957b585de..ac22ff5204 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -80,6 +80,7 @@
#define SMB_VFS_REALPATH(conn, path, resolved_path) ((conn)->vfs.ops.realpath((conn)->vfs.handles.realpath, (path), (resolved_path)))
#define SMB_VFS_NOTIFY_WATCH(conn, ctx, e, callback, private_data, handle_p) ((conn)->vfs.ops.notify_watch((conn)->vfs.handles.notify_watch, (ctx), (e), (callback), (private_data), (handle_p)))
#define SMB_VFS_CHFLAGS(conn, path, flags) ((conn)->vfs.ops.chflags((conn)->vfs.handles.chflags, (path), (flags)))
+#define SMB_VFS_FILE_ID_CREATE(conn, dev, inode) ((conn)->vfs.ops.file_id_create((conn)->vfs.handles.file_id_create, (dev), (inode)))
/* NT ACL operations. */
#define SMB_VFS_FGET_NT_ACL(fsp, fd, security_info, ppdesc) ((fsp)->conn->vfs.ops.fget_nt_acl((fsp)->conn->vfs.handles.fget_nt_acl, (fsp), (fd), (security_info), (ppdesc)))
@@ -197,6 +198,7 @@
#define SMB_VFS_OPAQUE_REALPATH(conn, path, resolved_path) ((conn)->vfs_opaque.ops.realpath((conn)->vfs_opaque.handles.realpath, (path), (resolved_path)))
#define SMB_VFS_OPAQUE_NOTIFY_WATCH(conn, ctx, e, callback, private_data, handle_p) ((conn)->vfs_opaque.ops.notify_watch((conn)->vfs_opaque.handles.notify_watch, (ctx), (e), (callback), (private_data), (handle_p)))
#define SMB_VFS_OPAQUE_CHFLAGS(conn, path, flags) ((conn)->vfs_opaque.ops.chflags((conn)->vfs_opaque.handles.chflags, (path), (flags)))
+#define SMB_VFS_OPAQUE_FILE_ID_CREATE(conn, dev, inode) ((conn)->vfs.ops_opaque.file_id_create((conn)->vfs_opaque.handles.file_id_create, (dev), (inode)))
/* NT ACL operations. */
#define SMB_VFS_OPAQUE_FGET_NT_ACL(fsp, fd, security_info, ppdesc) ((fsp)->conn->vfs_opaque.ops.fget_nt_acl((fsp)->conn->vfs_opaque.handles.fget_nt_acl, (fsp), (fd), (security_info), (ppdesc)))
@@ -315,6 +317,7 @@
#define SMB_VFS_NEXT_REALPATH(handle, path, resolved_path) ((handle)->vfs_next.ops.realpath((handle)->vfs_next.handles.realpath, (path), (resolved_path)))
#define SMB_VFS_NEXT_NOTIFY_WATCH(conn, ctx, e, callback, private_data, handle_p) ((conn)->vfs_next.ops.notify_watch((conn)->vfs_next.handles.notify_watch, (ctx), (e), (callback), (private_data), (handle_p)))
#define SMB_VFS_NEXT_CHFLAGS(handle, path, flags) ((handle)->vfs_next.ops.chflags((handle)->vfs_next.handles.chflags, (path), (flags)))
+#define SMB_VFS_NEXT_FILE_ID_CREATE(handle, dev, inode) ((handle)->vfs_next.ops.file_id_create((handle)->vfs_next.handles.file_id_create, (dev), (inode)))
/* NT ACL operations. */
#define SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, fd, security_info, ppdesc) ((handle)->vfs_next.ops.fget_nt_acl((handle)->vfs_next.handles.fget_nt_acl, (fsp), (fd), (security_info), (ppdesc)))
diff --git a/source3/lib/file_id.c b/source3/lib/file_id.c
index 11263af089..a92cca08fa 100644
--- a/source3/lib/file_id.c
+++ b/source3/lib/file_id.c
@@ -25,7 +25,7 @@
return a file_id which gives a unique ID for a file given the device and
inode numbers
*/
-struct file_id file_id_create(SMB_DEV_T dev, SMB_INO_T inode)
+struct file_id file_id_create_dev(SMB_DEV_T dev, SMB_INO_T inode)
{
struct file_id key;
/* the ZERO_STRUCT ensures padding doesn't break using the key as a
@@ -39,12 +39,11 @@ struct file_id file_id_create(SMB_DEV_T dev, SMB_INO_T inode)
/*
generate a file_id from a stat structure
*/
-struct file_id file_id_sbuf(const SMB_STRUCT_STAT *sbuf)
+struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_STAT *sbuf)
{
- return file_id_create(sbuf->st_dev, sbuf->st_ino);
+ return SMB_VFS_FILE_ID_CREATE(conn, sbuf->st_dev, sbuf->st_ino);
}
-
/*
return True if two file_id structures are equal
*/
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 6d14e475f1..76a03e9ffb 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -927,6 +927,11 @@ static int vfswrap_chflags(vfs_handle_struct *handle, const char *path, int flag
#endif
}
+static struct file_id vfswrap_file_id_create(struct vfs_handle_struct *handle, SMB_DEV_T dev, SMB_INO_T inode)
+{
+ return file_id_create_dev(dev, inode);
+}
+
static size_t vfswrap_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info, SEC_DESC **ppdesc)
{
size_t result;
@@ -1314,6 +1319,8 @@ static vfs_op_tuple vfs_default_ops[] = {
SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(vfswrap_chflags), SMB_VFS_OP_CHFLAGS,
SMB_VFS_LAYER_OPAQUE},
+ {SMB_VFS_OP(vfswrap_file_id_create), SMB_VFS_OP_FILE_ID_CREATE,
+ SMB_VFS_LAYER_OPAQUE},
/* NT ACL operations. */
diff --git a/source3/printing/printfsp.c b/source3/printing/printfsp.c
index 821f46041d..ab628e29fc 100644
--- a/source3/printing/printfsp.c
+++ b/source3/printing/printfsp.c
@@ -86,7 +86,7 @@ NTSTATUS print_fsp_open(connection_struct *conn, const char *fname,
fsp->wcp = NULL;
SMB_VFS_FSTAT(fsp,fsp->fh->fd, &sbuf);
fsp->mode = sbuf.st_mode;
- fsp->file_id = file_id_sbuf(&sbuf);
+ fsp->file_id = vfs_file_id_from_sbuf(conn, &sbuf);
conn->num_files_open++;
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 7c3e1eef28..9718fef4ea 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -265,7 +265,7 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
goto done;
}
- id = file_id_sbuf(&sbuf);
+ id = vfs_file_id_from_sbuf(conn, &sbuf);
if (!file_id_equal(&fsp->file_id, &id)) {
DEBUG(5,("close_remove_share_mode: file %s. Delete on close "
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index a1b56736a0..d5c22e81c3 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -540,7 +540,8 @@ NTSTATUS unix_convert(connection_struct *conn,
} /* end else */
#ifdef DEVELOPER
- if (VALID_STAT(st) && get_delete_on_close_flag(file_id_sbuf(&st))) {
+ if (VALID_STAT(st) &&
+ get_delete_on_close_flag(vfs_file_id_from_sbuf(conn, &st))) {
result = NT_STATUS_DELETE_PENDING;
goto fail;
}
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 432f6b808a..bff445bf61 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -357,7 +357,7 @@ static NTSTATUS open_file(files_struct *fsp,
}
fsp->mode = psbuf->st_mode;
- fsp->file_id = file_id_sbuf(psbuf);
+ fsp->file_id = vfs_file_id_from_sbuf(conn, psbuf);
fsp->vuid = req ? req->vuid : UID_FIELD_INVALID;
fsp->file_pid = req ? req->smbpid : 0;
fsp->can_lock = True;
@@ -1416,7 +1416,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn,
return status;
}
- fsp->file_id = file_id_sbuf(psbuf);
+ fsp->file_id = vfs_file_id_from_sbuf(conn, psbuf);
fsp->share_access = share_access;
fsp->fh->private_options = create_options;
fsp->access_mask = open_access_mask; /* We change this to the
@@ -1432,7 +1432,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn,
}
if (file_existed) {
- id = file_id_sbuf(psbuf);
+ id = vfs_file_id_from_sbuf(conn, psbuf);
lck = get_share_mode_lock(NULL, id,
conn->connectpath,
@@ -2160,7 +2160,7 @@ NTSTATUS open_directory(connection_struct *conn,
*/
fsp->mode = psbuf->st_mode;
- fsp->file_id = file_id_sbuf(psbuf);
+ fsp->file_id = vfs_file_id_from_sbuf(conn, psbuf);
fsp->vuid = req ? req->vuid : UID_FIELD_INVALID;
fsp->file_pid = req ? req->smbpid : 0;
fsp->can_lock = False;
@@ -2288,7 +2288,7 @@ NTSTATUS open_file_stat(connection_struct *conn, struct smb_request *req,
*/
fsp->mode = psbuf->st_mode;
- fsp->file_id = file_id_sbuf(psbuf);
+ fsp->file_id = vfs_file_id_from_sbuf(conn, psbuf);
fsp->vuid = req ? req->vuid : UID_FIELD_INVALID;
fsp->file_pid = req ? req->smbpid : 0;
fsp->can_lock = False;
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index ec27450593..cebb905a9e 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -4563,7 +4563,8 @@ NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, pstrin
}
if (dst_exists) {
- files_struct *dst_fsp = file_find_di_first(file_id_sbuf(&sbuf1));
+ struct file_id fileid = vfs_file_id_from_sbuf(conn, &sbuf1);
+ files_struct *dst_fsp = file_find_di_first(fileid);
if (dst_fsp) {
DEBUG(3, ("rename_internals_fsp: Target file open\n"));
return NT_STATUS_ACCESS_DENIED;
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 77a13ad186..2b0925d195 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -3312,6 +3312,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn, char *inbuf, char *
time_t create_time, mtime, atime;
struct timespec create_time_ts, mtime_ts, atime_ts;
files_struct *fsp = NULL;
+ struct file_id fileid;
TALLOC_CTX *data_ctx = NULL;
struct ea_list *ea_list = NULL;
uint32 access_mask = 0x12019F; /* Default - GENERIC_EXECUTE mapping from Windows */
@@ -3378,7 +3379,8 @@ static int call_trans2qfilepathinfo(connection_struct *conn, char *inbuf, char *
return UNIXERROR(ERRDOS,ERRbadpath);
}
- delete_pending = get_delete_on_close_flag(file_id_sbuf(&sbuf));
+ fileid = vfs_file_id_from_sbuf(conn, &sbuf);
+ delete_pending = get_delete_on_close_flag(fileid);
} else {
/*
* Original code - this is an open file.
@@ -3391,7 +3393,8 @@ static int call_trans2qfilepathinfo(connection_struct *conn, char *inbuf, char *
return(UNIXERROR(ERRDOS,ERRbadfid));
}
pos = fsp->fh->position_information;
- delete_pending = get_delete_on_close_flag(file_id_sbuf(&sbuf));
+ fileid = vfs_file_id_from_sbuf(conn, &sbuf);
+ delete_pending = get_delete_on_close_flag(fileid);
access_mask = fsp->access_mask;
}
} else {
@@ -3446,7 +3449,8 @@ static int call_trans2qfilepathinfo(connection_struct *conn, char *inbuf, char *
return UNIXERROR(ERRDOS,ERRbadpath);
}
- delete_pending = get_delete_on_close_flag(file_id_sbuf(&sbuf));
+ fileid = vfs_file_id_from_sbuf(conn, &sbuf);
+ delete_pending = get_delete_on_close_flag(fileid);
if (delete_pending) {
return ERROR_NT(NT_STATUS_DELETE_PENDING);
}
@@ -3572,8 +3576,10 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
mtime_ts = fsp->pending_modtime;
}
} else {
+ files_struct *fsp1;
/* Do we have this path open ? */
- files_struct *fsp1 = file_find_di_first(file_id_sbuf(&sbuf));
+ fileid = vfs_file_id_from_sbuf(conn, &sbuf);
+ fsp1 = file_find_di_first(fileid);
if (fsp1 && !null_timespec(fsp1->pending_modtime)) {
/* the pending modtime overrides the current modtime */
mtime_ts = fsp1->pending_modtime;