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

« back to all changes in this revision

Viewing changes to tests/regression/subdomain/syscall_mknod.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_mknod.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 <fcntl.h>
18
 
#include <string.h>
19
 
 
20
 
int main(int argc, char *argv[])
21
 
{
22
 
int fd, mode;
23
 
 
24
 
        if (argc != 3){
25
 
                fprintf(stderr, "usage: %s b|c|f|s|r file\n",
26
 
                        argv[0]);
27
 
                return 1;
28
 
        }
29
 
 
30
 
        if (strcmp(argv[1], "b") == 0){
31
 
                mode=S_IFBLK;
32
 
        }else if (strcmp(argv[1], "c") == 0){
33
 
                mode=S_IFCHR;
34
 
        }else if (strcmp(argv[1], "f") == 0){
35
 
                mode=S_IFIFO;
36
 
        }else if (strcmp(argv[1], "s") == 0){
37
 
                mode=S_IFSOCK;
38
 
        }else if (strcmp(argv[1], "r") == 0){
39
 
                mode=S_IFREG;
40
 
        }else{
41
 
                fprintf(stderr, "FAIL: type must be b|c|f|s|r\n");
42
 
                return 1;
43
 
        }
44
 
 
45
 
        if (mknod(argv[2], mode, 1) == -1){
46
 
                fprintf(stderr, "FAIL: mknod %s failed - %s\n",
47
 
                        argv[1],
48
 
                        strerror(errno));
49
 
                return 1;
50
 
        }
51
 
 
52
 
        close(fd);
53
 
 
54
 
        printf("PASS\n");
55
 
 
56
 
        return 0;
57
 
}