return NT_STATUS_OK;
}
+/****************************************************************************
+ Deal with SMB_SET_FILE_UNIX_HLINK (create a UNIX hard link).
+****************************************************************************/
+
+static NTSTATUS smb_set_file_unix_hlink(connection_struct *conn,
+ struct smb_request *req,
+ const char *pdata, int total_data,
+ struct smb_filename *smb_fname_new)
+{
+ char *oldname = NULL;
+ struct files_struct *src_dirfsp = NULL;
+ struct smb_filename *smb_fname_old = NULL;
+ uint32_t ucf_flags = ucf_flags_from_smb_request(req);
+ NTTIME old_twrp = 0;
+ TALLOC_CTX *ctx = talloc_tos();
+ NTSTATUS status = NT_STATUS_OK;
+
+ if (!CAN_WRITE(conn)) {
+ return NT_STATUS_DOS(ERRSRV, ERRaccess);
+ }
+
+ /* Set a hard link. */
+ if (total_data == 0) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (req->posix_pathnames) {
+ srvstr_get_path_posix(ctx,
+ pdata,
+ req->flags2,
+ &oldname,
+ pdata,
+ total_data,
+ STR_TERMINATE,
+ &status);
+ } else {
+ srvstr_get_path(ctx,
+ pdata,
+ req->flags2,
+ &oldname,
+ pdata,
+ total_data,
+ STR_TERMINATE,
+ &status);
+ }
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ DEBUG(10,("smb_set_file_unix_hlink: SMB_SET_FILE_UNIX_LINK doing hard link %s -> %s\n",
+ smb_fname_str_dbg(smb_fname_new), oldname));
+
+ if (ucf_flags & UCF_GMT_PATHNAME) {
+ extract_snapshot_token(oldname, &old_twrp);
+ }
+ status = filename_convert_dirfsp(ctx,
+ conn,
+ oldname,
+ ucf_flags,
+ old_twrp,
+ &src_dirfsp,
+ &smb_fname_old);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ return hardlink_internals(ctx,
+ conn,
+ req,
+ false,
+ src_dirfsp,
+ smb_fname_old,
+ NULL, /* new_dirfsp */
+ smb_fname_new);
+}
+
static void call_trans2setpathinfo(
connection_struct *conn,
struct smb_request *req,
status = smb_set_file_unix_link(
conn, req, *ppdata, total_data, smb_fname);
break;
+
+ case SMB_SET_FILE_UNIX_HLINK:
+ status = smb_set_file_unix_hlink(
+ conn, req, *ppdata, total_data, smb_fname);
+ break;
}
if (info_level_handled) {
return NT_STATUS_OK;
}
-/****************************************************************************
- Deal with SMB_SET_FILE_UNIX_HLINK (create a UNIX hard link).
-****************************************************************************/
-
-static NTSTATUS smb_set_file_unix_hlink(connection_struct *conn,
- struct smb_request *req,
- const char *pdata, int total_data,
- struct smb_filename *smb_fname_new)
-{
- char *oldname = NULL;
- struct files_struct *src_dirfsp = NULL;
- struct smb_filename *smb_fname_old = NULL;
- uint32_t ucf_flags = ucf_flags_from_smb_request(req);
- NTTIME old_twrp = 0;
- TALLOC_CTX *ctx = talloc_tos();
- NTSTATUS status = NT_STATUS_OK;
-
- /* Set a hard link. */
- if (total_data == 0) {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- if (req->posix_pathnames) {
- srvstr_get_path_posix(ctx,
- pdata,
- req->flags2,
- &oldname,
- pdata,
- total_data,
- STR_TERMINATE,
- &status);
- } else {
- srvstr_get_path(ctx,
- pdata,
- req->flags2,
- &oldname,
- pdata,
- total_data,
- STR_TERMINATE,
- &status);
- }
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- DEBUG(10,("smb_set_file_unix_hlink: SMB_SET_FILE_UNIX_LINK doing hard link %s -> %s\n",
- smb_fname_str_dbg(smb_fname_new), oldname));
-
- if (ucf_flags & UCF_GMT_PATHNAME) {
- extract_snapshot_token(oldname, &old_twrp);
- }
- status = filename_convert_dirfsp(ctx,
- conn,
- oldname,
- ucf_flags,
- old_twrp,
- &src_dirfsp,
- &smb_fname_old);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- return hardlink_internals(ctx,
- conn,
- req,
- false,
- src_dirfsp,
- smb_fname_old,
- NULL, /* new_dirfsp */
- smb_fname_new);
-}
-
/****************************************************************************
Deal with SMB2_FILE_RENAME_INFORMATION_INTERNAL
****************************************************************************/
break;
}
- case SMB_SET_FILE_UNIX_HLINK:
- {
- if (smb_fname == NULL) {
- /* We must have a pathname for this. */
- return NT_STATUS_INVALID_LEVEL;
- }
- status = smb_set_file_unix_hlink(conn, req,
- pdata, total_data,
- smb_fname);
- break;
- }
-
#if defined(HAVE_POSIX_ACLS)
case SMB_SET_POSIX_ACL:
{