Added swap support

This commit is contained in:
Nathan 2025-04-07 00:17:00 -05:00
parent 4822424518
commit dd8b7f2b10

View File

@ -1889,17 +1889,8 @@ static struct swap_info_struct *alloc_swap_info(void)
static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
{
int error;
/* On Chromium OS, we only support zram swap devices. */
if (S_ISBLK(inode->i_mode)) {
char name[BDEVNAME_SIZE];
p->bdev = bdgrab(I_BDEV(inode));
bdevname(p->bdev, name);
if (strncmp(name, "zram", strlen("zram")) &&
strncmp(name, "ram", strlen("ram"))) {
bdput(p->bdev);
p->bdev = NULL;
return -EINVAL;
}
error = blkdev_get(p->bdev,
FMODE_READ | FMODE_WRITE | FMODE_EXCL,
sys_swapon);
@ -1912,13 +1903,11 @@ static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
if (error < 0)
return error;
p->flags |= SWP_BLKDEV;
#if 0
} else if (S_ISREG(inode->i_mode)) {
p->bdev = inode->i_sb->s_bdev;
mutex_lock(&inode->i_mutex);
if (IS_SWAPFILE(inode))
return -EBUSY;
#endif
} else
return -EINVAL;