1d9d16e16SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 28488a38fSDavid Howells /* Kernel object name space definitions 38488a38fSDavid Howells * 48488a38fSDavid Howells * Copyright (c) 2002-2003 Patrick Mochel 58488a38fSDavid Howells * Copyright (c) 2002-2003 Open Source Development Labs 68488a38fSDavid Howells * Copyright (c) 2006-2008 Greg Kroah-Hartman <[email protected]> 78488a38fSDavid Howells * Copyright (c) 2006-2008 Novell Inc. 88488a38fSDavid Howells * 98488a38fSDavid Howells * Split from kobject.h by David Howells ([email protected]) 108488a38fSDavid Howells * 110c1bc6b8SMauro Carvalho Chehab * Please read Documentation/core-api/kobject.rst before using the kobject 128488a38fSDavid Howells * interface, ESPECIALLY the parts about reference counts and object 138488a38fSDavid Howells * destructors. 148488a38fSDavid Howells */ 158488a38fSDavid Howells 168488a38fSDavid Howells #ifndef _LINUX_KOBJECT_NS_H 178488a38fSDavid Howells #define _LINUX_KOBJECT_NS_H 188488a38fSDavid Howells 198488a38fSDavid Howells struct sock; 208488a38fSDavid Howells struct kobject; 218488a38fSDavid Howells 228488a38fSDavid Howells /* 238488a38fSDavid Howells * Namespace types which are used to tag kobjects and sysfs entries. 248488a38fSDavid Howells * Network namespace will likely be the first. 258488a38fSDavid Howells */ 268488a38fSDavid Howells enum kobj_ns_type { 278488a38fSDavid Howells KOBJ_NS_TYPE_NONE = 0, 288488a38fSDavid Howells KOBJ_NS_TYPE_NET, 298488a38fSDavid Howells KOBJ_NS_TYPES 308488a38fSDavid Howells }; 318488a38fSDavid Howells 328488a38fSDavid Howells /* 338488a38fSDavid Howells * Callbacks so sysfs can determine namespaces 34a685e089SAl Viro * @grab_current_ns: return a new reference to calling task's namespace 358488a38fSDavid Howells * @netlink_ns: return namespace to which a sock belongs (right?) 368488a38fSDavid Howells * @initial_ns: return the initial namespace (i.e. init_net_ns) 37a685e089SAl Viro * @drop_ns: drops a reference to namespace 388488a38fSDavid Howells */ 398488a38fSDavid Howells struct kobj_ns_type_operations { 408488a38fSDavid Howells enum kobj_ns_type type; 417dc5dbc8SEric W. Biederman bool (*current_may_mount)(void); 42a685e089SAl Viro void *(*grab_current_ns)(void); 438488a38fSDavid Howells const void *(*netlink_ns)(struct sock *sk); 448488a38fSDavid Howells const void *(*initial_ns)(void); 45a685e089SAl Viro void (*drop_ns)(void *); 468488a38fSDavid Howells }; 478488a38fSDavid Howells 488488a38fSDavid Howells int kobj_ns_type_register(const struct kobj_ns_type_operations *ops); 498488a38fSDavid Howells int kobj_ns_type_registered(enum kobj_ns_type type); 50*542aa246SGreg Kroah-Hartman const struct kobj_ns_type_operations *kobj_child_ns_ops(const struct kobject *parent); 51*542aa246SGreg Kroah-Hartman const struct kobj_ns_type_operations *kobj_ns_ops(const struct kobject *kobj); 528488a38fSDavid Howells 537dc5dbc8SEric W. Biederman bool kobj_ns_current_may_mount(enum kobj_ns_type type); 54a685e089SAl Viro void *kobj_ns_grab_current(enum kobj_ns_type type); 55a685e089SAl Viro void kobj_ns_drop(enum kobj_ns_type type, void *ns); 568488a38fSDavid Howells 578488a38fSDavid Howells #endif /* _LINUX_KOBJECT_NS_H */ 58