1f08c3bdfSopenharmony_ci/* Copyright (c) 2015 Red Hat, Inc. 2f08c3bdfSopenharmony_ci * 3f08c3bdfSopenharmony_ci * This program is free software: you can redistribute it and/or modify 4f08c3bdfSopenharmony_ci * it under the terms of version 2 the GNU General Public License as 5f08c3bdfSopenharmony_ci * published by the Free Software Foundation. 6f08c3bdfSopenharmony_ci * 7f08c3bdfSopenharmony_ci * This program is distributed in the hope that it will be useful, 8f08c3bdfSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 9f08c3bdfSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10f08c3bdfSopenharmony_ci * GNU General Public License for more details. 11f08c3bdfSopenharmony_ci * 12f08c3bdfSopenharmony_ci * You should have received a copy of the GNU General Public License 13f08c3bdfSopenharmony_ci * along with this program. If not, see <http://www.gnu.org/licenses/>. 14f08c3bdfSopenharmony_ci * 15f08c3bdfSopenharmony_ci ***********************************************************************/ 16f08c3bdfSopenharmony_ci 17f08c3bdfSopenharmony_ci#ifndef __NS_COMMON_H__ 18f08c3bdfSopenharmony_ci#define __NS_COMMON_H__ 19f08c3bdfSopenharmony_ci#include <sched.h> 20f08c3bdfSopenharmony_ci#include "lapi/namespaces_constants.h" 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_ci#define PROC_PATH "/proc" 23f08c3bdfSopenharmony_ci#define NS_TOTAL 6 24f08c3bdfSopenharmony_ci 25f08c3bdfSopenharmony_ci 26f08c3bdfSopenharmony_cistruct param { 27f08c3bdfSopenharmony_ci const char *name; 28f08c3bdfSopenharmony_ci int flag; 29f08c3bdfSopenharmony_ci}; 30f08c3bdfSopenharmony_ci 31f08c3bdfSopenharmony_cistruct param params[] = { 32f08c3bdfSopenharmony_ci {"ipc", CLONE_NEWIPC}, 33f08c3bdfSopenharmony_ci {"mnt", CLONE_NEWNS}, 34f08c3bdfSopenharmony_ci {"net", CLONE_NEWNET}, 35f08c3bdfSopenharmony_ci {"pid", CLONE_NEWPID}, 36f08c3bdfSopenharmony_ci {"user", CLONE_NEWUSER}, 37f08c3bdfSopenharmony_ci {"uts", CLONE_NEWUTS}, 38f08c3bdfSopenharmony_ci {NULL, 0} 39f08c3bdfSopenharmony_ci}; 40f08c3bdfSopenharmony_ci 41f08c3bdfSopenharmony_ci 42f08c3bdfSopenharmony_cistruct param *get_param(const char *name) 43f08c3bdfSopenharmony_ci{ 44f08c3bdfSopenharmony_ci int i; 45f08c3bdfSopenharmony_ci 46f08c3bdfSopenharmony_ci for (i = 0; params[i].name; i++) { 47f08c3bdfSopenharmony_ci if (!strcasecmp(params[i].name, name)) 48f08c3bdfSopenharmony_ci return params + i; 49f08c3bdfSopenharmony_ci } 50f08c3bdfSopenharmony_ci 51f08c3bdfSopenharmony_ci return NULL; 52f08c3bdfSopenharmony_ci} 53f08c3bdfSopenharmony_ci 54f08c3bdfSopenharmony_ci 55f08c3bdfSopenharmony_ci#endif 56