|
@@ -1844,33 +1844,15 @@ static int __init max_swapfiles_check(void)
|
|
late_initcall(max_swapfiles_check);
|
|
late_initcall(max_swapfiles_check);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
|
|
|
|
|
|
+static struct swap_info_struct *alloc_swap_info(void)
|
|
{
|
|
{
|
|
struct swap_info_struct *p;
|
|
struct swap_info_struct *p;
|
|
- char *name = NULL;
|
|
|
|
- struct block_device *bdev = NULL;
|
|
|
|
- struct file *swap_file = NULL;
|
|
|
|
- struct address_space *mapping;
|
|
|
|
unsigned int type;
|
|
unsigned int type;
|
|
- int i, prev;
|
|
|
|
int error;
|
|
int error;
|
|
- union swap_header *swap_header;
|
|
|
|
- unsigned int nr_good_pages;
|
|
|
|
- int nr_extents = 0;
|
|
|
|
- sector_t span;
|
|
|
|
- unsigned long maxpages;
|
|
|
|
- unsigned long swapfilepages;
|
|
|
|
- unsigned char *swap_map = NULL;
|
|
|
|
- struct page *page = NULL;
|
|
|
|
- struct inode *inode = NULL;
|
|
|
|
- int did_down = 0;
|
|
|
|
-
|
|
|
|
- if (!capable(CAP_SYS_ADMIN))
|
|
|
|
- return -EPERM;
|
|
|
|
|
|
|
|
p = kzalloc(sizeof(*p), GFP_KERNEL);
|
|
p = kzalloc(sizeof(*p), GFP_KERNEL);
|
|
if (!p)
|
|
if (!p)
|
|
- return -ENOMEM;
|
|
|
|
|
|
+ return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
spin_lock(&swap_lock);
|
|
spin_lock(&swap_lock);
|
|
for (type = 0; type < nr_swapfiles; type++) {
|
|
for (type = 0; type < nr_swapfiles; type++) {
|
|
@@ -1906,6 +1888,41 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
|
|
p->next = -1;
|
|
p->next = -1;
|
|
spin_unlock(&swap_lock);
|
|
spin_unlock(&swap_lock);
|
|
|
|
|
|
|
|
+ return p;
|
|
|
|
+
|
|
|
|
+out:
|
|
|
|
+ return ERR_PTR(error);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
|
|
|
|
+{
|
|
|
|
+ struct swap_info_struct *p;
|
|
|
|
+ char *name = NULL;
|
|
|
|
+ struct block_device *bdev = NULL;
|
|
|
|
+ struct file *swap_file = NULL;
|
|
|
|
+ struct address_space *mapping;
|
|
|
|
+ int i, prev;
|
|
|
|
+ int error;
|
|
|
|
+ union swap_header *swap_header;
|
|
|
|
+ unsigned int nr_good_pages;
|
|
|
|
+ int nr_extents = 0;
|
|
|
|
+ sector_t span;
|
|
|
|
+ unsigned long maxpages;
|
|
|
|
+ unsigned long swapfilepages;
|
|
|
|
+ unsigned char *swap_map = NULL;
|
|
|
|
+ struct page *page = NULL;
|
|
|
|
+ struct inode *inode = NULL;
|
|
|
|
+ int did_down = 0;
|
|
|
|
+
|
|
|
|
+ if (!capable(CAP_SYS_ADMIN))
|
|
|
|
+ return -EPERM;
|
|
|
|
+
|
|
|
|
+ p = alloc_swap_info();
|
|
|
|
+ if (IS_ERR(p)) {
|
|
|
|
+ error = PTR_ERR(p);
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+
|
|
name = getname(specialfile);
|
|
name = getname(specialfile);
|
|
error = PTR_ERR(name);
|
|
error = PTR_ERR(name);
|
|
if (IS_ERR(name)) {
|
|
if (IS_ERR(name)) {
|