#ifdef CONFIG_SYSFS if (mod->param_attrs) { structmodule_param_attrs *param_attrs = mod->param_attrs; structattribute **attrs = param_attrs->grp.attrs; int i;
for (i = 0; attrs[i] != NULL; i++) { if (strcmp(attrs[i]->name, "my_param") == 0) { // 修改权限为只读 err = sysfs_chmod_file(kobj, attrs[i], 0444); if (err) pr_err("Failed to set my_param to ro: %d\n", err); else pr_info("my_param is now read-only\n"); break; } } } #endif