.. | .. |
---|
7 | 7 | * Copyright (c) 2007 SUSE Linux Products GmbH |
---|
8 | 8 | * Copyright (c) 2007 Tejun Heo <teheo@suse.de> |
---|
9 | 9 | * |
---|
10 | | - * Please see Documentation/filesystems/sysfs.txt for more information. |
---|
| 10 | + * Please see Documentation/filesystems/sysfs.rst for more information. |
---|
11 | 11 | */ |
---|
12 | 12 | |
---|
13 | 13 | #ifndef _SYSFS_H_ |
---|
.. | .. |
---|
123 | 123 | .show = _name##_show, \ |
---|
124 | 124 | } |
---|
125 | 125 | |
---|
| 126 | +#define __ATTR_RW_MODE(_name, _mode) { \ |
---|
| 127 | + .attr = { .name = __stringify(_name), \ |
---|
| 128 | + .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \ |
---|
| 129 | + .show = _name##_show, \ |
---|
| 130 | + .store = _name##_store, \ |
---|
| 131 | +} |
---|
| 132 | + |
---|
126 | 133 | #define __ATTR_WO(_name) { \ |
---|
127 | 134 | .attr = { .name = __stringify(_name), .mode = 0200 }, \ |
---|
128 | 135 | .store = _name##_store, \ |
---|
.. | .. |
---|
196 | 203 | .size = _size, \ |
---|
197 | 204 | } |
---|
198 | 205 | |
---|
| 206 | +#define __BIN_ATTR_WO(_name, _size) { \ |
---|
| 207 | + .attr = { .name = __stringify(_name), .mode = 0200 }, \ |
---|
| 208 | + .write = _name##_write, \ |
---|
| 209 | + .size = _size, \ |
---|
| 210 | +} |
---|
| 211 | + |
---|
199 | 212 | #define __BIN_ATTR_RW(_name, _size) \ |
---|
200 | 213 | __BIN_ATTR(_name, 0644, _name##_read, _name##_write, _size) |
---|
201 | 214 | |
---|
.. | .. |
---|
207 | 220 | |
---|
208 | 221 | #define BIN_ATTR_RO(_name, _size) \ |
---|
209 | 222 | struct bin_attribute bin_attr_##_name = __BIN_ATTR_RO(_name, _size) |
---|
| 223 | + |
---|
| 224 | +#define BIN_ATTR_WO(_name, _size) \ |
---|
| 225 | +struct bin_attribute bin_attr_##_name = __BIN_ATTR_WO(_name, _size) |
---|
210 | 226 | |
---|
211 | 227 | #define BIN_ATTR_RW(_name, _size) \ |
---|
212 | 228 | struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size) |
---|
.. | .. |
---|
234 | 250 | const struct attribute *attr, |
---|
235 | 251 | const void *ns); |
---|
236 | 252 | int __must_check sysfs_create_files(struct kobject *kobj, |
---|
237 | | - const struct attribute **attr); |
---|
| 253 | + const struct attribute * const *attr); |
---|
238 | 254 | int __must_check sysfs_chmod_file(struct kobject *kobj, |
---|
239 | 255 | const struct attribute *attr, umode_t mode); |
---|
240 | 256 | struct kernfs_node *sysfs_break_active_protection(struct kobject *kobj, |
---|
.. | .. |
---|
243 | 259 | void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr, |
---|
244 | 260 | const void *ns); |
---|
245 | 261 | bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr); |
---|
246 | | -void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr); |
---|
| 262 | +void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *attr); |
---|
247 | 263 | |
---|
248 | 264 | int __must_check sysfs_create_bin_file(struct kobject *kobj, |
---|
249 | 265 | const struct bin_attribute *attr); |
---|
.. | .. |
---|
268 | 284 | const struct attribute_group *grp); |
---|
269 | 285 | int __must_check sysfs_create_groups(struct kobject *kobj, |
---|
270 | 286 | const struct attribute_group **groups); |
---|
| 287 | +int __must_check sysfs_update_groups(struct kobject *kobj, |
---|
| 288 | + const struct attribute_group **groups); |
---|
271 | 289 | int sysfs_update_group(struct kobject *kobj, |
---|
272 | 290 | const struct attribute_group *grp); |
---|
273 | 291 | void sysfs_remove_group(struct kobject *kobj, |
---|
.. | .. |
---|
286 | 304 | struct kobject *target, const char *link_name); |
---|
287 | 305 | void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name, |
---|
288 | 306 | const char *link_name); |
---|
289 | | -int __compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj, |
---|
290 | | - struct kobject *target_kobj, |
---|
291 | | - const char *target_name); |
---|
| 307 | +int compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj, |
---|
| 308 | + struct kobject *target_kobj, |
---|
| 309 | + const char *target_name, |
---|
| 310 | + const char *symlink_name); |
---|
292 | 311 | |
---|
293 | 312 | void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); |
---|
294 | 313 | |
---|
.. | .. |
---|
299 | 318 | return kernfs_enable_ns(kn); |
---|
300 | 319 | } |
---|
301 | 320 | |
---|
| 321 | +int sysfs_file_change_owner(struct kobject *kobj, const char *name, kuid_t kuid, |
---|
| 322 | + kgid_t kgid); |
---|
| 323 | +int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid); |
---|
| 324 | +int sysfs_link_change_owner(struct kobject *kobj, struct kobject *targ, |
---|
| 325 | + const char *name, kuid_t kuid, kgid_t kgid); |
---|
| 326 | +int sysfs_groups_change_owner(struct kobject *kobj, |
---|
| 327 | + const struct attribute_group **groups, |
---|
| 328 | + kuid_t kuid, kgid_t kgid); |
---|
| 329 | +int sysfs_group_change_owner(struct kobject *kobj, |
---|
| 330 | + const struct attribute_group *groups, kuid_t kuid, |
---|
| 331 | + kgid_t kgid); |
---|
302 | 332 | __printf(2, 3) |
---|
303 | 333 | int sysfs_emit(char *buf, const char *fmt, ...); |
---|
304 | 334 | __printf(3, 4) |
---|
.. | .. |
---|
347 | 377 | } |
---|
348 | 378 | |
---|
349 | 379 | static inline int sysfs_create_files(struct kobject *kobj, |
---|
350 | | - const struct attribute **attr) |
---|
| 380 | + const struct attribute * const *attr) |
---|
351 | 381 | { |
---|
352 | 382 | return 0; |
---|
353 | 383 | } |
---|
.. | .. |
---|
382 | 412 | } |
---|
383 | 413 | |
---|
384 | 414 | static inline void sysfs_remove_files(struct kobject *kobj, |
---|
385 | | - const struct attribute **attr) |
---|
| 415 | + const struct attribute * const *attr) |
---|
386 | 416 | { |
---|
387 | 417 | } |
---|
388 | 418 | |
---|
.. | .. |
---|
438 | 468 | return 0; |
---|
439 | 469 | } |
---|
440 | 470 | |
---|
| 471 | +static inline int sysfs_update_groups(struct kobject *kobj, |
---|
| 472 | + const struct attribute_group **groups) |
---|
| 473 | +{ |
---|
| 474 | + return 0; |
---|
| 475 | +} |
---|
| 476 | + |
---|
441 | 477 | static inline int sysfs_update_group(struct kobject *kobj, |
---|
442 | 478 | const struct attribute_group *grp) |
---|
443 | 479 | { |
---|
.. | .. |
---|
488 | 524 | { |
---|
489 | 525 | } |
---|
490 | 526 | |
---|
491 | | -static inline int __compat_only_sysfs_link_entry_to_kobj( |
---|
492 | | - struct kobject *kobj, |
---|
493 | | - struct kobject *target_kobj, |
---|
494 | | - const char *target_name) |
---|
| 527 | +static inline int compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj, |
---|
| 528 | + struct kobject *target_kobj, |
---|
| 529 | + const char *target_name, |
---|
| 530 | + const char *symlink_name) |
---|
495 | 531 | { |
---|
496 | 532 | return 0; |
---|
497 | 533 | } |
---|
.. | .. |
---|
510 | 546 | { |
---|
511 | 547 | } |
---|
512 | 548 | |
---|
| 549 | +static inline int sysfs_file_change_owner(struct kobject *kobj, |
---|
| 550 | + const char *name, kuid_t kuid, |
---|
| 551 | + kgid_t kgid) |
---|
| 552 | +{ |
---|
| 553 | + return 0; |
---|
| 554 | +} |
---|
| 555 | + |
---|
| 556 | +static inline int sysfs_link_change_owner(struct kobject *kobj, |
---|
| 557 | + struct kobject *targ, |
---|
| 558 | + const char *name, kuid_t kuid, |
---|
| 559 | + kgid_t kgid) |
---|
| 560 | +{ |
---|
| 561 | + return 0; |
---|
| 562 | +} |
---|
| 563 | + |
---|
| 564 | +static inline int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid) |
---|
| 565 | +{ |
---|
| 566 | + return 0; |
---|
| 567 | +} |
---|
| 568 | + |
---|
| 569 | +static inline int sysfs_groups_change_owner(struct kobject *kobj, |
---|
| 570 | + const struct attribute_group **groups, |
---|
| 571 | + kuid_t kuid, kgid_t kgid) |
---|
| 572 | +{ |
---|
| 573 | + return 0; |
---|
| 574 | +} |
---|
| 575 | + |
---|
| 576 | +static inline int sysfs_group_change_owner(struct kobject *kobj, |
---|
| 577 | + const struct attribute_group *groups, |
---|
| 578 | + kuid_t kuid, kgid_t kgid) |
---|
| 579 | +{ |
---|
| 580 | + return 0; |
---|
| 581 | +} |
---|
| 582 | + |
---|
513 | 583 | __printf(2, 3) |
---|
514 | 584 | static inline int sysfs_emit(char *buf, const char *fmt, ...) |
---|
515 | 585 | { |
---|