Diff between 42ad78700e4b4066b6b0e1bbeb4570f66b875e54 and 62a98dc28a200ffc281d78873ade721c04e9cd03

Changed Files

File Additions Deletions Status
tools/hcidump.1 +3 -0 modified
tools/hcidump.c +10 -3 modified

Full Patch

diff --git a/tools/hcidump.1 b/tools/hcidump.1
index d9bd7c2..913471c 100644
--- a/tools/hcidump.1
+++ b/tools/hcidump.1
@@ -105,6 +105,9 @@ Enables a more verbose decoding of every packet.
 .TP
 .BR -Y ", " "\-\^\-novendor"
 Don't display any vendor commands or events and don't show any pin code or link key in plain text.
+.TP
+.BR -N ", " "\-\^\-noappend"
+No appending to existing files. Always create new files.
 .SH FILTERS
 .B
 filter
diff --git a/tools/hcidump.c b/tools/hcidump.c
index f330e28..f1d0825 100644
--- a/tools/hcidump.c
+++ b/tools/hcidump.c
@@ -86,6 +86,7 @@ static int  defpsm = 0;
 static int  defcompid = DEFAULT_COMPID;
 static int  mode = PARSE;
 static int  permcheck = 1;
+static int  noappend = 0;
 static long flags;
 static long filter;
 static char *dump_file = NULL;
@@ -362,8 +363,8 @@ static int open_file(char *file, int mode, unsigned long flags)
 	int fd, len, open_flags;
 
 	if (mode == WRITE || mode == PPPDUMP || mode == AUDIO) {
-		if (flags & DUMP_BTSNOOP)
-			open_flags = O_WRONLY | O_CREAT;
+		if (noappend || flags & DUMP_BTSNOOP)
+			open_flags = O_WRONLY | O_CREAT | O_TRUNC;
 		else
 			open_flags = O_WRONLY | O_CREAT | O_APPEND;
 	} else
@@ -655,6 +656,7 @@ static void usage(void)
 	"  -B, --btsnoop              Use BTSnoop file format\n"
 	"  -V, --verbose              Verbose decoding\n"
 	"  -Y, --novendor             No vendor commands or events\n"
+	"  -N, --noappend             No appending to existing files\n"
 	"  -h, --help                 Give this help list\n"
 	"      --usage                Give a short usage message\n"
 	);
@@ -684,6 +686,7 @@ static struct option main_options[] = {
 	{ "verbose",		0, 0, 'V' },
 	{ "novendor",		0, 0, 'Y' },
 	{ "nopermcheck",	0, 0, 'Z' },
+	{ "noappend",		0, 0, 'N' },
 	{ "help",		0, 0, 'h' },
 	{ 0 }
 };
@@ -696,7 +699,7 @@ int main(int argc, char *argv[])
 
 	printf("HCI sniffer - Bluetooth packet analyzer ver %s\n", VERSION);
 
-	while ((opt=getopt_long(argc, argv, "i:l:p:m:w:r:s:n:taxXRC:H:O:P:D:A:BVYZh", main_options, NULL)) != -1) {
+	while ((opt=getopt_long(argc, argv, "i:l:p:m:w:r:s:n:taxXRC:H:O:P:D:A:BVYZNh", main_options, NULL)) != -1) {
 		switch(opt) {
 		case 'i':
 			if (strcasecmp(optarg, "none") && strcasecmp(optarg, "system"))
@@ -813,6 +816,10 @@ int main(int argc, char *argv[])
 			permcheck = 0;
 			break;
 
+		case 'N':
+			noappend = 1;
+			break;
+
 		case 'h':
 		default:
 			usage();