diff options
| author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2002-11-03 00:25:23 +0000 |
|---|---|---|
| committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2002-11-03 00:25:23 +0000 |
| commit | eccf202b2ac39d486d5679786bcbfd4379cb215b (patch) | |
| tree | d00f6259f19cede37e3f7451cb483fb7d7785ed7 /util-linux | |
| parent | 86e8c1288073da2a848e8e119555cd945f802101 (diff) | |
| download | busybox-w32-eccf202b2ac39d486d5679786bcbfd4379cb215b.tar.gz busybox-w32-eccf202b2ac39d486d5679786bcbfd4379cb215b.tar.bz2 busybox-w32-eccf202b2ac39d486d5679786bcbfd4379cb215b.zip | |
Test for holes in swapfiles
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@5779 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/swaponoff.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c index a57dfe472..918a5bc0e 100644 --- a/util-linux/swaponoff.c +++ b/util-linux/swaponoff.c | |||
| @@ -48,6 +48,18 @@ static const int SWAPOFF_APP = 1; | |||
| 48 | static int swap_enable_disable(const char *device) | 48 | static int swap_enable_disable(const char *device) |
| 49 | { | 49 | { |
| 50 | int status; | 50 | int status; |
| 51 | struct stat st; | ||
| 52 | |||
| 53 | if (stat(device, &st) < 0) { | ||
| 54 | perror_msg_and_die("cannot stat %s"); | ||
| 55 | } | ||
| 56 | |||
| 57 | /* test for holes */ | ||
| 58 | if (S_ISREG(st.st_mode)) { | ||
| 59 | if (st.st_blocks * 512 < st.st_size) { | ||
| 60 | error_msg_and_die("swap file has holes"); | ||
| 61 | } | ||
| 62 | } | ||
| 51 | 63 | ||
| 52 | if (whichApp == SWAPON_APP) | 64 | if (whichApp == SWAPON_APP) |
| 53 | status = swapon(device, 0); | 65 | status = swapon(device, 0); |
