Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Kernel object name space definitions
0003  *
0004  * Copyright (c) 2002-2003 Patrick Mochel
0005  * Copyright (c) 2002-2003 Open Source Development Labs
0006  * Copyright (c) 2006-2008 Greg Kroah-Hartman <greg@kroah.com>
0007  * Copyright (c) 2006-2008 Novell Inc.
0008  *
0009  * Split from kobject.h by David Howells (dhowells@redhat.com)
0010  *
0011  * Please read Documentation/core-api/kobject.rst before using the kobject
0012  * interface, ESPECIALLY the parts about reference counts and object
0013  * destructors.
0014  */
0015 
0016 #ifndef _LINUX_KOBJECT_NS_H
0017 #define _LINUX_KOBJECT_NS_H
0018 
0019 struct sock;
0020 struct kobject;
0021 
0022 /*
0023  * Namespace types which are used to tag kobjects and sysfs entries.
0024  * Network namespace will likely be the first.
0025  */
0026 enum kobj_ns_type {
0027     KOBJ_NS_TYPE_NONE = 0,
0028     KOBJ_NS_TYPE_NET,
0029     KOBJ_NS_TYPES
0030 };
0031 
0032 /*
0033  * Callbacks so sysfs can determine namespaces
0034  *   @grab_current_ns: return a new reference to calling task's namespace
0035  *   @netlink_ns: return namespace to which a sock belongs (right?)
0036  *   @initial_ns: return the initial namespace (i.e. init_net_ns)
0037  *   @drop_ns: drops a reference to namespace
0038  */
0039 struct kobj_ns_type_operations {
0040     enum kobj_ns_type type;
0041     bool (*current_may_mount)(void);
0042     void *(*grab_current_ns)(void);
0043     const void *(*netlink_ns)(struct sock *sk);
0044     const void *(*initial_ns)(void);
0045     void (*drop_ns)(void *);
0046 };
0047 
0048 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
0049 int kobj_ns_type_registered(enum kobj_ns_type type);
0050 const struct kobj_ns_type_operations *kobj_child_ns_ops(struct kobject *parent);
0051 const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj);
0052 
0053 bool kobj_ns_current_may_mount(enum kobj_ns_type type);
0054 void *kobj_ns_grab_current(enum kobj_ns_type type);
0055 const void *kobj_ns_netlink(enum kobj_ns_type type, struct sock *sk);
0056 const void *kobj_ns_initial(enum kobj_ns_type type);
0057 void kobj_ns_drop(enum kobj_ns_type type, void *ns);
0058 
0059 #endif /* _LINUX_KOBJECT_NS_H */