2 example program to read a file in the same way that Samba does. This
3 demonstrates the problem with GPFS share modes and leases and TSM
6 Andrew Tridgell January 2008
10 gcc -Wall -o tsmread{,.c} -lgpfs_gpl
12 then to run you must symlink tsmread to smbd
18 ./smbd /gpfs/data/tsmtest/test.dat
19 ./smbd /gpfs/data/tsmtest/test.dat -S
20 ./smbd /gpfs/data/tsmtest/test.dat -L
21 ./smbd /gpfs/data/tsmtest/test.dat -L -S
25 #define _XOPEN_SOURCE 500
40 static void sigio_handler(int sig)
42 printf("Got SIGIO\n");
45 static int read_file(const char *fname, bool use_lease, bool use_sharemode)
50 printf("Reading '%s' with use_lease=%s use_sharemode=%s\n",
51 fname, use_lease?"yes":"no", use_sharemode?"yes":"no");
53 signal(SIGIO, sigio_handler);
55 fd = open(fname, O_RDONLY);
61 if (use_lease && gpfs_set_lease(fd, GPFS_LEASE_READ) != 0) {
62 perror("gpfs_set_lease");
67 if (use_sharemode && gpfs_set_share(fd, 1, 2) != 0) {
68 perror("gpfs_set_share");
73 if (pread(fd, &c, 1, 0) != 1) {
85 static void usage(void)
87 printf("Usage: (note, must run as 'smbd')\n");
88 printf("ln -sf tesmread smbd\n");
89 printf("./smbd [options] <files>\n");
91 printf(" -L use gpfs leases\n");
92 printf(" -S use gpfs sharemodes\n");
96 int main(int argc, char * const argv[])
99 bool use_lease = false, use_sharemode = false;
101 /* parse command-line options */
102 while ((opt = getopt(argc, argv, "LSh")) != -1) {
108 use_sharemode = true;
123 for (i=0;i<argc;i++) {
124 const char *fname = argv[i];
125 if (read_file(fname, use_lease, use_sharemode) != 0) {
126 printf("Failed to read '%s'\n", fname);