Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/cs/vcs_src/mnt_umount.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 "umount mount-point1 mount-point2 ..."
23
24
int im_umount_help(s)
25
char* s;
26
{
27
printf("\t%s\n", USAGE);
28
return (0);
29
}
30
31
int im_umount(argc, argv)
32
int argc;
33
register char** argv;
34
{
35
int n;
36
register char* s;
37
int fd;
38
char buf[1024];
39
char reply[1024];
40
41
error_info.id = argv[0];
42
memset(buf, 0, sizeof(buf));
43
memset(reply, 0, sizeof(reply));
44
45
opt_info.index = 1;
46
while (n = optget(argv, "s:[cs_server] [mount-point ...]"))
47
switch (n)
48
{
49
case 's':
50
s = opt_info.arg;
51
if ((fd = csopen(s, CS_OPEN_READ)) < 0)
52
{
53
printf("cannot connect cs server %s\n", s);
54
return (-1);
55
}
56
istate.cs_svc = strdup(s);
57
istate.fd = fd;
58
break;
59
case '?':
60
case ':':
61
printf(USAGE);
62
return (1);
63
}
64
65
argv += opt_info.index;
66
argc -= opt_info.index;
67
68
while(argc > 0)
69
{
70
s = *argv;
71
sfsprintf(buf, sizeof(buf), "m %s -\n", s);
72
if (vcs_write(buf) > 0 && vcs_read(reply, 1024) > 0)
73
{
74
if (strncmp(reply, "I 0 ok 0", 8) == 0)
75
{
76
printf("%s deleted\n", s);
77
(void)rm_entry(s);
78
}
79
else
80
printf(reply);
81
}
82
argc--;
83
argv++;
84
}
85
86
return (0);
87
}
88
89