r25055: Add file_id_string_tos
authorVolker Lendecke <vlendec@samba.org>
Mon, 10 Sep 2007 10:56:07 +0000 (10:56 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:30:36 +0000 (12:30 -0500)
This removes file_id_string_static and file_id_string_static2

14 files changed:
source/lib/file_id.c
source/locking/brlock.c
source/locking/locking.c
source/modules/vfs_full_audit.c
source/smbd/close.c
source/smbd/files.c
source/smbd/open.c
source/smbd/oplock.c
source/smbd/oplock_irix.c
source/smbd/oplock_linux.c
source/smbd/reply.c
source/torture/locktest.c
source/torture/locktest2.c
source/utils/status.c

index a92cca08fa5f06da5d9d51c292bf9d528d35dab9..0a1913a9c20a4c76529ab2f1c046bc9ced4622e5 100644 (file)
@@ -55,25 +55,11 @@ BOOL file_id_equal(const struct file_id *id1, const struct file_id *id2)
 /*
   a static string for a file_id structure
  */
-const char *file_id_static_string(const struct file_id *id)
+const char *file_id_string_tos(const struct file_id *id)
 {
-       static char buf[32];
-       snprintf(buf, sizeof(buf), "%llx:%llx", 
-                (unsigned long long)id->devid, 
-                (unsigned long long)id->inode);
-       return buf;
-}
-
-/*
-  a 2nd static string for a file_id structure so we can print 2 at once
- */
-const char *file_id_static_string2(const struct file_id *id)
-{
-       static char buf[32];
-       snprintf(buf, sizeof(buf), "%llx:%llx", 
-                (unsigned long long)id->devid, 
-                (unsigned long long)id->inode);
-       return buf;
+       return talloc_asprintf(talloc_tos(), "%llx:%llx", 
+                              (unsigned long long)id->devid, 
+                              (unsigned long long)id->inode);
 }
 
 /*
index 4e15670b04de8023db46cde33636dbec6a03d758..c148fa33f3620de680087884bad8e236e54cb6b1 100644 (file)
@@ -1682,7 +1682,7 @@ static struct byte_range_lock *brl_get_locks_internal(TALLOC_CTX *mem_ctx,
                struct lock_struct *locks = br_lck->lock_data;
                DEBUG(10,("brl_get_locks_internal: %u current locks on file_id %s\n",
                        br_lck->num_locks,
-                         file_id_static_string(&fsp->file_id)));
+                         file_id_string_tos(&fsp->file_id)));
                for( i = 0; i < br_lck->num_locks; i++) {
                        print_lock_struct(i, &locks[i]);
                }
index 7f1f8f41e1db10d62a0e4af090634f42b6b9c7fd..4d6265cc7c4a0a059ddc893180e086c705120dbe 100644 (file)
@@ -458,7 +458,7 @@ char *share_mode_str(int num, struct share_mode_entry *e)
                 e->share_access, e->private_options,
                 e->access_mask, e->op_mid, e->op_type, e->share_file_id,
                 (unsigned int)e->uid, (unsigned int)e->flags,
-                file_id_static_string(&e->id));
+                file_id_string_tos(&e->id));
 
        return share_str;
 }
@@ -906,7 +906,7 @@ BOOL rename_share_filename(struct messaging_context *msg_ctx,
                DEBUG(10,("rename_share_filename: sending rename message to pid %s "
                          "file_id %s sharepath %s newname %s\n",
                          procid_str_static(&se->pid),
-                         file_id_static_string(&lck->id),
+                         file_id_string_tos(&lck->id),
                          lck->servicepath, lck->filename ));
 
                messaging_send_buf(msg_ctx, se->pid, MSG_SMB_FILE_RENAME,
index 47646e248f9ddc3001ca6ca1fde6ca9762957a40..3e99e52637769459a14dcbc6acd87ac3854512e4 100644 (file)
@@ -1483,7 +1483,7 @@ static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *ha
 
        do_log(SMB_VFS_OP_FILE_ID_CREATE,
               !file_id_equal(&id_zero, &result),
-              handle, "%s", file_id_static_string(&result));
+              handle, "%s", file_id_string_tos(&result));
 
        return result;
 }
index 30220ce4decd44d32759d4122f015796280caac9..4eb1a3034269d87f047aaae615d4d14e9f3d8307 100644 (file)
@@ -273,8 +273,8 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
                DEBUG(5,("close_remove_share_mode: file %s. stored file_id %s, "
                         "stat file_id %s\n",
                         fsp->fsp_name,
-                        file_id_static_string(&fsp->file_id),
-                        file_id_static_string2(&id)));
+                        file_id_string_tos(&fsp->file_id),
+                        file_id_string_tos(&id)));
                /*
                 * Don't save the errno here, we ignore this error
                 */
index 9d27c69a6b75a5c4f4f4ad7d6bd023097e215455..f3740da32820c171249bbbf74a47b5c38566bb35 100644 (file)
@@ -233,7 +233,7 @@ void file_dump_open_table(void)
        for (fsp=Files;fsp;fsp=fsp->next,count++) {
                DEBUG(10,("Files[%d], fnum = %d, name %s, fd = %d, gen = %lu, fileid=%s\n",
                        count, fsp->fnum, fsp->fsp_name, fsp->fh->fd, (unsigned long)fsp->fh->gen_id,
-                         file_id_static_string(&fsp->file_id)));
+                         file_id_string_tos(&fsp->file_id)));
        }
 }
 
@@ -280,7 +280,7 @@ files_struct *file_find_dif(struct file_id id, unsigned long gen_id)
                            (fsp->oplock_type != FAKE_LEVEL_II_OPLOCK)) {
                                DEBUG(0,("file_find_dif: file %s file_id = %s, gen = %u \
 oplock_type = %u is a stat open with oplock type !\n", fsp->fsp_name, 
-                                        file_id_static_string(&fsp->file_id),
+                                        file_id_string_tos(&fsp->file_id),
                                         (unsigned int)fsp->fh->gen_id,
                                         (unsigned int)fsp->oplock_type ));
                                smb_panic("file_find_dif");
index 6efef2f912f324ba85b54696c56ae585b5317d4f..691599ca972e114c852d05a5464c2d7be6511a7d 100644 (file)
@@ -2339,7 +2339,7 @@ void msg_file_was_renamed(struct messaging_context *msg,
 
        DEBUG(10,("msg_file_was_renamed: Got rename message for sharepath %s, new name %s, "
                "file_id %s\n",
-                 sharepath, newname, file_id_static_string(&id)));
+                 sharepath, newname, file_id_string_tos(&id)));
 
        for(fsp = file_find_di_first(id); fsp; fsp = file_find_di_next(fsp)) {
                if (memcmp(fsp->conn->connectpath, sharepath, sp_len) == 0) {
index e552cb545e150bdb7d382d462e4efa41d321ab25..a5f74b89d05d8890b471d6f0cf0fce599d0c2a44 100644 (file)
@@ -119,7 +119,7 @@ BOOL set_file_oplock(files_struct *fsp, int oplock_type)
 
        DEBUG(5,("set_file_oplock: granted oplock on file %s, %s/%lu, "
                    "tv_sec = %x, tv_usec = %x\n",
-                fsp->fsp_name, file_id_static_string(&fsp->file_id),
+                fsp->fsp_name, file_id_string_tos(&fsp->file_id),
                 fsp->fh->gen_id, (int)fsp->open_time.tv_sec,
                 (int)fsp->open_time.tv_usec ));
 
@@ -192,7 +192,7 @@ BOOL remove_oplock(files_struct *fsp)
        if (!ret) {
                DEBUG(0,("remove_oplock: failed to remove share oplock for "
                         "file %s fnum %d, %s\n",
-                        fsp->fsp_name, fsp->fnum, file_id_static_string(&fsp->file_id)));
+                        fsp->fsp_name, fsp->fnum, file_id_string_tos(&fsp->file_id)));
        }
        release_file_oplock(fsp);
        TALLOC_FREE(lck);
@@ -217,7 +217,7 @@ BOOL downgrade_oplock(files_struct *fsp)
        if (!ret) {
                DEBUG(0,("downgrade_oplock: failed to downgrade share oplock "
                         "for file %s fnum %d, file_id %s\n",
-                        fsp->fsp_name, fsp->fnum, file_id_static_string(&fsp->file_id)));
+                        fsp->fsp_name, fsp->fnum, file_id_string_tos(&fsp->file_id)));
        }
 
        downgrade_file_oplock(fsp);
@@ -289,7 +289,7 @@ static files_struct *initial_break_processing(struct file_id id, unsigned long f
 
        if( DEBUGLVL( 3 ) ) {
                dbgtext( "initial_break_processing: called for %s/%u\n",
-                        file_id_static_string(&id), (int)file_id);
+                        file_id_string_tos(&id), (int)file_id);
                dbgtext( "Current oplocks_open (exclusive = %d, levelII = %d)\n",
                        exclusive_oplocks_open, level_II_oplocks_open );
        }
@@ -306,7 +306,7 @@ static files_struct *initial_break_processing(struct file_id id, unsigned long f
                /* The file could have been closed in the meantime - return success. */
                if( DEBUGLVL( 3 ) ) {
                        dbgtext( "initial_break_processing: cannot find open file with " );
-                       dbgtext( "file_id %s gen_id = %lu", file_id_static_string(&id), file_id);
+                       dbgtext( "file_id %s gen_id = %lu", file_id_string_tos(&id), file_id);
                        dbgtext( "allowing break to succeed.\n" );
                }
                return NULL;
@@ -326,7 +326,7 @@ static files_struct *initial_break_processing(struct file_id id, unsigned long f
                if( DEBUGLVL( 3 ) ) {
                        dbgtext( "initial_break_processing: file %s ", fsp->fsp_name );
                        dbgtext( "(file_id = %s gen_id = %lu) has no oplock.\n",
-                                file_id_static_string(&id), fsp->fh->gen_id );
+                                file_id_string_tos(&id), fsp->fh->gen_id );
                        dbgtext( "Allowing break to succeed regardless.\n" );
                }
                return NULL;
@@ -405,7 +405,7 @@ static void process_oplock_async_level2_break_message(struct messaging_context *
        message_to_share_mode_entry(&msg, (char *)data->data);
 
        DEBUG(10, ("Got oplock async level 2 break message from pid %d: %s/%lu\n",
-                  (int)procid_to_pid(&src), file_id_static_string(&msg.id), msg.share_file_id));
+                  (int)procid_to_pid(&src), file_id_string_tos(&msg.id), msg.share_file_id));
 
        fsp = initial_break_processing(msg.id, msg.share_file_id);
 
@@ -493,7 +493,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
        message_to_share_mode_entry(&msg, (char *)data->data);
 
        DEBUG(10, ("Got oplock break message from pid %d: %s/%lu\n",
-                  (int)procid_to_pid(&src), file_id_static_string(&msg.id), msg.share_file_id));
+                  (int)procid_to_pid(&src), file_id_string_tos(&msg.id), msg.share_file_id));
 
        fsp = initial_break_processing(msg.id, msg.share_file_id);
 
@@ -523,7 +523,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
        if (EXCLUSIVE_OPLOCK_TYPE(msg.op_type) &&
            !EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
                DEBUG(3, ("Already downgraded oplock on %s: %s\n",
-                         file_id_static_string(&fsp->file_id),
+                         file_id_string_tos(&fsp->file_id),
                          fsp->fsp_name));
                /* We just send the same message back. */
                messaging_send_buf(msg_ctx, src, MSG_SMB_BREAK_RESPONSE,
@@ -605,7 +605,7 @@ static void process_kernel_oplock_break(struct messaging_context *msg_ctx,
        file_id = (unsigned long)IVAL(data->data, 16);
 
        DEBUG(10, ("Got kernel oplock break message from pid %d: %s/%u\n",
-                  (int)procid_to_pid(&src), file_id_static_string(&id),
+                  (int)procid_to_pid(&src), file_id_string_tos(&id),
                   (unsigned int)file_id));
 
        fsp = initial_break_processing(id, file_id);
@@ -695,7 +695,7 @@ static void process_oplock_break_response(struct messaging_context *msg_ctx,
        message_to_share_mode_entry(&msg, (char *)data->data);
 
        DEBUG(10, ("Got oplock break response from pid %d: %s/%lu mid %u\n",
-                  (int)procid_to_pid(&src), file_id_static_string(&msg.id), msg.share_file_id,
+                  (int)procid_to_pid(&src), file_id_string_tos(&msg.id), msg.share_file_id,
                   (unsigned int)msg.op_mid));
 
        /* Here's the hack from open.c, store the mid in the 'port' field */
@@ -724,7 +724,7 @@ static void process_open_retry_message(struct messaging_context *msg_ctx,
        message_to_share_mode_entry(&msg, (char *)data->data);
 
        DEBUG(10, ("Got open retry msg from pid %d: %s mid %u\n",
-                  (int)procid_to_pid(&src), file_id_static_string(&msg.id),
+                  (int)procid_to_pid(&src), file_id_string_tos(&msg.id),
                   (unsigned int)msg.op_mid));
 
        schedule_deferred_open_smb_message(msg.op_mid);
index 75f807f86b5b9ec34ce4ea70095bf29ac9f830cf..dde32fa288476f187e6d8e988fd4eb00df6f8df1 100644 (file)
@@ -154,7 +154,7 @@ static files_struct *irix_oplock_receive_message(fd_set *fds)
      
        DEBUG(5,("irix_oplock_receive_message: kernel oplock break request "
                 "received for file_id %s gen_id = %ul",
-                file_id_static_string(&fsp->file_id),
+                file_id_string_tos(&fsp->file_id),
                 fsp->fh->gen_id ));
 
        return fsp;
@@ -171,7 +171,7 @@ static BOOL irix_set_kernel_oplock(files_struct *fsp, int oplock_type)
                        DEBUG(0,("irix_set_kernel_oplock: Unable to get "
                                 "kernel oplock on file %s, file_id %s "
                                 "gen_id = %ul. Error was %s\n", 
-                                fsp->fsp_name, file_id_static_string(&fsp->file_id), 
+                                fsp->fsp_name, file_id_string_tos(&fsp->file_id), 
                                 fsp->fh->gen_id,
                                 strerror(errno) ));
                } else {
@@ -180,7 +180,7 @@ static BOOL irix_set_kernel_oplock(files_struct *fsp, int oplock_type)
                                 "gen_id = %ul. Another process had the file "
                                 "open.\n",
                                 fsp->fsp_name, fsp->fh->fd,
-                                file_id_static_string(&fsp->file_id),
+                                file_id_string_tos(&fsp->file_id),
                                 fsp->fh->gen_id ));
                }
                return False;
@@ -188,7 +188,7 @@ static BOOL irix_set_kernel_oplock(files_struct *fsp, int oplock_type)
        
        DEBUG(10,("irix_set_kernel_oplock: got kernel oplock on file %s, file_id = %s "
                  "gen_id = %ul\n",
-                 fsp->fsp_name, file_id_static_string(&fsp->file_id),
+                 fsp->fsp_name, file_id_string_tos(&fsp->file_id),
                  fsp->fh->gen_id));
 
        return True;
@@ -208,7 +208,7 @@ static void irix_release_kernel_oplock(files_struct *fsp)
                int state = sys_fcntl_long(fsp->fh->fd, F_OPLKACK, -1);
                dbgtext("irix_release_kernel_oplock: file %s, file_id = %s"
                        "gen_id = %ul, has kernel oplock state "
-                       "of %x.\n", fsp->fsp_name, file_id_static_string(&fsp->file_id),
+                       "of %x.\n", fsp->fsp_name, file_id_string_tos(&fsp->file_id),
                         fsp->fh->gen_id, state );
        }
 
@@ -221,7 +221,7 @@ static void irix_release_kernel_oplock(files_struct *fsp)
                                "removing kernel oplock on file " );
                        dbgtext("%s, file_id = %s gen_id = %ul. "
                                "Error was %s\n",
-                               fsp->fsp_name, file_id_static_string(&fsp->file_id),
+                               fsp->fsp_name, file_id_string_tos(&fsp->file_id),
                                fsp->fh->gen_id,
                                strerror(errno) );
                }
index 66ed90001555c158a325e4cdae88288c432f74a7..b07c2644a90e88aa012dc308a476c01b65cad6f3 100644 (file)
@@ -168,14 +168,14 @@ static BOOL linux_set_kernel_oplock(files_struct *fsp, int oplock_type)
                DEBUG(3,("linux_set_kernel_oplock: Refused oplock on file %s, "
                         "fd = %d, file_id = %s. (%s)\n",
                         fsp->fsp_name, fsp->fh->fd, 
-                        file_id_static_string(&fsp->file_id),
+                        file_id_string_tos(&fsp->file_id),
                         strerror(errno)));
                return False;
        }
        
        DEBUG(3,("linux_set_kernel_oplock: got kernel oplock on file %s, "
                 "file_id = %s gen_id = %lu\n",
-                fsp->fsp_name, file_id_static_string(&fsp->file_id),
+                fsp->fsp_name, file_id_string_tos(&fsp->file_id),
                 fsp->fh->gen_id));
 
        return True;
@@ -195,7 +195,7 @@ static void linux_release_kernel_oplock(files_struct *fsp)
                int state = fcntl(fsp->fh->fd, F_GETLEASE, 0);
                dbgtext("linux_release_kernel_oplock: file %s, file_id = %s "
                        "gen_id = %lu has kernel oplock state "
-                       "of %x.\n", fsp->fsp_name, file_id_static_string(&fsp->file_id),
+                       "of %x.\n", fsp->fsp_name, file_id_string_tos(&fsp->file_id),
                        fsp->fh->gen_id, state );
        }
 
@@ -208,7 +208,7 @@ static void linux_release_kernel_oplock(files_struct *fsp)
                                "removing kernel oplock on file " );
                        dbgtext("%s, file_id = %s, gen_id = %lu. "
                                "Error was %s\n", fsp->fsp_name,
-                               file_id_static_string(&fsp->file_id),
+                               file_id_string_tos(&fsp->file_id),
                                fsp->fh->gen_id, strerror(errno) );
                }
        }
index dec0e26c414a2e91c7395c9d999e53d6d1ae505e..e3c3e8dff02478ac96f8e2907f1a084378f05ca2 100644 (file)
@@ -5108,7 +5108,7 @@ static void rename_open_files(connection_struct *conn,
                        continue;
                }
                DEBUG(10,("rename_open_files: renaming file fnum %d (file_id %s) from %s -> %s\n",
-                         fsp->fnum, file_id_static_string(&fsp->file_id),
+                         fsp->fnum, file_id_string_tos(&fsp->file_id),
                        fsp->fsp_name, newname ));
                string_set(&fsp->fsp_name, newname);
                did_rename = True;
@@ -5116,7 +5116,7 @@ static void rename_open_files(connection_struct *conn,
 
        if (!did_rename) {
                DEBUG(10,("rename_open_files: no open files on file_id %s for %s\n",
-                         file_id_static_string(&lck->id), newname ));
+                         file_id_string_tos(&lck->id), newname ));
        }
 
        /* Send messages to all smbd's (not ourself) that the name has changed. */
index 34068cf0d70e676ff9f42d73474b382040e0958c..9e4b8953162b0c304a03c2f856b0a91240e3fb1c 100644 (file)
@@ -138,7 +138,7 @@ static void print_brl(struct file_id id,
 #endif
 
        printf("%s   %s    %s  %.0f:%.0f(%.0f)\n", 
-              procid_str_static(&pid), file_id_static_string(&id),
+              procid_str_static(&pid), file_id_string_tos(&id),
               lock_type==READ_LOCK?"R":"W",
               (double)start, (double)start+size-1,(double)size);
 
index 3d86876e899af0123d759466146d6977856fa921..44ef250154a1577a3ef1fa543ecda0555501c28d 100644 (file)
@@ -142,7 +142,7 @@ static void print_brl(struct file_id id, struct server_id pid,
                      void *private_data)
 {
        printf("%6d   %s    %s  %.0f:%.0f(%.0f)\n", 
-              (int)procid_to_pid(&pid), file_id_static_string(&id),
+              (int)procid_to_pid(&pid), file_id_string_tos(&id),
               lock_type==READ_LOCK?"R":"W",
               (double)start, (double)start+size-1,(double)size);
 
index ccf98a5b2959e689f634c6784f89a29658150796..96f4ae68886bfca3ba8b687dfd7e1a489e3e4870 100644 (file)
@@ -214,7 +214,7 @@ static void print_brl(struct file_id id,
        }
 
        d_printf("%-10s %-15s %-4s %-9.0f %-9.0f %-24s %-24s\n", 
-                procid_str_static(&pid), file_id_static_string(&id),
+                procid_str_static(&pid), file_id_string_tos(&id),
                 desc,
                 (double)start, (double)size,
                 sharepath, fname);