diff options
author | NeilBrown <neilb@suse.de> | 2013-08-08 01:16:43 +0200 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2013-08-08 01:16:43 +0200 |
commit | 2538ba2abf363192f8f737423ca62286a788c723 (patch) | |
tree | e81bd854307f98b90c1b050df004e49dca6f97fb /util.c | |
parent | DDF: Write new conf entries with a single write. (diff) | |
download | mdadm-2538ba2abf363192f8f737423ca62286a788c723.tar.xz mdadm-2538ba2abf363192f8f737423ca62286a788c723.zip |
Create: fix warning about pre-existing filesystems.
An ext[234] filesystem larger than 2TB was beign reported with
a negative size - which looks odd.
So fix it to use suitably large and unsigned values.
Reported-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -511,7 +511,8 @@ int check_ext2(int fd, char *name) */ unsigned char sb[1024]; time_t mtime; - int size, bsize; + unsigned long long size; + int bsize; if (lseek(fd, 1024,0)!= 1024) return 0; if (read(fd, sb, 1024)!= 1024) @@ -522,10 +523,10 @@ int check_ext2(int fd, char *name) mtime = sb[44]|(sb[45]|(sb[46]|sb[47]<<8)<<8)<<8; bsize = sb[24]|(sb[25]|(sb[26]|sb[27]<<8)<<8)<<8; size = sb[4]|(sb[5]|(sb[6]|sb[7]<<8)<<8)<<8; + size <<= bsize; pr_err("%s appears to contain an ext2fs file system\n", name); - cont_err("size=%dK mtime=%s", - size*(1<<bsize), ctime(&mtime)); + cont_err("size=%lluK mtime=%s", size, ctime(&mtime)); return 1; } @@ -538,7 +539,7 @@ int check_reiser(int fd, char *name) * */ unsigned char sb[1024]; - unsigned long size; + unsigned long long size; if (lseek(fd, 64*1024, 0) != 64*1024) return 0; if (read(fd, sb, 1024) != 1024) @@ -548,7 +549,7 @@ int check_reiser(int fd, char *name) return 0; pr_err("%s appears to contain a reiserfs file system\n",name); size = sb[0]|(sb[1]|(sb[2]|sb[3]<<8)<<8)<<8; - cont_err("size = %luK\n", size*4); + cont_err("size = %lluK\n", size*4); return 1; } |