diff options
author | Karel Zak | 2006-12-07 00:25:35 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:25:35 +0100 |
commit | 2b6fc908bc368b540845a313c3b8a867c5ad9a42 (patch) | |
tree | 6fad48a239bc90515a5dc4084d6e3c3ee1f41e29 /disk-utils/mkswap.c | |
parent | Imported from util-linux-2.7.1 tarball. (diff) | |
download | kernel-qcow2-util-linux-2b6fc908bc368b540845a313c3b8a867c5ad9a42.tar.gz kernel-qcow2-util-linux-2b6fc908bc368b540845a313c3b8a867c5ad9a42.tar.xz kernel-qcow2-util-linux-2b6fc908bc368b540845a313c3b8a867c5ad9a42.zip |
Imported from util-linux-2.8 tarball.
Diffstat (limited to 'disk-utils/mkswap.c')
-rw-r--r-- | disk-utils/mkswap.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index 2a4027406..49447f2af 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -193,11 +193,11 @@ int main(int argc, char ** argv) if (PAGES < 10) { fprintf(stderr, "%s: error: swap area needs to be at least %ldkB\n", - program_name, 10 * PAGE_SIZE / 1024); + program_name, (long)(10 * PAGE_SIZE / 1024)); usage(); } if (PAGES > 8 * (PAGE_SIZE - 10)) { - PAGES = 8 * (PAGE_SIZE - 10); + PAGES = 8 * (PAGE_SIZE - 10); fprintf(stderr, "%s: warning: truncating swap area to %ldkB\n", program_name, PAGES * PAGE_SIZE / 1024); } @@ -217,11 +217,17 @@ int main(int argc, char ** argv) if (goodpages <= 0) die("Unable to set up swap-space: unreadable"); printf("Setting up swapspace, size = %ld bytes\n", - goodpages*PAGE_SIZE); + (long)(goodpages*PAGE_SIZE)); strncpy((char*)signature_page+PAGE_SIZE-10, "SWAP-SPACE", 10); if (lseek(DEV, 0, SEEK_SET)) die("unable to rewind swap-device"); if (PAGE_SIZE != write(DEV, signature_page, PAGE_SIZE)) die("unable to write signature page"); + /* + * A subsequent swapon() will fail if the signature + * is not actually on disk. (This is a kernel bug.) + */ + if (fsync(DEV)) + die("fsync failed"); return 0; } |