Make check_same_stat() and check_same_dev_ino() common functions.
authorJeremy Allison <jra@samba.org>
Mon, 9 Jul 2012 19:26:56 +0000 (12:26 -0700)
committerJeremy Allison <jra@samba.org>
Mon, 9 Jul 2012 19:26:56 +0000 (12:26 -0700)
source3/include/proto.h
source3/lib/util.c
source3/smbd/open.c
source3/smbd/proto.h

index b7f2852a48607c34169780e18efff07703da3a62..76259835184b42728b64a2114a506bae9a5cc5a8 100644 (file)
@@ -400,6 +400,10 @@ bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf,
                     bool fake_dir_create_times);
 bool socket_exist(const char *fname);
 uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf);
+bool check_same_dev_ino(const SMB_STRUCT_STAT *sbuf1,
+                       const SMB_STRUCT_STAT *sbuf2);
+bool check_same_stat(const SMB_STRUCT_STAT *sbuf1,
+                       const SMB_STRUCT_STAT *sbuf2);
 void show_msg(const char *buf);
 int set_message_bcc(char *buf,int num_bytes);
 ssize_t message_push_blob(uint8 **outbuf, DATA_BLOB blob);
index 697f7b143d1b296a54a5be6f928e10a86477a9a6..fa464482969ba8120949901eb8f5a17badc3e1c8 100644 (file)
@@ -126,6 +126,35 @@ uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf)
        return sbuf->st_ex_size;
 }
 
+/****************************************************************************
+ Check two stats have identical dev and ino fields.
+****************************************************************************/
+
+bool check_same_dev_ino(const SMB_STRUCT_STAT *sbuf1,
+                        const SMB_STRUCT_STAT *sbuf2)
+{
+       if (sbuf1->st_ex_dev != sbuf2->st_ex_dev ||
+                       sbuf1->st_ex_ino != sbuf2->st_ex_ino) {
+               return false;
+       }
+       return true;
+}
+
+/****************************************************************************
+ Check if a stat struct is identical for use.
+****************************************************************************/
+
+bool check_same_stat(const SMB_STRUCT_STAT *sbuf1,
+                       const SMB_STRUCT_STAT *sbuf2)
+{
+       if (sbuf1->st_ex_uid != sbuf2->st_ex_uid ||
+                       sbuf1->st_ex_gid != sbuf2->st_ex_gid ||
+                       !check_same_dev_ino(sbuf1, sbuf2)) {
+               return false;
+       }
+       return true;
+}
+
 /*******************************************************************
  Show a smb message structure.
 ********************************************************************/
index 145a8a4e6af495e979031c09bd88e692c25725c7..88f779a527e401c1d99463f1429c70bf77502240 100644 (file)
@@ -39,20 +39,6 @@ struct deferred_open_record {
         struct file_id id;
 };
 
-/****************************************************************************
- Check two stats have identical dev and ino fields.
-****************************************************************************/
-
-static bool check_same_dev_ino(const SMB_STRUCT_STAT *sbuf1,
-                       const SMB_STRUCT_STAT *sbuf2)
-{
-       if (sbuf1->st_ex_dev != sbuf2->st_ex_dev ||
-                       sbuf1->st_ex_ino != sbuf2->st_ex_ino) {
-               return false;
-       }
-       return true;
-}
-
 /****************************************************************************
  If the requester wanted DELETE_ACCESS and was rejected because
  the file ACL didn't include DELETE_ACCESS, see if the parent ACL
@@ -2750,21 +2736,6 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
        return NT_STATUS_OK;
 }
 
-/****************************************************************************
- Ensure we didn't get symlink raced on opening a directory.
-****************************************************************************/
-
-bool check_same_stat(const SMB_STRUCT_STAT *sbuf1,
-                       const SMB_STRUCT_STAT *sbuf2)
-{
-       if (sbuf1->st_ex_uid != sbuf2->st_ex_uid ||
-                       sbuf1->st_ex_gid != sbuf2->st_ex_gid ||
-                       !check_same_dev_ino(sbuf1, sbuf2)) {
-               return false;
-       }
-       return true;
-}
-
 /****************************************************************************
  Open a directory from an NT SMB call.
 ****************************************************************************/
index 4279755d66ff41bb25f0ff0f475ec6565e8ea7db..725f89c2296b5ea60a11716495a7f2ff78fb11f9 100644 (file)
@@ -620,8 +620,6 @@ bool is_deferred_open_async(const void *ptr);
 NTSTATUS open_file_fchmod(connection_struct *conn,
                          struct smb_filename *smb_fname,
                          files_struct **result);
-bool check_same_stat(const SMB_STRUCT_STAT *sbuf1,
-                       const SMB_STRUCT_STAT *sbuf2);
 NTSTATUS create_directory(connection_struct *conn, struct smb_request *req,
                          struct smb_filename *smb_dname);
 void msg_file_was_renamed(struct messaging_context *msg,