Surprising use of basename in finish_log_named
Hi Jens,
I had a input of the fio irc channel (yes some at getting into it sometimes :p), and he had a very interesting point.
If you specify a full path name for the iops_log, the file will stay into the current dir. While looking at the code I found that finish_log_named() is performing the following:
char file_name[256], *p;
snprintf(file_name, sizeof(file_name), "%s_%s.log", prefix, postfix);
p = basename(file_name);Why do we basename the file_name ? What's the reason of shrinking the path this way ?
Note for the author: 256 is maybe too small for some ? :)))
Cheers,
Erwan
Quoted 10 lines · Erwan Velu
Hi Jens,
I had a input of the fio irc channel (yes some at getting into it sometimes :p), and he had a very interesting point.
If you specify a full path name for the
iops_log, the file will stay into the current dir.
While looking at the code I found thatfinish_log_named()is performing the following:
Quoted 6 lines
char file_name[256], *p; snprintf(file_name, sizeof(file_name), "%s_%s.log", prefix, postfix); p = basename(file_name);Why do we basename the
file_name? What's the reason of shrinking the path this way ?
I don't think there's a good reason for that. So feel free to send in a (tested) patch :-)
Quoted 1 line
Note for the author: 256 is maybe too small for some ? :)))
We can make it PATH_MAX instead, not a big deal.
Signature · 1 line
Jens Axboe
Quoted 1 line · Jens Axboe
I don't think there's a good reason for that. So feel free to send in a (tested) patch :-)
Please find my branch ready for master here : https://github.com/enovance/fio/tree/erwan/nobasename
Quoted 1 line
We can make it
PATH_MAXinstead, not a big deal
I've been looking at it and fixing it in iolog is pretty easy but I have some fear that it will not be enough to fix it globally. I mean, there is many occurences of paths & strings set at 256. So I'll have a look at a global scale for this issue in another thread.
Erwan,
Quoted 6 lines · Erwan Velu
Le 01/04/2014 20:49, Jens Axboe a �crit :
Quoted 2 lines
I don't think there's a good reason for that. So feel free to send in a (tested) patch :-)
Please find my branch ready for master here :
https://github.com/enovance/fio/tree/erwan/nobasename
Thanks, pulled.
Quoted 5 lines
Quoted 1 line
We can make it
PATH_MAXinstead, not a big dealI've been looking at it and fixing it in iolog is pretty easy but I have some fear that it will not be enough to fix it globally. I mean, there is many occurences of paths & strings set at 256. So I'll have a look at a global scale for this issue in another thread.
OK, sounds good. I'm pretty sure I consistently used 256 in most places. One problematic area might be around the server/client protocol. Maybe it's time to finally improve that... So don't worry too much about that part.
Signature · 1 line
Jens Axboe