sysfs.c (02a476d932287cf3096f78962ccb70d94d6203c6) sysfs.c (19cdc8fa5b9b768f5753eefe3da32fcbafcb0d18)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2019 Hammerspace Inc
4 */
5
6#include <linux/module.h>
7#include <linux/kobject.h>
8#include <linux/sysfs.h>

--- 12 unchanged lines hidden (view full) ---

21static struct kset *nfs_client_kset;
22
23static void nfs_netns_object_release(struct kobject *kobj)
24{
25 kfree(kobj);
26}
27
28static const struct kobj_ns_type_operations *nfs_netns_object_child_ns_type(
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2019 Hammerspace Inc
4 */
5
6#include <linux/module.h>
7#include <linux/kobject.h>
8#include <linux/sysfs.h>

--- 12 unchanged lines hidden (view full) ---

21static struct kset *nfs_client_kset;
22
23static void nfs_netns_object_release(struct kobject *kobj)
24{
25 kfree(kobj);
26}
27
28static const struct kobj_ns_type_operations *nfs_netns_object_child_ns_type(
29 const struct kobject *kobj)
29 struct kobject *kobj)
30{
31 return &net_ns_type_operations;
32}
33
34static struct kobj_type nfs_netns_object_type = {
35 .release = nfs_netns_object_release,
36 .sysfs_ops = &kobj_sysfs_ops,
37 .child_ns_type = nfs_netns_object_child_ns_type,

--- 39 unchanged lines hidden (view full) ---

77 struct kobj_attribute *attr, char *buf)
78{
79 struct nfs_netns_client *c = container_of(kobj,
80 struct nfs_netns_client,
81 kobject);
82 ssize_t ret;
83
84 rcu_read_lock();
30{
31 return &net_ns_type_operations;
32}
33
34static struct kobj_type nfs_netns_object_type = {
35 .release = nfs_netns_object_release,
36 .sysfs_ops = &kobj_sysfs_ops,
37 .child_ns_type = nfs_netns_object_child_ns_type,

--- 39 unchanged lines hidden (view full) ---

77 struct kobj_attribute *attr, char *buf)
78{
79 struct nfs_netns_client *c = container_of(kobj,
80 struct nfs_netns_client,
81 kobject);
82 ssize_t ret;
83
84 rcu_read_lock();
85 ret = scnprintf(buf, PAGE_SIZE, "%s\n", rcu_dereference(c->identifier));
85 ret = sysfs_emit(buf, "%s\n", rcu_dereference(c->identifier));
86 rcu_read_unlock();
87 return ret;
88}
89
90/* Strip trailing '\n' */
91static size_t nfs_string_strip(const char *c, size_t len)
92{
93 while (len > 0 && c[len-1] == '\n')

--- 31 unchanged lines hidden (view full) ---

125 struct nfs_netns_client *c = container_of(kobj,
126 struct nfs_netns_client,
127 kobject);
128
129 kfree(rcu_dereference_raw(c->identifier));
130 kfree(c);
131}
132
86 rcu_read_unlock();
87 return ret;
88}
89
90/* Strip trailing '\n' */
91static size_t nfs_string_strip(const char *c, size_t len)
92{
93 while (len > 0 && c[len-1] == '\n')

--- 31 unchanged lines hidden (view full) ---

125 struct nfs_netns_client *c = container_of(kobj,
126 struct nfs_netns_client,
127 kobject);
128
129 kfree(rcu_dereference_raw(c->identifier));
130 kfree(c);
131}
132
133static const void *nfs_netns_client_namespace(const struct kobject *kobj)
133static const void *nfs_netns_client_namespace(struct kobject *kobj)
134{
135 return container_of(kobj, struct nfs_netns_client, kobject)->net;
136}
137
138static struct kobj_attribute nfs_netns_client_id = __ATTR(identifier,
139 0644, nfs_netns_identifier_show, nfs_netns_identifier_store);
140
141static struct attribute *nfs_netns_client_attrs[] = {

--- 51 unchanged lines hidden ---
134{
135 return container_of(kobj, struct nfs_netns_client, kobject)->net;
136}
137
138static struct kobj_attribute nfs_netns_client_id = __ATTR(identifier,
139 0644, nfs_netns_identifier_show, nfs_netns_identifier_store);
140
141static struct attribute *nfs_netns_client_attrs[] = {

--- 51 unchanged lines hidden ---