~ubuntu-branches/ubuntu/wily/apparmor/wily

« back to all changes in this revision

Viewing changes to tests/regression/subdomain/swap.c

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2011-04-27 10:38:07 UTC
  • mfrom: (5.1.118 natty)
  • Revision ID: james.westby@ubuntu.com-20110427103807-ym3rhwys6o84ith0
Tags: 2.6.1-2
debian/copyright: clarify for some full organization names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: swap.c 61 2006-05-19 18:32:14Z steve-beattie $ */
2
 
 
3
 
/*
4
 
 *      Copyright (C) 2002-2005 Novell/SUSE
5
 
 *
6
 
 *      This program is free software; you can redistribute it and/or
7
 
 *      modify it under the terms of the GNU General Public License as
8
 
 *      published by the Free Software Foundation, version 2 of the
9
 
 *      License.
10
 
 */
11
 
 
12
 
#include <stdio.h>
13
 
#include <unistd.h>
14
 
#include <errno.h>
15
 
#include <sys/types.h>
16
 
#include <sys/stat.h>
17
 
#include <sys/swap.h>
18
 
#include <string.h>
19
 
 
20
 
int main(int argc, char *argv[])
21
 
{
22
 
        if (argc != 3) {
23
 
                fprintf(stderr, "usage: %s [on|off] swapfile\n",
24
 
                        argv[0]);
25
 
                return 1;
26
 
        }
27
 
 
28
 
        if (strcmp(argv[1], "on") == 0) {
29
 
                if (swapon(argv[2], 0) == -1) {
30
 
                        fprintf(stderr, "FAIL: swapon %s failed - %s\n",
31
 
                                argv[2],
32
 
                                strerror(errno));
33
 
                        return errno;
34
 
                }
35
 
        } else if (strcmp(argv[1], "off") == 0) {
36
 
                if (swapoff(argv[2]) == -1) {
37
 
                        fprintf(stderr, "FAIL: swapoff %s failed - %s\n",
38
 
                                argv[2],
39
 
                                strerror(errno));
40
 
                        return errno;
41
 
                }
42
 
        } else {
43
 
                fprintf(stderr, "usage: %s [on|off] swapfile\n",
44
 
                        argv[0]);
45
 
                return 1;
46
 
        }
47
 
 
48
 
        printf("PASS\n");
49
 
 
50
 
        return 0;
51
 
}