* Create an internal fsp for an *existing* directory.
*
* This should only be used by callers in the VFS that need to control the
- * opening of the directory.
+ * opening of the directory. Otherwise use open_internal_dirfsp_at().
*/
NTSTATUS create_internal_dirfsp_at(connection_struct *conn,
struct files_struct *dirfsp,
return NT_STATUS_OK;
}
+/*
+ * Open an internal fsp for an *existing* directory.
+ */
+NTSTATUS open_internal_dirfsp_at(connection_struct *conn,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_dname,
+ struct files_struct **_fsp)
+{
+ struct files_struct *fsp = NULL;
+ int open_flags = O_RDONLY;
+ NTSTATUS status;
+
+ SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
+
+ status = create_internal_dirfsp_at(conn, dirfsp, smb_dname, &fsp);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+#ifdef O_DIRECTORY
+ open_flags |= O_DIRECTORY;
+#endif
+ status = fd_open(conn, fsp, open_flags, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_INFO("Could not open fd for %s (%s)\n",
+ smb_fname_str_dbg(smb_dname),
+ nt_errstr(status));
+ file_free(NULL, fsp);
+ return status;
+ }
+
+
+ *_fsp = fsp;
+ return NT_STATUS_OK;
+}
+
/****************************************************************************
Close all open files for a connection.
****************************************************************************/
const struct smb_filename *smb_dname,
struct files_struct **_fsp);
-NTSTATUS open_internal_dir_fsp(connection_struct *conn,
- const struct smb_filename *smb_dname,
- struct files_struct **_fsp);
+NTSTATUS open_internal_dirfsp_at(connection_struct *conn,
+ struct files_struct *dirfsp,
+ const struct smb_filename *smb_dname,
+ struct files_struct **_fsp);
/* The following definitions come from smbd/ipc.c */