1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2004 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 #include <lustre/lustre_user.h>
34 int get_groups_local(struct mds_grp_downcall_data **grp)
36 struct mds_grp_downcall_data *param;
37 int i, maxgroups, size;
41 pw = getpwuid((*grp)->mgd_uid);
43 (*grp)->mgd_err = -errno;
44 return sizeof(*param);
47 maxgroups = sysconf(_SC_NGROUPS_MAX);
48 size = offsetof(struct mds_grp_downcall_data, mgd_groups[maxgroups]);
51 (*grp)->mgd_err = -ENOMEM;
52 return sizeof(*param);
55 memcpy(param, *grp, sizeof(*param));
57 while ((gr = getgrent())) {
60 for (i = 0; gr->gr_mem[i]; i++) {
61 if (strcmp(gr->gr_mem[i], pw->pw_name) == 0) {
62 param->mgd_groups[param->mgd_ngroups++] =
67 if (param->mgd_ngroups == maxgroups)
75 /* Note that we need to make the downcall regardless of error, so that the
76 * MDS doesn't continue to wait on the upcall. */
77 int main(int argc, char **argv)
80 struct mds_grp_downcall_data sparam = { MDS_GRP_DOWNCALL_MAGIC };
81 struct mds_grp_downcall_data *param = &sparam;
85 printf("bad parameter\n");
89 snprintf(pathname, 1024, "/proc/fs/lustre/mds/%s/group_info", argv[1]);
90 param->mgd_uid = atoi(argv[2]);
92 fd = open(pathname, O_WRONLY);
94 printf("can't open device %s\n", pathname);
98 size = get_groups_local(¶m);
100 rc = write(fd, param, size);