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

« back to all changes in this revision

Viewing changes to tests/regression/subdomain/syscall_ioperm.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: syscall_ioperm.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/io.h> /* for glibc */
17
 
#include <string.h>
18
 
#include <stdlib.h>
19
 
 
20
 
int main(int argc, char *argv[])
21
 
{
22
 
        unsigned long from, num;
23
 
        if (argc != 3) {
24
 
                fprintf(stderr, "usage: %s <from> <num>\n",
25
 
                                argv[0]);
26
 
                return 1;
27
 
        }
28
 
 
29
 
        if ( (from = strtoul(argv[1], NULL, 0)) == 0) {
30
 
                if (errno == EINVAL) {
31
 
                fprintf(stderr, "FAIL: no <from> argument in '%s'\n",
32
 
                                argv[1]);
33
 
                }
34
 
        }
35
 
 
36
 
        if ( (num = strtoul(argv[2], NULL, 0)) == 0) {
37
 
                if (errno == EINVAL) {
38
 
                fprintf(stderr, "FAIL: no <num> argument in '%s'\n",
39
 
                                argv[1]);
40
 
                }
41
 
        }
42
 
 
43
 
        if (from > 0x3ff || (from + num) > 0x3ff) {
44
 
                fprintf(stderr, "FAIL: out of range (0x3ff)\n");
45
 
        }
46
 
 
47
 
        if (ioperm(from, num, 1) == -1) {
48
 
                fprintf(stderr, "FAIL: ioperm failed - %s\n",
49
 
                        strerror(errno));
50
 
                return 1;
51
 
        }
52
 
 
53
 
        printf("PASS\n");
54
 
 
55
 
        return 0;
56
 
}