~apparmor-dev/apparmor/master

« back to all changes in this revision

Viewing changes to tests/regression/apparmor/mount.c

  • Committer: Steve Beattie
  • Date: 2019-02-19 09:38:13 UTC
  • Revision ID: sbeattie@ubuntu.com-20190219093813-ud526ee6hwn8nljz
The AppArmor project has been converted to git and is now hosted on
gitlab.

To get the converted repository, please do
  git clone https://gitlab.com/apparmor/apparmor

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/stat.h>
15
 
#include <sys/mount.h>
16
 
#include <string.h>
17
 
 
18
 
int main(int argc, char *argv[])
19
 
{
20
 
        if (argc != 4) {
21
 
                fprintf(stderr, "usage: %s [mount|umount] loopdev mountpoint\n",
22
 
                        argv[0]);
23
 
                return 1;
24
 
        }
25
 
 
26
 
        if (strcmp(argv[1], "mount") == 0) {
27
 
                if (mount(argv[2], argv[3], "ext2", 0xc0ed0000 | MS_MANDLOCK, NULL ) == -1) {
28
 
                        fprintf(stderr, "FAIL: mount %s on %s failed - %s\n",
29
 
                                argv[2], argv[3], 
30
 
                                strerror(errno));
31
 
                        return errno;
32
 
                }
33
 
        } else if (strcmp(argv[1], "umount") == 0) {
34
 
                if (umount(argv[3]) == -1) {
35
 
                        fprintf(stderr, "FAIL: umount %s failed - %s\n",
36
 
                                argv[3],
37
 
                                strerror(errno));
38
 
                        return errno;
39
 
                }
40
 
        } else {
41
 
                fprintf(stderr, "usage: %s [mount|umount] loopdev mountpoint\n",
42
 
                        argv[0]);
43
 
                return 1;
44
 
        }
45
 
 
46
 
        printf("PASS\n");
47
 
 
48
 
        return 0;
49
 
}