summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-01-30 02:27:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:17:30 -0500
commite90b6c743deeb8db2e7c779f5427d8b45ee77aef (patch)
tree6ea5655af60ec5b45bc8a688078f6f840d5eb826
parent54aefc22679012af4deecea1160396ef8d3f4b86 (diff)
downloadsamba-e90b6c743deeb8db2e7c779f5427d8b45ee77aef.tar.gz
samba-e90b6c743deeb8db2e7c779f5427d8b45ee77aef.tar.bz2
samba-e90b6c743deeb8db2e7c779f5427d8b45ee77aef.zip
r21054: More function refactoring.
Jeremy. (This used to be commit b6f43e9509cfedbf77c883cff793c469d6f86370)
-rw-r--r--source3/smbd/trans2.c76
1 files changed, 52 insertions, 24 deletions
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 7450f0581a..679f589b49 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -3679,7 +3679,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
code.
****************************************************************************/
-NTSTATUS hardlink_internals(connection_struct *conn, char *oldname, char *newname)
+NTSTATUS hardlink_internals(connection_struct *conn, pstring oldname, pstring newname)
{
SMB_STRUCT_STAT sbuf1, sbuf2;
pstring last_component_oldname;
@@ -3988,6 +3988,45 @@ static int smb_set_file_unix_link(connection_struct *conn,
return -1;
}
+/****************************************************************************
+ Deal with SMB_SET_FILE_UNIX_HLINK (create a UNIX hard link).
+****************************************************************************/
+
+static int smb_set_file_unix_hlink(connection_struct *conn,
+ char *inbuf,
+ char *outbuf,
+ int bufsize,
+ char *params,
+ char *pdata,
+ int total_data,
+ unsigned int max_data_bytes,
+ pstring fname)
+{
+ pstring oldname;
+ NTSTATUS status = NT_STATUS_OK;
+
+ /* Set a hard link. */
+ if (total_data == 0) {
+ return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
+ }
+
+ srvstr_get_path(inbuf, oldname, pdata, sizeof(oldname), total_data, STR_TERMINATE, &status);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ERROR_NT(status);
+ }
+
+ DEBUG(10,("call_trans2setfilepathinfo: SMB_SET_FILE_UNIX_LINK doing hard link %s -> %s\n",
+ fname, oldname));
+
+ status = hardlink_internals(conn, oldname, fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ 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).
@@ -4534,30 +4573,19 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
case SMB_SET_FILE_UNIX_HLINK:
{
- pstring oldname;
- char *newname = fname;
-
- /* Set a hard link. */
- if (total_data == 0) {
- return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
- }
-
- srvstr_get_path(inbuf, oldname, pdata, sizeof(oldname), total_data, STR_TERMINATE, &status);
- if (!NT_STATUS_IS_OK(status)) {
- return ERROR_NT(status);
- }
-
- DEBUG(10,("call_trans2setfilepathinfo: SMB_SET_FILE_UNIX_LINK doing hard link %s -> %s\n",
- fname, oldname));
-
- status = hardlink_internals(conn, oldname, newname);
- if (!NT_STATUS_IS_OK(status)) {
- return ERROR_NT(status);
+ if (tran_call != TRANSACT2_SETPATHINFO) {
+ /* We must have a pathname for this. */
+ return ERROR_NT(NT_STATUS_INVALID_LEVEL);
}
-
- SSVAL(params,0,0);
- send_trans2_replies(outbuf, bufsize, params, 2, *ppdata, 0, max_data_bytes);
- return(-1);
+ return smb_set_file_unix_hlink(conn,
+ inbuf,
+ outbuf,
+ bufsize,
+ params,
+ *ppdata,
+ total_data,
+ max_data_bytes,
+ fname);
}
case SMB_FILE_RENAME_INFORMATION: