← Commit list

97b141ac6

Eric Andersen
Eric Andersen
2002-11-03
FAILED Duration: 6s

Subject

Test for holes in swapfiles -Erik

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

util-linux/swaponoff.c+12 -0
@@ -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);