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

« back to all changes in this revision

Viewing changes to tests/regression/apparmor/syscall_iopl.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
/*
 
2
 *      Copyright (C) 2002-2005 Novell/SUSE
 
3
 *
 
4
 *      This program is free software; you can redistribute it and/or
 
5
 *      modify it under the terms of the GNU General Public License as
 
6
 *      published by the Free Software Foundation, version 2 of the
 
7
 *      License.
 
8
 */
 
9
 
 
10
#include <stdio.h>
 
11
#include <unistd.h>
 
12
#include <errno.h>
 
13
#include <sys/types.h>
 
14
#include <sys/io.h> /* for glibc */
 
15
#include <string.h>
 
16
#include <stdlib.h>
 
17
 
 
18
int main(int argc, char *argv[])
 
19
{
 
20
        int ring;
 
21
        if (argc != 2) {
 
22
                fprintf(stderr, "usage: %s <ring>\n",
 
23
                                argv[0]);
 
24
                return 1;
 
25
        }
 
26
 
 
27
        if ( (ring = strtol(argv[1], NULL, 0)) == 0) {
 
28
                if (errno == EINVAL) {
 
29
                fprintf(stderr, "FAIL: no <ring> argument in '%s'\n",
 
30
                                argv[1]);
 
31
                }
 
32
        }
 
33
 
 
34
        if (ring > 3 || ring < 0) {
 
35
                fprintf(stderr, "FAIL: out of range (0-3)\n");
 
36
        }
 
37
 
 
38
        if (iopl(ring) == -1) {
 
39
                fprintf(stderr, "FAIL: iopl failed - %s\n",
 
40
                        strerror(errno));
 
41
                return 1;
 
42
        }
 
43
 
 
44
        printf("PASS\n");
 
45
 
 
46
        return 0;
 
47
}