diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/aquarela/smbcomdir.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/aquarela/smbcomdir.c')
-rwxr-xr-x | sys/src/cmd/aquarela/smbcomdir.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/sys/src/cmd/aquarela/smbcomdir.c b/sys/src/cmd/aquarela/smbcomdir.c new file mode 100755 index 000000000..72bf827ad --- /dev/null +++ b/sys/src/cmd/aquarela/smbcomdir.c @@ -0,0 +1,49 @@ +#include "headers.h" + +SmbProcessResult +smbcomcheckdirectory(SmbSession *s, SmbHeader *h, uchar *, SmbBuffer *b) +{ + char *path; + Dir *d; + uchar fmt; + SmbProcessResult pr; + SmbTree *t; + char *fullpath = nil; + + if (!smbcheckwordcount("comcheckdirectory", h, 0)) + return SmbProcessResultFormat; + + if (!smbbuffergetb(b, &fmt) + || fmt != 4 + || !smbbuffergetstring(b, h, SMB_STRING_PATH, &path)) + return SmbProcessResultFormat; + + t = smbidmapfind(s->tidmap, h->tid); + if (t == nil) { + smbseterror(s, ERRSRV, ERRinvtid); + return SmbProcessResultError; + } + + smbstringprint(&fullpath, "%s%s", t->serv->path, path); +smblogprintif(1, "smbcomcheckdirectory: statting %s\n", fullpath); + d = dirstat(fullpath); + + if (d == nil || (d->mode & DMDIR) == 0) { + smbseterror(s, ERRDOS, ERRbadpath); + pr = SmbProcessResultError; + goto done; + } + + if (access(fullpath, AREAD) < 0) { + smbseterror(s, ERRDOS, ERRbadpath); + pr = SmbProcessResultError; + goto done; + } + + pr = smbbufferputack(s->response, h, &s->peerinfo) ? SmbProcessResultReply : SmbProcessResultMisc; +done: + free(fullpath); + free(path); + free(d); + return pr; +} |