]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] Don't swap to files which do not implement readpage
authorAndrew Morton <akpm@osdl.org>
Thu, 16 Oct 2003 00:31:16 +0000 (17:31 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Thu, 16 Oct 2003 00:31:16 +0000 (17:31 -0700)
From: Zwane Mwaikambo <zwane@arm.linux.org.uk>

The swapon code uses read_cache_page() to access the swap header, so the
filesystem had better implement it.

mm/swapfile.c

index 8d252bdb4db37b478bcd601db61f26e0306d6edc..6c23241ad9b3deaad1da24f24ee8313e88ebb170 100644 (file)
@@ -1318,6 +1318,10 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
        /*
         * Read the swap header.
         */
+       if (!mapping->a_ops->readpage) {
+               error = -EINVAL;
+               goto bad_swap;
+       }
        page = read_cache_page(mapping, 0,
                        (filler_t *)mapping->a_ops->readpage, swap_file);
        if (IS_ERR(page)) {