* Lustre is a trademark of Sun Microsystems, Inc.
*/
+#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <libgen.h>
#include <syslog.h>
-#include <libcfs/libcfs.h>
+#include <libcfs/util/param.h>
+#include <libcfs/util/string.h>
#include <lnet/nidstr.h>
#include <lustre/lustre_user.h>
#include <lustre/lustre_idl.h>
* the valid values for perms are:
* setuid/setgid/setgrp/rmtacl -- enable corresponding perm
* nosetuid/nosetgid/nosetgrp/normtacl -- disable corresponding perm
- * they can be listed together, seperated by ',',
+ * they can be listed together, separated by ',',
* when perm and noperm are in the same line (item), noperm is preferential,
* when they are in different lines (items), the latter is preferential,
* '*' nid is as default perm, and is not preferential.
static void usage(void)
{
- fprintf(stderr,
- "\nusage: %s {mdtname} {uid}\n"
- "Normally invoked as an upcall from Lustre, set via:\n"
- "/proc/fs/lustre/mdt/${mdtname}/identity_upcall\n",
- progname);
+ fprintf(stderr,
+ "\nusage: %s {mdtname} {uid}\n"
+ "Normally invoked as an upcall from Lustre, set via:\n"
+ "lctl set_param mdt.${mdtname}.identity_upcall={path to upcall}\n",
+ progname);
}
static int compare_u32(const void *v1, const void *v2)
pdd = &data->idd_perms[i];
- printf(" "LPX64"\t0x%x\n", pdd->pdd_nid, pdd->pdd_perm);
+ printf(" %#jx\t0x%x\n", (uintmax_t)pdd->pdd_nid,
+ pdd->pdd_perm);
}
printf("\n");
}
int main(int argc, char **argv)
{
- char *end;
- struct identity_downcall_data *data = NULL;
- char procname[1024];
- unsigned long uid;
- int fd, rc = -EINVAL, size, maxgroups;
+ char *end;
+ struct identity_downcall_data *data = NULL;
+ glob_t path;
+ unsigned long uid;
+ int fd, rc = -EINVAL, size, maxgroups;
progname = basename(argv[0]);
if (argc != 3) {
goto out;
}
- snprintf(procname, sizeof(procname),
- "/proc/fs/lustre/mdt/%s/identity_info", argv[1]);
- fd = open(procname, O_WRONLY);
- if (fd < 0) {
- errlog("can't open file %s: %s\n", procname, strerror(errno));
- rc = -1;
- goto out;
- }
+ rc = cfs_get_param_paths(&path, "mdt/%s/identity_info", argv[1]);
+ if (rc != 0) {
+ rc = -errno;
+ goto out;
+ }
- rc = write(fd, data, size);
- close(fd);
- if (rc != size) {
- errlog("partial write ret %d: %s\n", rc, strerror(errno));
- rc = -1;
- } else {
- rc = 0;
- }
+ fd = open(path.gl_pathv[0], O_WRONLY);
+ if (fd < 0) {
+ errlog("can't open file '%s':%s\n", path.gl_pathv[0],
+ strerror(errno));
+ rc = -errno;
+ goto out_params;
+ }
+
+ rc = write(fd, data, size);
+ close(fd);
+ if (rc != size) {
+ errlog("partial write ret %d: %s\n", rc, strerror(errno));
+ rc = -1;
+ } else {
+ rc = 0;
+ }
+out_params:
+ cfs_free_param_data(&path);
out:
- if (data != NULL)
- free(data);
- return rc;
+ if (data != NULL)
+ free(data);
+ return rc;
}