X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fptlrpc%2Fnodemap_lproc.c;h=f8d964dd73255f88d4a39f63da8d15a8d179ac1b;hb=f64aeebfceb306694f42688038f70197ac809a69;hp=d0858d113dc57dc1567bf3a71f5a33aeefb25acb;hpb=a9b830da51bd4d37cb7188c11ab101a40bc57f7f;p=fs%2Flustre-release.git diff --git a/lustre/ptlrpc/nodemap_lproc.c b/lustre/ptlrpc/nodemap_lproc.c index d0858d1..f8d964d 100644 --- a/lustre/ptlrpc/nodemap_lproc.c +++ b/lustre/ptlrpc/nodemap_lproc.c @@ -241,6 +241,74 @@ out: LPROC_SEQ_FOPS(nodemap_fileset); /** + * Reads and prints the SELinux policy info for the given nodemap. + * + * \param m seq file in proc fs + * \param data unused + * \retval 0 success + */ +static int nodemap_sepol_seq_show(struct seq_file *m, void *data) +{ + struct lu_nodemap *nodemap; + int rc = 0; + + mutex_lock(&active_config_lock); + nodemap = nodemap_lookup(m->private); + mutex_unlock(&active_config_lock); + if (IS_ERR(nodemap)) { + rc = PTR_ERR(nodemap); + CERROR("cannot find nodemap '%s': rc = %d\n", + (char *)m->private, rc); + return rc; + } + + seq_printf(m, "%s\n", nodemap_get_sepol(nodemap)); + nodemap_putref(nodemap); + return rc; +} + +/** + * Set SELinux policy info on a nodemap. + * + * \param[in] file proc file + * \param[in] buffer string, "" + * \param[in] count \a buffer length + * \param[in] off unused + * \retval \a count on success + * \retval negative number on error + */ +static ssize_t +nodemap_sepol_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) +{ + struct seq_file *m = file->private_data; + char sepol[LUSTRE_NODEMAP_SEPOL_LENGTH + 1]; + int rc = 0; + + CLASSERT(sizeof(sepol) == sizeof(((struct lu_nodemap *)0)->nm_sepol)); + + if (count > 0) { + if (count >= sizeof(sepol)) + GOTO(out, rc = -ENAMETOOLONG); + + if (copy_from_user(sepol, buffer, count)) + GOTO(out, rc = -EFAULT); + + sepol[count] = '\0'; + + rc = nodemap_set_sepol(m->private, sepol); + } + +out: + if (rc != 0) + return rc; + + return count; +} +LPROC_SEQ_FOPS(nodemap_sepol); + +/** * Reads and prints the exports attached to the given nodemap. * * \param m seq file in proc fs, stores nodemap @@ -650,6 +718,10 @@ static struct lprocfs_vars lprocfs_nodemap_vars[] = { .fops = &nodemap_fileset_fops, }, { + .name = "sepol", + .fops = &nodemap_sepol_fops, + }, + { .name = "exports", .fops = &nodemap_exports_fops, },