Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include "headers.h"
2
 
3
SmbProcessResult
4
smbcomcreatedirectory(SmbSession *s, SmbHeader *h, uchar *, SmbBuffer *b)
5
{
6
	int fd;
7
	char *path;
8
	char *fullpath = nil;
9
	SmbTree *t;
10
	uchar fmt;
11
 
12
	if (h->wordcount != 0)
13
		return SmbProcessResultFormat;
14
	if (!smbbuffergetb(b, &fmt) || fmt != 0x04 || !smbbuffergetstring(b, h, SMB_STRING_PATH, &path))
15
		return SmbProcessResultFormat;
16
	smblogprint(h->command, "smbcomcreatedirectory: %s\n", path);
17
	t = smbidmapfind(s->tidmap, h->tid);
18
	if (t == nil) {
19
		smbseterror(s, ERRSRV, ERRinvtid);
20
		return SmbProcessResultError;
21
	}
22
	smbstringprint(&fullpath, "%s%s", t->serv->path, path);
23
	fd = create(fullpath, OREAD, DMDIR | 0775);
24
	if (fd < 0) {
25
		smblogprint(h->command, "smbcomcreatedirectory failed: %r\n");
26
		smbseterror(s, ERRDOS, ERRnoaccess);
27
		free(path);
28
		return SmbProcessResultError;
29
	}
30
	close(fd);
31
	free(fullpath);
32
	free(path);
33
	return smbbufferputack(s->response, h, &s->peerinfo);
34
}