summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-01-30 18:16:51 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:17:31 -0500
commit845647f4687431e321ee98a7b48cc324c345cbd4 (patch)
tree02ab13b0cec5c1d2b371613b3acfca5109f9aff8 /source3/smbd
parentc51e4c3440dc9189f3532ecf69f5b08920b285bb (diff)
downloadsamba-845647f4687431e321ee98a7b48cc324c345cbd4.tar.gz
samba-845647f4687431e321ee98a7b48cc324c345cbd4.tar.bz2
samba-845647f4687431e321ee98a7b48cc324c345cbd4.zip
r21057: More refactoring into functions.
Jeremy. (This used to be commit fe2d7cb2dcd7c4d25d71f196aa557ce3e287bb4c)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/reply.c4
-rw-r--r--source3/smbd/trans2.c156
2 files changed, 95 insertions, 65 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 7cb086841d..a1edce935d 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -3999,7 +3999,7 @@ static BOOL rename_path_prefix_equal(const char *src, const char *dest)
Rename an open file - given an fsp.
****************************************************************************/
-NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, char *newname, uint32 attrs, BOOL replace_if_exists)
+NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, pstring newname, uint32 attrs, BOOL replace_if_exists)
{
SMB_STRUCT_STAT sbuf;
pstring newname_last_component;
@@ -4116,7 +4116,7 @@ NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, char *
code.
****************************************************************************/
-NTSTATUS rename_internals(connection_struct *conn, char *name, char *newname, uint32 attrs, BOOL replace_if_exists, BOOL has_wild)
+NTSTATUS rename_internals(connection_struct *conn, pstring name, pstring newname, uint32 attrs, BOOL replace_if_exists, BOOL has_wild)
{
pstring directory;
pstring mask;
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 679f589b49..6167fa30bd 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -3881,7 +3881,7 @@ static int smb_file_position_information(connection_struct *conn,
}
#endif /* LARGE_SMB_OFF_T */
- DEBUG(10,("call_trans2setfilepathinfo: Set file position information for file %s to %.0f\n",
+ DEBUG(10,("smb_file_position_information: Set file position information for file %s to %.0f\n",
fsp->fsp_name, (double)position_information ));
fsp->fh->position_information = position_information;
@@ -3976,7 +3976,7 @@ static int smb_set_file_unix_link(connection_struct *conn,
}
}
- DEBUG(10,("call_trans2setfilepathinfo: SMB_SET_FILE_UNIX_LINK doing symlink %s -> %s\n",
+ DEBUG(10,("smb_set_file_unix_link: SMB_SET_FILE_UNIX_LINK doing symlink %s -> %s\n",
newname, link_target ));
if (SMB_VFS_SYMLINK(conn,link_target,newname) != 0) {
@@ -4015,7 +4015,7 @@ static int smb_set_file_unix_hlink(connection_struct *conn,
return ERROR_NT(status);
}
- DEBUG(10,("call_trans2setfilepathinfo: SMB_SET_FILE_UNIX_LINK doing hard link %s -> %s\n",
+ DEBUG(10,("smb_set_file_unix_hlink: SMB_SET_FILE_UNIX_LINK doing hard link %s -> %s\n",
fname, oldname));
status = hardlink_internals(conn, oldname, fname);
@@ -4029,6 +4029,86 @@ static int smb_set_file_unix_hlink(connection_struct *conn,
}
/****************************************************************************
+ Deal with SMB_FILE_RENAME_INFORMATION.
+****************************************************************************/
+
+static int smb_file_rename_information(connection_struct *conn,
+ char *inbuf,
+ char *outbuf,
+ int bufsize,
+ char *params,
+ char *pdata,
+ int total_data,
+ unsigned int max_data_bytes,
+ files_struct *fsp,
+ pstring fname)
+{
+ BOOL overwrite;
+ /* uint32 root_fid; */ /* Not used */
+ uint32 len;
+ pstring newname;
+ pstring base_name;
+ NTSTATUS status = NT_STATUS_OK;
+ char *p;
+
+ if (total_data < 13) {
+ return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
+ }
+
+ overwrite = (CVAL(pdata,0) ? True : False);
+ /* root_fid = IVAL(pdata,4); */
+ len = IVAL(pdata,8);
+
+ if (len > (total_data - 12) || (len == 0)) {
+ return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
+ }
+
+ srvstr_get_path(inbuf, newname, &pdata[12], sizeof(newname), len, 0, &status);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ERROR_NT(status);
+ }
+
+ /* Check the new name has no '/' characters. */
+ if (strchr_m(newname, '/')) {
+ return ERROR_NT(NT_STATUS_NOT_SUPPORTED);
+ }
+
+ RESOLVE_DFSPATH(newname, conn, inbuf, outbuf);
+
+ /* Create the base directory. */
+ pstrcpy(base_name, fname);
+ p = strrchr_m(base_name, '/');
+ if (p) {
+ *p = '\0';
+ }
+ /* Append the new name. */
+ pstrcat(base_name, "/");
+ pstrcat(base_name, newname);
+
+ if (fsp) {
+ DEBUG(10,("smb_file_rename_information: SMB_FILE_RENAME_INFORMATION (fnum %d) %s -> %s\n",
+ fsp->fnum, fsp->fsp_name, base_name ));
+ status = rename_internals_fsp(conn, fsp, base_name, 0, overwrite);
+ } else {
+ DEBUG(10,("smb_file_rename_information: SMB_FILE_RENAME_INFORMATION %s -> %s\n",
+ fname, newname ));
+ status = rename_internals(conn, fname, base_name, 0, overwrite, False);
+ }
+
+ if (!NT_STATUS_IS_OK(status)) {
+ if (open_was_deferred(SVAL(inbuf,smb_mid))) {
+ /* We have re-scheduled this call. */
+ return -1;
+ }
+ return ERROR_NT(status);
+ }
+
+ SSVAL(params,0,0);
+ send_trans2_replies(outbuf, bufsize, params, 2, pdata, 0, max_data_bytes);
+ return -1;
+}
+
+/****************************************************************************
Reply to a TRANS2_SETFILEINFO (set file info by fileid or pathname).
****************************************************************************/
@@ -4590,66 +4670,16 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
case SMB_FILE_RENAME_INFORMATION:
{
- BOOL overwrite;
- /* uint32 root_fid; */ /* Not used */
- uint32 len;
- pstring newname;
- pstring base_name;
- char *p;
-
- if (total_data < 13) {
- return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
- }
-
- overwrite = (CVAL(pdata,0) ? True : False);
- /* root_fid = IVAL(pdata,4); */
- len = IVAL(pdata,8);
-
- if (len > (total_data - 12) || (len == 0)) {
- return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
- }
-
- srvstr_get_path(inbuf, newname, &pdata[12], sizeof(newname), len, 0, &status);
- if (!NT_STATUS_IS_OK(status)) {
- return ERROR_NT(status);
- }
-
- /* Check the new name has no '/' characters. */
- if (strchr_m(newname, '/'))
- return ERROR_NT(NT_STATUS_NOT_SUPPORTED);
-
- RESOLVE_DFSPATH(newname, conn, inbuf, outbuf);
-
- /* Create the base directory. */
- pstrcpy(base_name, fname);
- p = strrchr_m(base_name, '/');
- if (p)
- *p = '\0';
- /* Append the new name. */
- pstrcat(base_name, "/");
- pstrcat(base_name, newname);
-
- if (fsp) {
- DEBUG(10,("call_trans2setfilepathinfo: SMB_FILE_RENAME_INFORMATION (fnum %d) %s -> %s\n",
- fsp->fnum, fsp->fsp_name, base_name ));
- status = rename_internals_fsp(conn, fsp, base_name, 0, overwrite);
- } else {
- DEBUG(10,("call_trans2setfilepathinfo: SMB_FILE_RENAME_INFORMATION %s -> %s\n",
- fname, newname ));
- status = rename_internals(conn, fname, base_name, 0, overwrite, False);
- }
-
- if (!NT_STATUS_IS_OK(status)) {
- if (open_was_deferred(SVAL(inbuf,smb_mid))) {
- /* We have re-scheduled this call. */
- return -1;
- }
- return ERROR_NT(status);
- }
-
- SSVAL(params,0,0);
- send_trans2_replies(outbuf, bufsize, params, 2, *ppdata, 0, max_data_bytes);
- return(-1);
+ return smb_file_rename_information(conn,
+ inbuf,
+ outbuf,
+ bufsize,
+ params,
+ pdata,
+ total_data,
+ max_data_bytes,
+ fsp,
+ fname);
}
#if defined(HAVE_POSIX_ACLS)