Lines Matching +full:mode +full:- +full:capable
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
4 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
41 return a->show ? a->show(sdp, buf) : 0; in gfs2_attr_show()
49 return a->store ? a->store(sdp, buf, len) : len; in gfs2_attr_store()
63 MAJOR(sdp->sd_vfs->s_dev), MINOR(sdp->sd_vfs->s_dev)); in id_show()
68 return snprintf(buf, PAGE_SIZE, "%s\n", sdp->sd_fsname); in fsname_show()
73 struct super_block *s = sdp->sd_vfs; in uuid_show()
76 if (uuid_is_null(&s->s_uuid)) in uuid_show()
78 return snprintf(buf, PAGE_SIZE, "%pUB\n", &s->s_uuid); in uuid_show()
83 struct super_block *sb = sdp->sd_vfs; in freeze_show()
84 int frozen = (sb->s_writers.frozen == SB_UNFROZEN) ? 0 : 1; in freeze_show()
97 if (!capable(CAP_SYS_ADMIN)) in freeze_store()
98 return -EPERM; in freeze_store()
102 error = thaw_super(sdp->sd_vfs); in freeze_store()
105 error = freeze_super(sdp->sd_vfs); in freeze_store()
108 return -EINVAL; in freeze_store()
129 if (!capable(CAP_SYS_ADMIN)) in withdraw_store()
130 return -EPERM; in withdraw_store()
137 return -EINVAL; in withdraw_store()
150 if (!capable(CAP_SYS_ADMIN)) in statfs_sync_store()
151 return -EPERM; in statfs_sync_store()
158 return -EINVAL; in statfs_sync_store()
160 gfs2_statfs_sync(sdp->sd_vfs, 0); in statfs_sync_store()
169 if (!capable(CAP_SYS_ADMIN)) in quota_sync_store()
170 return -EPERM; in quota_sync_store()
177 return -EINVAL; in quota_sync_store()
179 gfs2_quota_sync(sdp->sd_vfs, 0); in quota_sync_store()
190 if (!capable(CAP_SYS_ADMIN)) in quota_refresh_user_store()
191 return -EPERM; in quota_refresh_user_store()
199 return -EINVAL; in quota_refresh_user_store()
212 if (!capable(CAP_SYS_ADMIN)) in quota_refresh_group_store()
213 return -EPERM; in quota_refresh_group_store()
221 return -EINVAL; in quota_refresh_group_store()
234 char mode[16]; in demote_rq_store() local
237 if (!capable(CAP_SYS_ADMIN)) in demote_rq_store()
238 return -EPERM; in demote_rq_store()
241 mode); in demote_rq_store()
243 return -EINVAL; in demote_rq_store()
245 if (strcmp(mode, "EX") == 0) in demote_rq_store()
247 else if ((strcmp(mode, "CW") == 0) || (strcmp(mode, "DF") == 0)) in demote_rq_store()
249 else if ((strcmp(mode, "PR") == 0) || (strcmp(mode, "SH") == 0)) in demote_rq_store()
252 return -EINVAL; in demote_rq_store()
255 return -EINVAL; in demote_rq_store()
261 return -EINVAL; in demote_rq_store()
262 if (!test_and_set_bit(SDF_DEMOTE, &sdp->sd_flags)) in demote_rq_store()
273 #define GFS2_ATTR(name, mode, show, store) \ argument
274 static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store)
306 complete(&sdp->sd_kobj_unregister); in gfs2_sbd_release()
322 const struct lm_lockops *ops = sdp->sd_lockstruct.ls_ops; in proto_name_show()
323 return sprintf(buf, "%s\n", ops->lm_proto_name); in proto_name_show()
328 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in block_show()
332 if (test_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags)) in block_show()
340 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in block_store()
348 set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags); in block_store()
350 clear_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags); in block_store()
354 return -EINVAL; in block_store()
361 int val = completion_done(&sdp->sd_wdack) ? 1 : 0; in wdack_show()
375 !strcmp(sdp->sd_lockstruct.ls_ops->lm_proto_name, "lock_dlm")) in wdack_store()
376 complete(&sdp->sd_wdack); in wdack_store()
378 return -EINVAL; in wdack_store()
384 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in lkfirst_show()
385 return sprintf(buf, "%d\n", ls->ls_first); in lkfirst_show()
395 return -EINVAL; in lkfirst_store()
396 rv = wait_for_completion_killable(&sdp->sd_locking_init); in lkfirst_store()
399 spin_lock(&sdp->sd_jindex_spin); in lkfirst_store()
400 rv = -EBUSY; in lkfirst_store()
401 if (test_bit(SDF_NOJOURNALID, &sdp->sd_flags) == 0) in lkfirst_store()
403 rv = -EINVAL; in lkfirst_store()
404 if (sdp->sd_args.ar_spectator) in lkfirst_store()
406 if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL) in lkfirst_store()
408 sdp->sd_lockstruct.ls_first = first; in lkfirst_store()
411 spin_unlock(&sdp->sd_jindex_spin); in lkfirst_store()
417 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in first_done_show()
418 return sprintf(buf, "%d\n", !!test_bit(DFL_FIRST_MOUNT_DONE, &ls->ls_recover_flags)); in first_done_show()
427 wait_for_completion(&sdp->sd_journal_ready); in gfs2_recover_set()
429 spin_lock(&sdp->sd_jindex_spin); in gfs2_recover_set()
430 rv = -EBUSY; in gfs2_recover_set()
438 if (!sdp->sd_jdesc) in gfs2_recover_set()
440 if (sdp->sd_jdesc->jd_jid == jid && !sdp->sd_args.ar_spectator) in gfs2_recover_set()
442 rv = -ENOENT; in gfs2_recover_set()
443 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { in gfs2_recover_set()
444 if (jd->jd_jid != jid && !sdp->sd_args.ar_spectator) in gfs2_recover_set()
450 spin_unlock(&sdp->sd_jindex_spin); in gfs2_recover_set()
461 return -EINVAL; in recover_store()
463 if (test_bit(SDF_NORECOVERY, &sdp->sd_flags)) { in recover_store()
464 rv = -ESHUTDOWN; in recover_store()
475 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in recover_done_show()
476 return sprintf(buf, "%d\n", ls->ls_recover_jid_done); in recover_done_show()
481 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in recover_status_show()
482 return sprintf(buf, "%d\n", ls->ls_recover_jid_status); in recover_status_show()
487 return sprintf(buf, "%d\n", sdp->sd_lockstruct.ls_jid); in jid_show()
497 return -EINVAL; in jid_store()
498 rv = wait_for_completion_killable(&sdp->sd_locking_init); in jid_store()
501 spin_lock(&sdp->sd_jindex_spin); in jid_store()
502 rv = -EINVAL; in jid_store()
503 if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL) in jid_store()
505 rv = -EBUSY; in jid_store()
506 if (test_bit(SDF_NOJOURNALID, &sdp->sd_flags) == 0) in jid_store()
509 if (sdp->sd_args.ar_spectator && jid > 0) in jid_store()
510 rv = jid = -EINVAL; in jid_store()
511 sdp->sd_lockstruct.ls_jid = jid; in jid_store()
512 clear_bit(SDF_NOJOURNALID, &sdp->sd_flags); in jid_store()
514 wake_up_bit(&sdp->sd_flags, SDF_NOJOURNALID); in jid_store()
516 spin_unlock(&sdp->sd_jindex_spin); in jid_store()
553 sdp->sd_tune.gt_quota_scale_num, in quota_scale_show()
554 sdp->sd_tune.gt_quota_scale_den); in quota_scale_show()
560 struct gfs2_tune *gt = &sdp->sd_tune; in quota_scale_store()
563 if (!capable(CAP_SYS_ADMIN)) in quota_scale_store()
564 return -EPERM; in quota_scale_store()
567 return -EINVAL; in quota_scale_store()
569 spin_lock(>->gt_spin); in quota_scale_store()
570 gt->gt_quota_scale_num = x; in quota_scale_store()
571 gt->gt_quota_scale_den = y; in quota_scale_store()
572 spin_unlock(>->gt_spin); in quota_scale_store()
579 struct gfs2_tune *gt = &sdp->sd_tune; in tune_set()
583 if (!capable(CAP_SYS_ADMIN)) in tune_set()
584 return -EPERM; in tune_set()
591 return -EINVAL; in tune_set()
593 spin_lock(>->gt_spin); in tune_set()
595 spin_unlock(>->gt_spin); in tune_set()
605 return snprintf(buf, PAGE_SIZE, "%u\n", sdp->sd_tune.gt_##name); \
612 return tune_set(sdp, &sdp->sd_tune.gt_##name, check_zero, buf, len); \
649 struct super_block *sb = sdp->sd_vfs; in gfs2_sys_fs_add()
656 sprintf(spectator, "SPECTATOR=%d", sdp->sd_args.ar_spectator ? 1 : 0); in gfs2_sys_fs_add()
658 init_completion(&sdp->sd_kobj_unregister); in gfs2_sys_fs_add()
659 sdp->sd_kobj.kset = gfs2_kset; in gfs2_sys_fs_add()
660 error = kobject_init_and_add(&sdp->sd_kobj, &gfs2_ktype, NULL, in gfs2_sys_fs_add()
661 "%s", sdp->sd_table_name); in gfs2_sys_fs_add()
665 error = sysfs_create_group(&sdp->sd_kobj, &tune_group); in gfs2_sys_fs_add()
669 error = sysfs_create_group(&sdp->sd_kobj, &lock_module_group); in gfs2_sys_fs_add()
673 error = sysfs_create_link(&sdp->sd_kobj, in gfs2_sys_fs_add()
674 &disk_to_dev(sb->s_bdev->bd_disk)->kobj, in gfs2_sys_fs_add()
679 kobject_uevent_env(&sdp->sd_kobj, KOBJ_ADD, envp); in gfs2_sys_fs_add()
683 sysfs_remove_group(&sdp->sd_kobj, &lock_module_group); in gfs2_sys_fs_add()
685 sysfs_remove_group(&sdp->sd_kobj, &tune_group); in gfs2_sys_fs_add()
688 kobject_put(&sdp->sd_kobj); in gfs2_sys_fs_add()
689 wait_for_completion(&sdp->sd_kobj_unregister); in gfs2_sys_fs_add()
690 sb->s_fs_info = NULL; in gfs2_sys_fs_add()
696 sysfs_remove_link(&sdp->sd_kobj, "device"); in gfs2_sys_fs_del()
697 sysfs_remove_group(&sdp->sd_kobj, &tune_group); in gfs2_sys_fs_del()
698 sysfs_remove_group(&sdp->sd_kobj, &lock_module_group); in gfs2_sys_fs_del()
699 kobject_put(&sdp->sd_kobj); in gfs2_sys_fs_del()
700 wait_for_completion(&sdp->sd_kobj_unregister); in gfs2_sys_fs_del()
707 struct super_block *s = sdp->sd_vfs; in gfs2_uevent()
709 add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name); in gfs2_uevent()
710 add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name); in gfs2_uevent()
711 if (!test_bit(SDF_NOJOURNALID, &sdp->sd_flags)) in gfs2_uevent()
712 add_uevent_var(env, "JOURNALID=%d", sdp->sd_lockstruct.ls_jid); in gfs2_uevent()
713 if (!uuid_is_null(&s->s_uuid)) in gfs2_uevent()
714 add_uevent_var(env, "UUID=%pUB", &s->s_uuid); in gfs2_uevent()
726 return -ENOMEM; in gfs2_sys_init()