From d9432291168e7e15877bdd4c1c23ed0dc8913246 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Thu, 7 May 2015 13:32:59 +0200 Subject: netsniff-ng: add comment wrt NOATIME and fix whitespace Just add a comment to the reader, so that it's obvious. The second condition could have been spared in case of open_or_die(), but it's nothing critical and the extra indent can be spared instead. Signed-off-by: Daniel Borkmann --- netsniff-ng.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/netsniff-ng.c b/netsniff-ng.c index d6782ac..afa522f 100644 --- a/netsniff-ng.c +++ b/netsniff-ng.c @@ -570,12 +570,16 @@ static void read_pcap(struct ctx *ctx) if (ctx->pcap == PCAP_OPS_MM) ctx->pcap = PCAP_OPS_SG; } else { + /* O_NOATIME requires privileges, in case we don't have + * them, retry without them at a minor cost of updating + * atime in case the fs has been mounted as such. + */ fd = open(ctx->device_in, O_RDONLY | O_LARGEFILE | O_NOATIME); if (fd < 0 && errno == EPERM) fd = open_or_die(ctx->device_in, O_RDONLY | O_LARGEFILE); if (fd < 0) panic("Cannot open file %s! %s.\n", ctx->device_in, - strerror(errno)); + strerror(errno)); } if (__pcap_io->init_once_pcap) -- cgit v1.2.3-54-g00ecf