fs/orangefs/orangefs-sysfs.c

Source file repositories/reference/linux-study-clean/fs/orangefs/orangefs-sysfs.c

File Facts

System
Linux kernel
Corpus path
fs/orangefs/orangefs-sysfs.c
Extension
.c
Size
34932 bytes
Lines
1317
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct orangefs_attribute {
	struct attribute attr;
	ssize_t (*show)(struct kobject *kobj,
			struct orangefs_attribute *attr,
			char *buf);
	ssize_t (*store)(struct kobject *kobj,
			 struct orangefs_attribute *attr,
			 const char *buf,
			 size_t count);
};

static ssize_t orangefs_attr_show(struct kobject *kobj,
				  struct attribute *attr,
				  char *buf)
{
	struct orangefs_attribute *attribute;

	attribute = container_of(attr, struct orangefs_attribute, attr);
	if (!attribute->show)
		return -EIO;
	return attribute->show(kobj, attribute, buf);
}

static ssize_t orangefs_attr_store(struct kobject *kobj,
				   struct attribute *attr,
				   const char *buf,
				   size_t len)
{
	struct orangefs_attribute *attribute;

	if (!strcmp(kobj->name, PC_KOBJ_ID) ||
	    !strcmp(kobj->name, STATS_KOBJ_ID))
		return -EPERM;

	attribute = container_of(attr, struct orangefs_attribute, attr);
	if (!attribute->store)
		return -EIO;
	return attribute->store(kobj, attribute, buf, len);
}

static const struct sysfs_ops orangefs_sysfs_ops = {
	.show = orangefs_attr_show,
	.store = orangefs_attr_store,
};

static ssize_t sysfs_int_show(struct kobject *kobj,
    struct orangefs_attribute *attr, char *buf)
{
	int rc = -EIO;

	gossip_debug(GOSSIP_SYSFS_DEBUG, "sysfs_int_show: id:%s:\n",
	    kobj->name);

	if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
		if (!strcmp(attr->attr.name, "op_timeout_secs")) {
			rc = sysfs_emit(buf,
				       "%d\n",
				       op_timeout_secs);
			goto out;
		} else if (!strcmp(attr->attr.name,
				   "slot_timeout_secs")) {
			rc = sysfs_emit(buf,
				       "%d\n",
				       slot_timeout_secs);
			goto out;
		} else if (!strcmp(attr->attr.name,
				   "cache_timeout_msecs")) {
			rc = sysfs_emit(buf,
				       "%d\n",
				       orangefs_cache_timeout_msecs);
			goto out;
		} else if (!strcmp(attr->attr.name,
				   "dcache_timeout_msecs")) {
			rc = sysfs_emit(buf,
				       "%d\n",
				       orangefs_dcache_timeout_msecs);
			goto out;
		} else if (!strcmp(attr->attr.name,
				   "getattr_timeout_msecs")) {
			rc = sysfs_emit(buf,
				       "%d\n",
				       orangefs_getattr_timeout_msecs);
			goto out;
		} else {
			goto out;
		}

	} else if (!strcmp(kobj->name, STATS_KOBJ_ID)) {
		if (!strcmp(attr->attr.name, "reads")) {
			rc = sysfs_emit(buf,

Annotation

Implementation Notes