summaryrefslogtreecommitdiffstats
path: root/perl-install/swap.pm
blob: f9bacf4922f32838bc895bf1d9fd1718dbc0fb33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package swap; # $Id$

use diagnostics;
use strict;

use common;
use log;
use devices;

sub make {
    my ($dev, $checkBlocks) = @_;
    run_program::raw({ timeout => 60 * 60 }, "mkswap", if_($checkBlocks, '-c'), devices::make($dev)) or die \N("%s formatting of %s failed", 'swap', $dev);
}

sub enable {
    my ($dev, $checkBlocks) = @_;
    make($dev, $checkBlocks);
    swapon($dev);
}

sub swapon {
    my ($dev) = @_;
    log::l("swapon called with $dev");
    syscall_('swapon', devices::make($dev), 0) or die "swapon($dev) failed: $!";
}

sub swapoff($) {
    my ($dev) = @_;
    syscall_('swapoff', devices::make($dev)) or die "swapoff($dev) failed: $!";
}

1;