[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: flow-tools on amd64



tags 320998 + patch
thanks

On Sat, Aug 06, 2005 at 05:06:23AM +0300, Radu Spineanu wrote:
> Hello
> 
> #320998 was filed on flow-tools recently describing a problem i couldn't
> reproduce with the packages in sarge/sid on my i386.
> 
> However the user was running amd64. If anybody has the time, i would
> appreciate if they tried to reproduce it and send me some more information.
> 
> Basically you can apt-get install flow-tools, stop flow-capture if it
> was started (/etc/init.d/flow-capture stop) and then run:
> flow-capture -w /tmp/temp-2214k -V 5 -n 1439 /0/0/9100
> After that check the logs for errors of flow-capture not being able to
> create directories.

I get:
mkdir("2822", 0755)                     = 0
mkdir("2822/2822-03", 0755)             = 0
mkdir("2822/2822-03/2822-03-18", 0755)  = 0
open("2005/2005-08/2005-08-06/tmp-v05.2005-08-06.154136+0200", O_WRONLY|O_CREAT|O_TRUNC, 0644) = -1 ENOENT (No such file or directory)
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=1067, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=1067, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=1067, ...}) = 0
sendto(0, "<182>Aug  6 15:41:36 flow-capture[4682]: open(2005/2005-08/2005-08-06/tmp-v05.2005-08-06.154136+0200): No such file or directory", 128, MSG_NOSIGNAL, NULL, 0) = 128

And in /var/log/messages:
Aug  6 15:41:35 loopback flow-capture[4682]: setsockopt(size=4194304)
Aug  6 15:41:36 loopback flow-capture[4682]: open(2005/2005-08/2005-08-06/tmp-v05.2005-08-06.154136+0200): No such file or directory

The 2005 path obviously doesn't exist.

This problem is this in lib/ftfile.c:
  if (!(tm = localtime ((time_t*)&ftime)))

Where ftime is an u_int32 instead of a time_t, which
happens to be a 64 bit value.

Anyway, I think you should merge those 2 functions that
make the path based on a file into 1 function.

The attached patch "fixes" the problem.  I now instead
get:
mkdir("2005", 0755)                     = 0
mkdir("2005/2005-08", 0755)             = 0
mkdir("2005/2005-08/2005-08-06", 0755)  = 0
open("2005/2005-08/2005-08-06/tmp-v05.2005-08-06.160926+0200", O_WRONLY|O_CREAT|O_TRUNC, 0644) = 2

You really should put all time values into a time_t
instead of a u_int32.

Note, this patch changes the API and ABI.  You only seem to have
a static version of the library.  If you want to avoid doing an
API/ABI change at this time, and want to clean up the rest too at
the same time, you can temporary store it in a time_t before
calling localtime() instead.  I suggest you fix things properly
by converting everything to a time_t however.


Kurt

--- ./lib/ftfile.c.old	2005-08-06 16:01:18.228015904 +0200
+++ ./lib/ftfile.c	2005-08-06 16:04:55.087048320 +0200
@@ -410,7 +410,7 @@
  * 
  */
 void ftfile_pathname(char *buf, int bsize, int nest, struct ftver ftv,
- int done, u_int32 ftime)
+ int done, time_t ftime)
 {
   struct tm *tm;
   char *prefix, dbuf[64];
@@ -418,7 +418,7 @@
   char gmt_sign;
   int tm_gmtoff;
   
-  if (!(tm = localtime ((time_t*)&ftime))) {
+  if (!(tm = localtime (&ftime))) {
     snprintf(buf, bsize, ".");
   }
 
@@ -499,7 +499,7 @@
  * returns -1 on error
  * 
  */
-int ftfile_mkpath(u_int32 ftime, int nest)
+int ftfile_mkpath(time_t ftime, int nest)
 {
   struct tm *tm;
   char buf[32];
@@ -512,7 +512,7 @@
   if ((nest > 3) || (nest < -3))
     return -1;
 
-  if (!(tm = localtime ((time_t*)&ftime)))
+  if (!(tm = localtime (&ftime)))
     return -1;
 
   if (nest == -1)
--- ./lib/ftlib.h.old	2005-08-06 16:06:19.836164496 +0200
+++ ./lib/ftlib.h	2005-08-06 16:05:47.261116656 +0200
@@ -2710,9 +2710,9 @@
 int ftfile_dump(struct ftfile_entries *fte);
 struct ftfile_entry *ftfile_entry_new(int len);
 void ftfile_entry_free(struct ftfile_entry *entry);
-int ftfile_mkpath(u_int32 ftime, int nest);
+int ftfile_mkpath(time_t ftime, int nest);
 void ftfile_pathname(char *buf, int bsize, int nest, struct ftver ftv,
- int done, u_int32 ftime);
+ int done, time_t ftime);
 
 
 

Reply to: