Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/cs/vcs_src/mnt_list.c
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1990-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#include "mnt_imount.h"
21
22
#define USAGE "list [mount-point ...]"
23
24
int im_list_help(s)
25
char* s;
26
{
27
printf("\t%s\n", USAGE);
28
return (0);
29
}
30
31
int im_list(argc, argv)
32
int argc;
33
register char** argv;
34
{
35
register int n;
36
register char* s;
37
int seq;
38
int fd;
39
int len;
40
char* mpoint;
41
char buf[1024];
42
char reply[1024];
43
44
error_info.id = argv[0];
45
memset(buf, 0, sizeof(buf));
46
memset(reply, 0, sizeof(reply));
47
48
opt_info.index = 1;
49
while (n = optget(argv, "s:[server] "))
50
switch (n)
51
{
52
case 's':
53
s = opt_info.arg;
54
if ((fd = csopen(s, CS_OPEN_READ)) < 0)
55
{
56
printf("cannot connect cs server %s\n", s);
57
return (-1);
58
}
59
istate.cs_svc = strdup(s);
60
istate.fd = fd;
61
break;
62
case '?':
63
case ':':
64
printf(USAGE);
65
return (1);
66
}
67
argc -= opt_info.index;
68
argv += opt_info.index;
69
70
if (argc == 0)
71
{
72
seq = -1;
73
do
74
{
75
if (seq == -1)
76
sfsprintf(buf, sizeof(buf), "m -0\n");
77
else
78
sfsprintf(buf, sizeof(buf), "m %d\n", seq);
79
if (vcs_write(buf) <= 0 || vcs_read(reply, 1024) <= 0)
80
return (-1);
81
if (seq == -1)
82
{
83
if ((s = strstr(reply, "ok 0 ")) == NULL)
84
{
85
printf("%s", buf);
86
return (-1);
87
}
88
s += 5;
89
len = (int)strtol(s, (char**)0, 0);
90
}
91
else
92
printmtmsg(reply);
93
seq++;
94
} while (seq < len);
95
return (0);
96
}
97
else
98
{
99
while (argc> 0)
100
{
101
mpoint = *argv;
102
sfsprintf(buf, sizeof(buf), "m %s\n", mpoint);
103
if (vcs_write(buf) > 0 && vcs_read(reply, 1024) > 0)
104
printmtmsg(reply);
105
argc--;
106
argv++;
107
}
108
}
109
return (0);
110
}
111
112