Plan 9 from Bell Labs’s /usr/web/sources/patch/applied/aquarela-fixes/smbcomrename.c.orig

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include "headers.h"

SmbProcessResult
smbcomrename(SmbSession *s, SmbHeader *h, uchar *, SmbBuffer *b)
{
	int rv;
	char *oldpath, *newpath;
	char *olddir, *newdir;
	char *oldname, *newname;
	uchar oldfmt, newfmt;
	Dir d;
	SmbProcessResult pr;

	if (h->wordcount != 1)
		return SmbProcessResultFormat;
	if (!smbbuffergetb(b, &oldfmt) || oldfmt != 0x04 || !smbbuffergetstring(b, h, SMB_STRING_PATH, &oldpath)
		|| !smbbuffergetb(b, &newfmt) || newfmt != 0x04 || !smbbuffergetstring(b, h, SMB_STRING_PATH, &newpath))
		return SmbProcessResultFormat;
	smblogprint(h->command, "smbcomrename: %s to %s\n", oldpath, newpath);
	smbpathsplit(oldpath, &olddir, &oldname);
	smbpathsplit(newpath, &newdir, &newname);
	if (strcmp(olddir, newdir) != 0) {
		smblogprint(h->command, "smbcomrename: directories differ\n");
		goto noaccess;
	}
	memset(&d, 0xff, sizeof(d));
	d.uid = d.gid = d.muid = nil;
	d.name = newname;
	rv = dirwstat(oldpath, &d);
	if (rv < 0) {
		smblogprint(h->command, "smbcomrename failed: %r\n");
	noaccess:
		smbseterror(s, ERRDOS, ERRnoaccess);
		pr =  SmbProcessResultError;
	}
	else
		pr = smbbufferputack(s->response, h, &s->peerinfo);
	free(oldpath);
	free(olddir);
	free(oldname);
	free(newpath);
	free(newdir);
	free(newname);
	return pr;
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.