smbfile.c 850 B

12345678910111213141516171819202122232425262728293031323334
  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. static void
  11. smbfilefree(SmbFile **fp)
  12. {
  13. SmbFile *f;
  14. f = *fp;
  15. if (f) {
  16. smbsharedfileput(f, f->sf, f->share);
  17. if (f->fd >= 0)
  18. close(f->fd);
  19. free(f->name);
  20. free(f);
  21. *fp = nil;
  22. }
  23. }
  24. void
  25. smbfileclose(SmbSession *s, SmbFile *f)
  26. {
  27. smblogprintif(smbglobals.log.fids, "smbfileclose: 0x%.4ux/0x%.4ux %s%s\n",
  28. f->t->id, f->id, f->t->serv->path, f->name);
  29. smbidmapremove(s->fidmap, f);
  30. smbfilefree(&f);
  31. }