smbcomcreatedir.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "headers.h"
  10. SmbProcessResult
  11. smbcomcreatedirectory(SmbSession *s, SmbHeader *h, uint8_t *l, SmbBuffer *b)
  12. {
  13. int fd;
  14. char *path;
  15. char *fullpath = nil;
  16. SmbTree *t;
  17. uint8_t fmt;
  18. if (h->wordcount != 0)
  19. return SmbProcessResultFormat;
  20. if (!smbbuffergetb(b, &fmt) || fmt != 0x04 || !smbbuffergetstring(b, h, SMB_STRING_PATH, &path))
  21. return SmbProcessResultFormat;
  22. smblogprint(h->command, "smbcomcreatedirectory: %s\n", path);
  23. t = smbidmapfind(s->tidmap, h->tid);
  24. if (t == nil) {
  25. smbseterror(s, ERRSRV, ERRinvtid);
  26. return SmbProcessResultError;
  27. }
  28. smbstringprint(&fullpath, "%s%s", t->serv->path, path);
  29. fd = create(fullpath, OREAD, DMDIR | 0775);
  30. if (fd < 0) {
  31. smblogprint(h->command, "smbcomcreatedirectory failed: %r\n");
  32. smbseterror(s, ERRDOS, ERRnoaccess);
  33. free(path);
  34. return SmbProcessResultError;
  35. }
  36. close(fd);
  37. free(fullpath);
  38. free(path);
  39. return smbbufferputack(s->response, h, &s->peerinfo);
  40. }