9 #define max(a,b) (((a) > (b))? (a): (b))
10 #define min(a,b) (((a) < (b))? (a): (b))
12 typedef struct Aux Aux;
16 char *path; /* full path fo file */
17 Share *sp; /* this share's info */
18 long expire; /* expiration time of cache */
19 long off; /* file pos of start of cache */
20 long end; /* file pos of end of cache */
22 int fh; /* file handle */
23 int sh; /* search handle */
24 long srch; /* find first's internal state */
29 int Checkcase = 1; /* enforce case significance on filenames */
30 int Dfstout = 100; /* timeout (in ms) for ping of dfs servers (assume they are local) */
31 int Billtrog = 1; /* enable file owner/group resolution */
32 int Attachpid; /* pid of proc that attaches (ugh !) */
33 char *Debug = nil; /* messages */
34 Qid Root; /* root of remote system */
35 Share Ipc; /* Share info of IPC$ share */
36 Session *Sess; /* current session */
37 int Active = IDLE_TIME; /* secs until next keepalive is sent */
38 static int Keeppid; /* process ID of keepalive thread */
39 Share Shares[MAX_SHARES]; /* table of connected shares */
40 int Nshares = 0; /* number of Shares connected */
41 Aux *Auxroot = nil; /* linked list of Aux structs */
42 char *Host = nil; /* host we are connected to */
44 static char *Ipcname = "IPC$";
46 #define ptype(x) (((x) & 0xf))
47 #define pindex(x) (((x) & 0xff0) >> 4)
56 * This is revolting but I cannot see any other way to get
57 * the pid of the server. We need this as Windows doesn't
58 * drop the TCP connection when it closes a connection.
59 * Thus we keepalive() to detect when/if we are thrown off.
63 snprint(buf, sizeof buf, "#p/%d/args", getpid());
64 if((fd = open(buf, OWRITE)) >= 0){
65 fprint(fd, "%s network", Host);
76 if((ap = Auxroot) != nil)
83 fmtprint(f, "%-9s %s\n", type, ap->path);
85 }while(ap != Auxroot);
90 mkqid(char *s, int is_dir, long vers, int subtype, long path)
93 union { /* align digest suitably */
94 uchar digest[SHA1dlen];
98 sha1((uchar *)s, strlen(s), u.digest, nil);
99 q.type = (is_dir)? QTDIR: 0;
102 q.path = *((uvlong *)u.digest) & ~0xfffL;
103 q.path |= ((path & 0xff) << 4);
104 q.path |= (subtype & 0xf);
107 q.path = *((uvlong *)u.digest) & ~0xfL;
112 * used only for root dir and shares
115 V2D(Dir *d, Qid qid, char *name)
117 memset(d, 0, sizeof(Dir));
120 d->name = estrdup9p(name);
121 d->uid = estrdup9p("bill");
122 d->muid = estrdup9p("boyd");
123 d->gid = estrdup9p("trog");
124 d->mode = 0755 | DMDIR;
125 d->atime = time(nil);
132 I2D(Dir *d, Share *sp, char *path, FInfo *fi)
136 if((name = strrchr(fi->name, '\\')) != nil)
140 d->name = estrdup9p(name);
143 d->uid = estrdup9p("bill");
144 d->gid = estrdup9p("trog");
145 d->muid = estrdup9p("boyd");
146 d->atime = fi->accessed;
147 d->mtime = fi->written;
149 if(fi->attribs & ATTR_READONLY)
154 d->length = fi->size;
155 d->qid = mkqid(path, fi->attribs & ATTR_DIRECTORY, fi->changed, 0, 0);
157 if(fi->attribs & ATTR_DIRECTORY){
159 d->mode |= DMDIR|0111;
164 responderrstr(Req *r)
169 rerrstr(e, sizeof e);
174 newpath(char *path, char *name)
178 assert((p = strrchr(path, '/')) != nil);
180 if(strcmp(name, "..") == 0){
182 return estrdup9p("/");
183 q = emalloc9p((p-path)+1);
184 strecpy(q, q+(p-path)+1, path);
187 if(strcmp(path, "/") == 0)
188 return smprint("/%s", name);
189 return smprint("%s/%s", path, name);
193 dirgen(int slot, Dir *d, void *aux)
200 int numinf = numinfo();
203 slots = 128; /* number of dir entries to fetch at one time */
205 if(strcmp(a->path, "/") == 0){
214 V2D(d, mkqid(Shares[slot].name, 1, 1, Pshare, slot),
219 off = slot * sizeof(FInfo);
220 if(off >= a->off && off < a->end && time(nil) < a->expire)
224 fi = (FInfo *)a->cache;
225 npath = smprint("%s/*", mapfile(a->path));
226 a->sh = T2findfirst(Sess, a->sp, slots, npath, &got, &a->srch,
233 a->end = got * sizeof(FInfo);
235 if(got >= 2 && strcmp(fi[0].name, ".") == 0 &&
236 strcmp(fi[1].name, "..") == 0){
237 a->end = (got - 2) * sizeof(FInfo);
238 memmove(a->cache, a->cache + sizeof(FInfo)*2,
243 while(off >= a->end && a->sh != -1){
244 fi = (FInfo *)(a->cache + (a->end - a->off) - sizeof(FInfo));
246 npath = smprint("%s/%s", mapfile(a->path), fi->name);
247 rc = T2findnext(Sess, a->sp, slots, npath,
248 &got, &a->srch, (FInfo *)a->cache, a->sh);
250 if(rc == -1 || got == 0)
252 a->end = a->off + got * sizeof(FInfo);
254 a->expire = time(nil) + CACHETIME;
258 CIFSfindclose2(Sess, a->sp, a->sh);
266 fi = (FInfo *)(a->cache + (off - a->off));
267 npath = smprint("%s/%s", mapfile(a->path), fi->name);
268 I2D(d, a->sp, npath, fi);
270 upd_names(Sess, a->sp, npath, d);
279 static int first = 1;
280 char *spec = r->ifcall.aname;
286 respond(r, "invalid attach specifier");
290 r->ofcall.qid = mkqid("/", 1, 1, Proot, 0);
291 r->fid->qid = r->ofcall.qid;
293 a = r->fid->aux = emalloc9p(sizeof(Aux));
294 memset(a, 0, sizeof(Aux));
295 a->path = estrdup9p("/");
302 a->next = Auxroot->next;
303 Auxroot->next->prev = a;
314 fsclone(Fid *ofid, Fid *fid)
317 Aux *a = emalloc9p(sizeof(Aux));
321 memset(a, 0, sizeof(Aux));
325 a->path = estrdup9p(oa->path);
329 a->next = Auxroot->next;
330 Auxroot->next->prev = a;
341 * for some weird reason T2queryall() returns share names
342 * in lower case so we have to do an extra test against
343 * our share table to validate filename case.
345 * on top of this here (snell & Wilcox) most of our
346 * redirections point to a share of the same name,
347 * but some do not, thus the tail of the filename
348 * returned by T2queryall() is not the same as
349 * the name we wanted.
351 * We work around this by not validating the names
352 * or files which resolve to share names as they must
353 * be correct, having been enforced in the dfs layer.
356 validfile(char *found, char *want, char *winpath, Share *sp)
360 if(strcmp(want, "..") == 0)
362 if(strcmp(winpath, "/") == 0){
363 share = trimshare(sp->name);
364 if(cistrcmp(want, share) == 0)
365 return strcmp(want, share) == 0;
367 * OK, a DFS redirection points us from a directory XXX
368 * to a share named YYY. There is no case checking we can
369 * do so we allow either case - it's all we can do.
373 if(cistrcmp(found, want) != 0)
377 if(strcmp(found, want) == 0)
384 fswalk1(Fid *fid, char *name, Qid *qid)
389 static char e[ERRMAX];
390 char *p, *npath, *winpath;
393 npath = newpath(a->path, name);
394 if(strcmp(npath, "/") == 0){ /* root dir */
395 *qid = mkqid("/", 1, 1, Proot, 0);
402 if(strrchr(npath, '/') == npath){ /* top level dir */
403 if((n = walkinfo(name)) != -1){ /* info file */
404 *qid = mkqid(npath, 0, 1, Pinfo, n);
406 else { /* volume name */
407 for(i = 0; i < Nshares; i++){
408 n = strlen(Shares[i].name);
409 if(cistrncmp(npath+1, Shares[i].name, n) != 0)
411 if(Checkcase && strncmp(npath+1, Shares[i].name, n) != 0)
413 if(npath[n+1] != 0 && npath[n+1] != '/')
422 *qid = mkqid(npath, 1, 1, Pshare, i);
430 /* must be a vanilla file or directory */
432 if(mapshare(npath, &a->sp) == -1){
433 rerrstr(e, sizeof(e));
438 winpath = mapfile(npath);
439 memset(&fi, 0, sizeof fi);
440 if(Sess->caps & CAP_NT_SMBS)
441 rc = T2queryall(Sess, a->sp, winpath, &fi);
443 rc = T2querystandard(Sess, a->sp, winpath, &fi);
446 rerrstr(e, sizeof(e));
451 if((a->sp->options & SMB_SHARE_IS_IN_DFS) != 0 &&
452 (fi.attribs & ATTR_REPARSE) != 0){
453 if(redirect(Sess, a->sp, npath) != -1)
457 if((p = strrchr(fi.name, '/')) == nil && (p = strrchr(fi.name, '\\')) == nil)
462 if(! validfile(p, name, winpath, a->sp)){
467 *qid = mkqid(npath, fi.attribs & ATTR_DIRECTORY, fi.changed, 0, 0);
480 Aux *a = r->fid->aux;
482 if(ptype(r->fid->qid.path) == Proot)
483 V2D(&r->d, r->fid->qid, "");
484 else if(ptype(r->fid->qid.path) == Pinfo)
485 dirgeninfo(pindex(r->fid->qid.path), &r->d);
486 else if(ptype(r->fid->qid.path) == Pshare)
487 V2D(&r->d, r->fid->qid, a->path +1);
489 memset(&fi, 0, sizeof fi);
490 if(Sess->caps & CAP_NT_SMBS)
491 rc = T2queryall(Sess, a->sp, mapfile(a->path), &fi);
493 rc = T2querystandard(Sess, a->sp, mapfile(a->path), &fi);
498 I2D(&r->d, a->sp, a->path, &fi);
500 upd_names(Sess, a->sp, mapfile(a->path), &r->d);
506 smbcreateopen(Aux *a, char *path, int mode, int perm, int is_create,
507 int is_dir, FInfo *fip)
509 int rc, action, attrs, access, result;
511 if(is_create && is_dir){
512 if(CIFScreatedirectory(Sess, a->sp, path) == -1)
517 if(mode & DMAPPEND) {
518 werrstr("filesystem does not support DMAPPEND");
524 else if(mode & OTRUNC)
532 attrs = ATTR_NORMAL|ATTR_READONLY;
534 switch (mode & OMASK){
548 werrstr("%d bad open mode", mode & OMASK);
553 if(mode & DMEXCL == 0)
558 if((a->fh = CIFS_SMB_opencreate(Sess, a->sp, path, access, attrs,
559 action, &result)) == -1)
562 if(Sess->caps & CAP_NT_SMBS)
563 rc = T2queryall(Sess, a->sp, mapfile(a->path), fip);
565 rc = T2querystandard(Sess, a->sp, mapfile(a->path), fip);
567 fprint(2, "internal error: stat of newly open/created file failed\n");
571 if((mode & OEXCL) && (result & 0x8000) == 0){
572 werrstr("%d bad open mode", mode & OMASK);
578 /* Uncle Bill, you have a lot to answer for... */
580 ntcreateopen(Aux *a, char *path, int mode, int perm, int is_create,
581 int is_dir, FInfo *fip)
583 int options, result, attrs, flags, access, action, share;
586 werrstr("CIFSopen, DMAPPEND not supported");
593 else if(mode & OTRUNC)
594 action = FILE_CREATE;
596 action = FILE_OVERWRITE_IF;
599 action = FILE_OVERWRITE_IF;
601 action = FILE_OPEN_IF;
604 flags = 0; /* FIXME: really not sure */
607 share = FILE_NO_SHARE;
609 share = FILE_SHARE_ALL;
611 switch (mode & OMASK){
613 access = GENERIC_READ;
616 access = GENERIC_WRITE;
619 access = GENERIC_ALL;
622 access = GENERIC_EXECUTE;
625 werrstr("%d bad open mode", mode & OMASK);
631 action = FILE_CREATE;
632 options = FILE_DIRECTORY_FILE;
634 attrs = ATTR_DIRECTORY;
636 attrs = ATTR_DIRECTORY|ATTR_READONLY;
638 options = FILE_NON_DIRECTORY_FILE;
642 attrs = ATTR_NORMAL|ATTR_READONLY;
646 options |= FILE_DELETE_ON_CLOSE;
647 attrs |= ATTR_DELETE_ON_CLOSE;
650 if((a->fh = CIFS_NT_opencreate(Sess, a->sp, path, flags, options,
651 attrs, access, share, action, &result, fip)) == -1)
654 if((mode & OEXCL) && (result & 0x8000) == 0){
655 werrstr("%d bad open mode", mode & OMASK);
668 Aux *a = r->fid->aux;
671 a->cache = emalloc9p(max(Sess->mtu, MTU));
673 is_dir = (r->ifcall.perm & DMDIR) == DMDIR;
674 npath = smprint("%s/%s", a->path, r->ifcall.name);
676 if(Sess->caps & CAP_NT_SMBS)
677 rc = ntcreateopen(a, mapfile(npath), r->ifcall.mode,
678 r->ifcall.perm, 1, is_dir, &fi);
680 rc = smbcreateopen(a, mapfile(npath), r->ifcall.mode,
681 r->ifcall.perm, 1, is_dir, &fi);
688 r->fid->qid = mkqid(npath, fi.attribs & ATTR_DIRECTORY, fi.changed, 0, 0);
690 r->ofcall.qid = r->fid->qid;
702 Aux *a = r->fid->aux;
705 a->cache = emalloc9p(max(Sess->mtu, MTU));
707 if(ptype(r->fid->qid.path) == Pinfo){
708 if(makeinfo(pindex(r->fid->qid.path)) != -1)
711 respond(r, "cannot generate info");
715 if(r->fid->qid.type & QTDIR){
720 if(Sess->caps & CAP_NT_SMBS)
721 rc = ntcreateopen(a, mapfile(a->path), r->ifcall.mode, 0777,
724 rc = smbcreateopen(a, mapfile(a->path), r->ifcall.mode, 0777,
737 Aux *a = r->fid->aux;
738 vlong len = r->ifcall.count;
739 vlong off = r->ifcall.offset;
740 char *buf = r->ifcall.data;
743 n = Sess->mtu -OVERHEAD;
747 m = CIFSwrite(Sess, a->sp, a->fh, off + got, buf + got, n);
750 } while(got < len && m >= n);
752 r->ofcall.count = got;
763 Aux *a = r->fid->aux;
764 char *buf = r->ofcall.data;
765 vlong len = r->ifcall.count;
766 vlong off = r->ifcall.offset;
768 if(ptype(r->fid->qid.path) == Pinfo){
769 r->ofcall.count = readinfo(pindex(r->fid->qid.path), buf, len,
775 if(r->fid->qid.type & QTDIR){
776 dirread9p(r, dirgen, a);
782 n = Sess->mtu -OVERHEAD;
786 m = CIFSread(Sess, a->sp, a->fh, off + got, buf + got, n, len);
789 } while(got < len && m >= n);
791 r->ofcall.count = got;
803 if(ptype(f->qid.path) == Pinfo)
804 freeinfo(pindex(f->qid.path));
809 if(CIFSclose(Sess, a->sp, a->fh) == -1)
810 fprint(2, "%s: close failed fh=%d %r\n", argv0, a->fh);
812 if(CIFSfindclose2(Sess, a->sp, a->sh) == -1)
813 fprint(2, "%s: findclose failed sh=%d %r\n",
822 a->prev->next = a->next;
823 a->next->prev = a->prev;
824 if(a->next == a->prev)
831 rdonly(Session *s, Share *sp, char *path, int rdonly)
836 if(Sess->caps & CAP_NT_SMBS)
837 rc = T2queryall(s, sp, path, &fi);
839 rc = T2querystandard(s, sp, path, &fi);
843 if((rdonly && !(fi.attribs & ATTR_READONLY)) ||
844 (!rdonly && (fi.attribs & ATTR_READONLY))){
845 fi.attribs &= ~ATTR_READONLY;
846 fi.attribs |= rdonly? ATTR_READONLY: 0;
847 rc = CIFSsetinfo(s, sp, path, &fi);
857 Aux *ap, *a = r->fid->aux;
860 if(ptype(r->fid->qid.path) == Proot ||
861 ptype(r->fid->qid.path) == Pshare){
862 respond(r, "illegal operation");
866 /* close all instences of this file/dir */
867 if((ap = Auxroot) != nil)
869 if(strcmp(ap->path, a->path) == 0){
871 CIFSfindclose2(Sess, ap->sp, ap->sh);
874 CIFSclose(Sess, ap->sp, ap->fh);
878 }while(ap != Auxroot);
881 if(r->fid->qid.type & QTDIR)
882 rc = CIFSdeletedirectory(Sess, a->sp, mapfile(a->path));
884 rc = CIFSdeletefile(Sess, a->sp, mapfile(a->path));
886 rerrstr(e, sizeof(e));
887 if(rc == -1 && try++ == 0 && strcmp(e, "permission denied") == 0 &&
888 rdonly(Sess, a->sp, mapfile(a->path), 0) == 0)
901 char *p, *from, *npath;
902 Aux *a = r->fid->aux;
904 if(ptype(r->fid->qid.path) == Proot ||
905 ptype(r->fid->qid.path) == Pshare){
906 respond(r, "illegal operation");
910 if((r->d.uid && r->d.uid[0]) || (r->d.gid && r->d.gid[0])){
911 respond(r, "cannot change ownership");
918 if(Sess->caps & CAP_NT_SMBS)
919 rc = T2queryall(Sess, a->sp, mapfile(a->path), &fi);
921 rc = T2querystandard(Sess, a->sp, mapfile(a->path), &fi);
923 werrstr("(query) - %r");
929 * always clear the readonly attribute if set,
930 * before trying to set any other fields.
931 * wstat() fails if the file/dir is readonly
932 * and this function is so full of races - who cares about one more?
934 rdonly(Sess, a->sp, mapfile(a->path), 0);
937 * rename - one piece of joy, renaming open files
938 * is legal (sharing permitting).
940 if(r->d.name && r->d.name[0]){
941 if((p = strrchr(a->path, '/')) == nil){
942 respond(r, "illegal path");
945 npath = emalloc9p((p-a->path)+strlen(r->d.name)+2);
946 strecpy(npath, npath+(p- a->path)+2, a->path);
947 strcat(npath, r->d.name);
949 from = estrdup9p(mapfile(a->path));
950 if(CIFSrename(Sess, a->sp, from, mapfile(npath)) == -1){
951 werrstr("(rename) - %r");
963 * set the files length, do this before setting
964 * the file times as open() will alter them
967 fi.size = r->d.length;
969 if(Sess->caps & CAP_NT_SMBS){
970 if((fh = CIFS_NT_opencreate(Sess, a->sp, mapfile(a->path),
971 0, FILE_NON_DIRECTORY_FILE,
972 ATTR_NORMAL, GENERIC_WRITE, FILE_SHARE_ALL,
973 FILE_OPEN_IF, &result, &tmpfi)) == -1){
974 werrstr("(set length, open) - %r");
978 rc = T2setfilelength(Sess, a->sp, fh, &fi);
979 CIFSclose(Sess, a->sp, fh);
981 werrstr("(set length), set) - %r");
986 if((fh = CIFS_SMB_opencreate(Sess, a->sp, mapfile(a->path),
987 1, ATTR_NORMAL, 1, &result)) == -1){
988 werrstr("(set length, open) failed - %r");
992 rc = CIFSwrite(Sess, a->sp, fh, fi.size, 0, 0);
993 CIFSclose(Sess, a->sp, fh);
995 werrstr("(set length, write) - %r");
1003 * This doesn't appear to set length or
1004 * attributes, no idea why, so I do those seperately
1006 if(~r->d.mtime || ~r->d.atime){
1008 fi.written = r->d.mtime;
1010 fi.accessed = r->d.atime;
1011 if(T2setpathinfo(Sess, a->sp, mapfile(a->path), &fi) == -1){
1012 werrstr("(set path info) - %r");
1019 * always update the readonly flag as
1020 * we may have cleared it above.
1023 if(r->d.mode & 0222)
1024 fi.attribs &= ~ATTR_READONLY;
1026 fi.attribs |= ATTR_READONLY;
1028 if(rdonly(Sess, a->sp, mapfile(a->path), fi.attribs & ATTR_READONLY) == -1){
1029 werrstr("(set info) - %r");
1035 * Win95 has a broken write-behind cache for metadata
1036 * on open files (writes go to the cache, reads bypass
1037 * the cache), so we must flush the file.
1039 if(r->fid->omode != -1 && CIFSflush(Sess, a->sp, a->fh) == -1){
1040 werrstr("(flush) %r");
1053 for(i = 0; i < Nshares; i++)
1054 CIFStreedisconnect(Sess, Shares+i);
1056 postnote(PNPROC, Keeppid, "die");
1060 .destroyfid = fsdestroyfid,
1077 fprint(2, "usage: %s [-d name] [-Dvb] [-a auth-method] [-s srvname] "
1078 "[-n called-name] [-k factotum-params] [-m mntpnt] "
1079 "host [share...]\n", argv0);
1084 * SMBecho looks like the function to use for keepalives,
1085 * sadly the echo packet does not seem to reload the
1086 * idle timer in Microsoft's servers. Instead we use
1087 * "get file system size" on each share until we get one that succeeds.
1094 int fd, i, slot, rc;
1096 snprint(buf, sizeof buf, "#p/%d/args", getpid());
1097 if((fd = open(buf, OWRITE)) >= 0){
1098 fprint(fd, "%s keepalive", Host);
1109 for(i = 0; i < Nshares; i++){
1110 if((rc = T2fssizeinfo(Sess, &Shares[slot], &tot, &fre)) == 0)
1112 if(++slot >= Nshares)
1116 postnote(PNPROC, Attachpid, "die");
1121 ding(void *u, char *msg)
1124 if(strstr(msg, "alarm") != nil)
1130 dmpkey(char *s, void *v, int n)
1133 unsigned char *p = (unsigned char *)v;
1136 for(i = 0; i < n; i++)
1137 print("%02ux ", *p++);
1142 main(int argc, char **argv)
1146 char windom[64], cname[64];
1147 char *method, *sysname, *keyp, *mtpt, *svs;
1148 static char *sh[1024];
1153 strcpy(windom, "unknown");
1160 method = EARGF(autherr());
1169 Debug = EARGF(usage());
1175 keyp = EARGF(usage());
1178 mtpt = EARGF(usage());
1181 strncpy(cname, EARGF(usage()), sizeof(cname));
1182 cname[sizeof(cname) - 1] = 0;
1185 svs = EARGF(usage());
1188 Dfstout = atoi(EARGF(usage()));
1200 if(mtpt == nil && svs == nil)
1201 mtpt = smprint("/n/%s", Host);
1203 if((sysname = getenv("sysname")) == nil)
1204 sysname = "unknown";
1206 if(*cname && (Sess = cifsdial(Host, cname, sysname)) != nil)
1209 if(calledname(Host, cname) == 0 &&
1210 (Sess = cifsdial(Host, cname, sysname)) != nil)
1213 strcpy(cname, Host);
1214 if((Sess = cifsdial(Host, Host, sysname)) != nil ||
1215 (Sess = cifsdial(Host, "*SMBSERVER", sysname)) != nil)
1218 sysfatal("%s - cannot dial, %r\n", Host);
1220 if(CIFSnegotiate(Sess, &svrtime, windom, sizeof windom, cname, sizeof cname) == -1)
1221 sysfatal("%s - cannot negioate common protocol, %r\n", Host);
1224 Sess->secmode &= ~SECMODE_SIGN_ENABLED;
1227 Sess->auth = getauth(method, windom, keyp, Sess->secmode, Sess->chal,
1230 if(CIFSsession(Sess) < 0)
1231 sysfatal("session authentication failed, %r\n");
1233 Sess->slip = svrtime - time(nil);
1234 Sess->cname = estrdup9p(cname);
1236 if(CIFStreeconnect(Sess, cname, Ipcname, &Ipc) == -1)
1237 fprint(2, "%s, %r - can't connect\n", Ipcname);
1243 if((n = RAPshareenum(Sess, &Ipc, &sip)) < 1)
1244 sysfatal("can't enumerate shares: %r - specify share "
1245 "names on command line\n");
1247 for(i = 0; i < n; i++){
1248 #ifdef NO_HIDDEN_SHARES
1249 int l = strlen(sip[i].name);
1251 if(l > 1 && sip[i].name[l-1] == '$'){
1256 memcpy(Shares+Nshares, sip+i, sizeof(Share));
1257 if(CIFStreeconnect(Sess, Sess->cname,
1258 Shares[Nshares].name, Shares+Nshares) == -1){
1259 fprint(2, "%s: %s %q - can't connect to share"
1260 ", %r\n", argv0, Host, Shares[Nshares].name);
1261 free(Shares[Nshares].name);
1268 for(i = 1; i < argc; i++){
1269 if(CIFStreeconnect(Sess, Sess->cname, argv[i],
1270 Shares+Nshares) == -1){
1271 fprint(2, "%s: %s %q - can't connect to share"
1272 ", %r\n", argv0, Host, argv[i]);
1275 Shares[Nshares].name = strlwr(estrdup9p(argv[i]));
1280 fprint(2, "no available shares\n");
1282 if((Keeppid = rfork(RFPROC|RFMEM|RFNOTEG|RFFDG|RFNAMEG)) == 0){
1286 postmountsrv(&fs, svs, mtpt, MREPL|MCREATE);