projects
/
oweals
/
busybox.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
bf1cc8b
)
Test for holes in swapfiles
author
Eric Andersen
<andersen@codepoet.org>
Sun, 3 Nov 2002 00:25:23 +0000
(
00:25
-0000)
committer
Eric Andersen
<andersen@codepoet.org>
Sun, 3 Nov 2002 00:25:23 +0000
(
00:25
-0000)
-Erik
util-linux/swaponoff.c
patch
|
blob
|
history
diff --git
a/util-linux/swaponoff.c
b/util-linux/swaponoff.c
index a57dfe472be95d0109740f1eab7e70b84b4f7958..918a5bc0e6ce32682c765e021290ee0521edbc12 100644
(file)
--- a/
util-linux/swaponoff.c
+++ b/
util-linux/swaponoff.c
@@
-48,6
+48,18
@@
static const int SWAPOFF_APP = 1;
static int swap_enable_disable(const char *device)
{
int status;
+ struct stat st;
+
+ if (stat(device, &st) < 0) {
+ perror_msg_and_die("cannot stat %s");
+ }
+
+ /* test for holes */
+ if (S_ISREG(st.st_mode)) {
+ if (st.st_blocks * 512 < st.st_size) {
+ error_msg_and_die("swap file has holes");
+ }
+ }
if (whichApp == SWAPON_APP)
status = swapon(device, 0);