linux-btrace.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vasily Tarasov <sectorsize512@gmail.com>
To: linux-btrace@vger.kernel.org
Subject: [PATCH][BLKPARSE/BLKTRACE] too small arrays for file names
Date: Fri, 09 Sep 2011 23:02:16 +0000	[thread overview]
Message-ID: <20110909230216.GA11154@white> (raw)

[-- Attachment #1: Type: text/plain, Size: 542 bytes --]

In our experiments blktrace/blkparse file names encode a lot of infomation about
the particular experiment.  We noticed that for long enough file names blkparse
does not work.

The reason is that per_cpu_info->fname[] is of 128 bytes. As a result, in
setup_file() function only part of the file name gets to ->fname[]. Then stat()
fails and we exit the function. Notice, that no error is printed in this case.

In the following patch ->fname[] size is increased to POSXI defined PATH_MAX.

Signed-off-by: Vasily Tarasov <tarasov@vasily.name>

[-- Attachment #2: blkparse-to-short-file-name.diff --]
[-- Type: text/x-diff, Size: 735 bytes --]

diff --git a/blkparse.c b/blkparse.c
index 169d491..6db7307 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2836,7 +2836,7 @@ int main(int argc, char *argv[])
 			ofp = fdopen(STDOUT_FILENO, "w");
 			mode = _IOLBF;
 		} else {
-			char ofname[128];
+			char ofname[PATH_MAX];
 
 			snprintf(ofname, sizeof(ofname) - 1, "%s", output_name);
 			ofp = fopen(ofname, "w");
diff --git a/blktrace.h b/blktrace.h
index 8b3e031..5da6dbc 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -2,6 +2,7 @@
 #define BLKTRACE_H
 
 #include <stdio.h>
+#include <limits.h>
 #include <byteswap.h>
 #include <endian.h>
 
@@ -44,7 +45,7 @@ struct per_cpu_info {
 
 	int fd;
 	int fdblock;
-	char fname[128];
+	char fname[PATH_MAX];
 
 	struct io_stats io_stats;
 

                 reply	other threads:[~2011-09-09 23:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110909230216.GA11154@white \
    --to=sectorsize512@gmail.com \
    --cc=linux-btrace@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).