1 /*
2  * Copyright (c) International Business Machines Corp., 2009
3  * Copyright (c) Nadia Derbey, 2009
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12  * the GNU General Public License for more details.
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Author: Serge Hallyn <serue@us.ibm.com>
18  ***************************************************************************/
19 #include <sys/mount.h>
20 #include <sys/stat.h>
21 #include <sys/types.h>
22 #include "../libclone/libclone.h"
23 #include "test.h"
24 #include "mqns.h"
25 #include "safe_macros.h"
26 
dummy_child(void * v)27 static int dummy_child(void *v)
28 {
29 	(void) v;
30 	return 0;
31 }
32 
check_mqns(void)33 static void check_mqns(void)
34 {
35 	int pid, status;
36 	mqd_t mqd;
37 
38 	if (tst_kvercmp(2, 6, 30) < 0)
39 		tst_brkm(TCONF, NULL, "Kernel version is lower than expected");
40 
41 	mq_unlink("/checkmqnsenabled");
42 	mqd =
43 	    mq_open("/checkmqnsenabled", O_RDWR | O_CREAT | O_EXCL, 0777, NULL);
44 	if (mqd == -1)
45 		tst_brkm(TCONF, NULL, "mq_open check failed");
46 
47 	mq_close(mqd);
48 	mq_unlink("/checkmqnsenabled");
49 
50 	pid = do_clone_unshare_test(T_CLONE, CLONE_NEWIPC, dummy_child, NULL);
51 	if (pid == -1)
52 		tst_brkm(TCONF | TERRNO, NULL, "CLONE_NEWIPC not supported");
53 
54 	SAFE_WAIT(NULL, &status);
55 }
56