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