compelling reason to use a kset in kernel code?
Robert P. J. Day
rpjday at crashcourse.ca
Sun Oct 14 04:27:34 EDT 2012
it's not at all clear to me what the value is in using a kset when
writing some kernel code. i can see the example program,
samples/kobject/kset-example.c, but that program doesn't seem to
demonstrate what the purpose is of the kset created.
as another example, consider the different filesystem
implementations under the fs/ directory, and grep to see who uses
what to create the appropriate entry under /sys/fs/:
$ grep -r "create_and_add" *
9p/v9fs.c: v9fs_kobj = kobject_create_and_add("9p", fs_kobj);
btrfs/sysfs.c: btrfs_kset = kset_create_and_add("btrfs", NULL, fs_kobj);
configfs/mount.c: config_kobj = kobject_create_and_add("config", kernel_kobj);
debugfs/inode.c: debug_kobj = kobject_create_and_add("debug", kernel_kobj);
dlm/lockspace.c: dlm_kset = kset_create_and_add("dlm", &dlm_uevent_ops, kernel_kobj);
ecryptfs/main.c: ecryptfs_kobj = kobject_create_and_add("ecryptfs", fs_kobj);
exofs/sys.c: exofs_kset = kset_create_and_add("exofs", NULL, fs_kobj);
exofs/sys.c: EXOFS_ERR("ERROR: kset_create_and_add exofs failed\n");
ext4/super.c: ext4_kset = kset_create_and_add("ext4", NULL, fs_kobj);
fscache/cache.c: cache->kobj = kobject_create_and_add(tagname, fscache_root);
fscache/main.c: fscache_root = kobject_create_and_add("fscache", kernel_kobj);
fuse/inode.c: fuse_kobj = kobject_create_and_add("fuse", fs_kobj);
fuse/inode.c: connections_kobj = kobject_create_and_add("connections", fuse_kobj);
gfs2/sys.c: gfs2_kset = kset_create_and_add("gfs2", &gfs2_uevent_ops, fs_kobj);
namespace.c: fs_kobj = kobject_create_and_add("fs", NULL);
ocfs2/cluster/sys.c: o2cb_kset = kset_create_and_add("o2cb", NULL, fs_kobj);
ocfs2/stackglue.c: ocfs2_kset = kset_create_and_add("ocfs2", NULL, fs_kobj);
$
as you can see, some use kobject_create_and_add() while others use
kset_create_and_add(), and it's not clear to me what the difference is
in *why* one was chosen over the other. thoughts? i'm sure there's a
simple distinction i'm just missing here.
rday
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
More information about the Kernelnewbies
mailing list