From: Ming Zhang Date: Tue, 2 Jan 2007 14:32:23 +0000 (+0100) Subject: [PATCH] Fixup filename on full file input X-Git-Tag: blktrace-0.99.3~38 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=7d34075678b7ed1dd2026831b46175b1b6247885;p=blktrace.git [PATCH] Fixup filename on full file input If the user by mistake specifies the full filename, strip that back down to avoid missing input files. Signed-off-by: Jens Axboe --- diff --git a/blkparse.c b/blkparse.c index 90614d8..cdcb426 100644 --- a/blkparse.c +++ b/blkparse.c @@ -2308,9 +2308,27 @@ static int handle(struct ms_stream *msp) return 1; } +/* + * Check if we need to sanitize the name. We allow 'foo', or if foo.blktrace.X + * is given, then strip back down to 'foo' to avoid missing files. + */ +static int name_fixup(char *name) +{ + char *b; + + if (!name) + return 1; + + b = strstr(name, ".blktrace."); + if (b) + *b = '\0'; + + return 0; +} + static int do_file(void) { - int i, cpu; + int i, cpu, ret; struct per_dev_info *pdi; /* @@ -2318,6 +2336,10 @@ static int do_file(void) */ for (i = 0; i < ndevices; i++) { pdi = &devices[i]; + ret = name_fixup(pdi->name); + if (ret) + return ret; + for (cpu = 0; setup_file(pdi, cpu); cpu++) ; }