From bb2d1ea559f4563e2ad08fb02886625de703877e Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 16 Dec 2012 10:43:54 +0000 Subject: isosize: inform if file does not look like iso file system $ isosize /dev/urandom isosize: /dev/urandom: might not be iso file system -67690643227260 Signed-off-by: Sami Kerola --- disk-utils/isosize.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'disk-utils/isosize.c') diff --git a/disk-utils/isosize.c b/disk-utils/isosize.c index 625dd427e..5f1a2971c 100644 --- a/disk-utils/isosize.c +++ b/disk-utils/isosize.c @@ -32,6 +32,14 @@ #define ISODCL(from, to) (to - from + 1) +static int is_iso(int fd) +{ + char label[8]; + if (pread(fd, &label, 8, 0x8000) == -1) + return 1; + return memcmp(&label, &"\1CD001\1", 8); +} + static int isonum_721(unsigned char *p) { return ((p[0] & 0xff) @@ -124,6 +132,8 @@ static void isosize(char *filenamep, int xflag, long divisor) if ((fd = open(filenamep, O_RDONLY)) < 0) err(EXIT_FAILURE, _("cannot open %s"), filenamep); + if (is_iso(fd)) + warnx(_("%s: might not be iso file system"), filenamep); if (lseek(fd, 16 << 11, 0) == (off_t) - 1) err(EXIT_FAILURE, _("seek error on %s"), filenamep); -- cgit v1.2.3-55-g7522