1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.sf.net/projects/lustre/
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.
30 #include <sys/ioctl.h>
36 #include <liblustre.h>
37 #include <linux/lustre_mds.h>
39 static void usage(char *argv0, int status)
42 "Usage: %s [OPTION...]\n\
44 --getattr <directory>\n\
45 --setattr <directory>\n\
46 --readpage <directory>\n\
48 --close <directory handle (returned by open)>\n\
49 --create <new name>\n", argv0);
54 int main(int argc, char **argv)
61 char *short_opts = "h", *name = argv[0];
62 static struct option long_opts[] = {
63 #define OPT_GETATTR -2
64 {"getattr", no_argument, NULL, OPT_GETATTR},
65 #define OPT_READPAGE -3
66 {"readpage", no_argument, NULL, OPT_READPAGE},
67 #define OPT_SETATTR -4
68 {"setattr", no_argument, NULL, OPT_SETATTR},
70 {"create", no_argument, NULL, OPT_CREATE},
72 {"open", no_argument, NULL, OPT_OPEN},
74 {"close", required_argument, NULL, OPT_CLOSE},
76 {"help", no_argument, NULL, OPT_HELP},
81 c = getopt_long(argc, argv, short_opts, long_opts, NULL);
88 cmd = IOC_REQUEST_GETATTR;
93 cmd = IOC_REQUEST_SETATTR;
98 cmd = IOC_REQUEST_READPAGE;
103 cmd = IOC_REQUEST_CREATE;
108 cmd = IOC_REQUEST_OPEN;
113 cmd = IOC_REQUEST_CLOSE;
115 arg = strtoul(optarg, NULL, 0);
125 fd = open("/dev/request", O_RDONLY);
127 fprintf(stderr, "error opening /dev/request: %s\n",
132 fprintf(stderr, "Executing %s test (arg=%lu)...\n", name, arg);
133 if (cmd == IOC_REQUEST_OPEN) {
134 rc = ioctl(fd, cmd, &arg);
135 printf("%lu\n", arg);
137 rc = ioctl(fd, cmd, arg);
138 fprintf(stderr, "result code: %d\n", rc);