]> err.no Git - util-linux/commitdiff
mkswap: zap bootbits on regular files
authorKarel Zak <kzak@redhat.com>
Fri, 2 Apr 2010 10:49:07 +0000 (12:49 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 2 Apr 2010 10:49:07 +0000 (12:49 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/mkswap.c

index 54951991ef857ccc0c04ee604b99b2b32b8016eb..09a9a0a40c71e263d2c3a7db037654ec323b7e65 100644 (file)
@@ -372,7 +372,7 @@ check_mount(void) {
 }
 
 static void
-zap_bootbits(int fd, const char *devname, int force)
+zap_bootbits(int fd, const char *devname, int force, int is_blkdev)
 {
        char *type = NULL;
        int whole = 0;
@@ -382,7 +382,7 @@ zap_bootbits(int fd, const char *devname, int force)
                if (lseek(fd, 0, SEEK_SET) != 0)
                        die(_("unable to rewind swap-device"));
 
-               if (is_whole_disk_fd(fd, devname)) {
+               if (is_blkdev && is_whole_disk_fd(fd, devname)) {
                        /* don't zap bootbits on whole disk -- we know nothing
                         * about bootloaders on the device */
                        whole = 1;
@@ -625,7 +625,7 @@ main(int argc, char ** argv) {
        if (check)
                check_blocks();
 
-       zap_bootbits(DEV, device_name, force);
+       zap_bootbits(DEV, device_name, force, S_ISBLK(statbuf.st_mode));
 
        p->version = 1;
        p->last_page = PAGES-1;