Thread (28 messages) flat view 28 messages, 4 authors, 2020-02-24

Re: [PATCH net-next v3 1/9] sysfs: add sysfs_file_change_owner{_by_name}()

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: 2020-02-20 11:20:53
Also in: linux-pm, lkml

On Tue, Feb 18, 2020 at 05:29:35PM +0100, Christian Brauner wrote:
+/**
+ *	sysfs_file_change_owner - change owner of a file.
+ *	@kobj:	object.
+ *	@kuid: new owner's kuid
+ *	@kgid: new owner's kgid
+ */
+int sysfs_file_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid)
+{
+	struct kernfs_node *kn;
+	int error;
+
+	if (!kobj->state_in_sysfs)
+		return -EINVAL;
+
+	kernfs_get(kobj->sd);
+
+	kn = kobj->sd;
+	error = internal_change_owner(kn, kobj, kuid, kgid);
+
+	kernfs_put(kn);
+
+	return error;
+}
+EXPORT_SYMBOL_GPL(sysfs_file_change_owner);
Oops, wait, what "file" are you changing here?  You aren't changing the
kobject's attributes, but rather a file in the kobject's directory,
right?  But kobj->sd is the directory of the kobject itself, so why
isn't this function just the same thing as sysfs_change_owner()?

Why would you call this function at all?

confused,

greg k-h
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help