Set RINGBUFFER_MAX_NUM_FILES to 100000. Use it to generate file names.
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 27 May 2010 18:00:46 +0000 (18:00 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 27 May 2010 18:00:46 +0000 (18:00 +0000)
Add RINGBUFFER_WARN_NUM_FILES and use it to print a warning. Print
warnings when we change the number of ringbuffer files.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@32998 f5534014-38df-0310-8fa8-9805f1628bb7

capture_opts.c
ringbuffer.c
ringbuffer.h

index 23297b60eb7d7b083bc2e4b74a06d6d6f71d59d3..e24ec8fed190cd6db7c95dbc79700715a6f695df 100644 (file)
@@ -604,10 +604,15 @@ void capture_opts_trim_snaplen(capture_options *capture_opts, int snaplen_min)
 void capture_opts_trim_ring_num_files(capture_options *capture_opts)
 {
   /* Check the value range of the ring_num_files parameter */
-  if (capture_opts->ring_num_files > RINGBUFFER_MAX_NUM_FILES)
+  if (capture_opts->ring_num_files > RINGBUFFER_MAX_NUM_FILES) {
+    cmdarg_err("Too many ring buffer files (%u). Reducing to %u.\n", capture_opts->ring_num_files, RINGBUFFER_MAX_NUM_FILES);
     capture_opts->ring_num_files = RINGBUFFER_MAX_NUM_FILES;
+  } else if (capture_opts->ring_num_files > RINGBUFFER_WARN_NUM_FILES) {
+    cmdarg_err("%u is a lot of ring buffer files.\n", capture_opts->ring_num_files);
+  }
 #if RINGBUFFER_MIN_NUM_FILES > 0
   else if (capture_opts->ring_num_files < RINGBUFFER_MIN_NUM_FILES)
+    cmdarg_err("Too few ring buffer files (%u). Increasing to %u.\n", capture_opts->ring_num_files, RINGBUFFER_MIN_NUM_FILES);
     capture_opts->ring_num_files = RINGBUFFER_MIN_NUM_FILES;
 #endif
 }
index 94efe0b5c710801bcf0f7925e5335c9e24f10a4f..ca946554381fe99319b4989c870c3031d059e762 100644 (file)
@@ -113,7 +113,7 @@ static int ringbuf_open_file(rb_file *rfile, int *err)
 #endif
   current_time = time(NULL);
 
-  g_snprintf(filenum, sizeof(filenum), "%05u", (rb_data.curr_file_num + 1) % 100000);
+  g_snprintf(filenum, sizeof(filenum), "%05u", (rb_data.curr_file_num + 1) % RINGBUFFER_MAX_NUM_FILES);
   strftime(timestr, sizeof(timestr), "%Y%m%d%H%M%S", localtime(&current_time));
   rfile->name = g_strconcat(rb_data.fprefix, "_", filenum, "_", timestr,
                            rb_data.fsuffix, NULL);
index b4ef7a42f1976ee24aac2de1d850b39448c3be86..497c9827d2863a6c7261e7c3f3db05e56fdf4560 100644 (file)
 #include "wiretap/wtap.h"
 
 #define RINGBUFFER_UNLIMITED_FILES 0
-/* minimum number of ringbuffer files */
+/* Minimum number of ringbuffer files */
 #define RINGBUFFER_MIN_NUM_FILES 0
-/* maximum number of ringbuffer files */
-/* (only to avoid crashes on very large numbers) */
-#define RINGBUFFER_MAX_NUM_FILES 10000
+/* Maximum number of ringbuffer files */
+/* Avoid crashes on very large numbers. Should be a power of 10 */
+#define RINGBUFFER_MAX_NUM_FILES 100000
+/* Maximum number for FAT filesystems */
+#define RINGBUFFER_WARN_NUM_FILES 65535
 
 int ringbuf_init(const char *capture_name, guint num_files);
 const gchar *ringbuf_current_filename(void);