smbcomclose.c 996 B

123456789101112131415161718192021222324252627282930313233
  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. smbcomclose(SmbSession *s, SmbHeader *h, uint8_t *pdata, SmbBuffer *sb)
  12. {
  13. SmbTree *t;
  14. SmbFile *f;
  15. uint16_t fid;
  16. if (!smbcheckwordcount("comclose", h, 3))
  17. return SmbProcessResultFormat;
  18. t = smbidmapfind(s->tidmap, h->tid);
  19. if (t == nil) {
  20. smbseterror(s, ERRSRV, ERRinvtid);
  21. return SmbProcessResultError;
  22. }
  23. fid = smbnhgets(pdata);
  24. f = smbidmapfind(s->fidmap, fid);
  25. if (f == nil) {
  26. smbseterror(s, ERRDOS, ERRbadfid);
  27. return SmbProcessResultError;
  28. }
  29. smbfileclose(s, f);
  30. return smbbufferputack(s->response, h, &s->peerinfo);
  31. }