From 926240428c0646aabb13539745940b61a7cf44a9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 4 Dec 2003 02:03:06 +0000 Subject: * patch based on work by Jim Myers to unify the ioctl handling to be more like the other major SMB functions * added SMBntrename code (This used to be commit f2d3dc9893fa0e089c407fa16ce9ff13587e70cd) --- source4/smbd/process.c | 2 +- source4/smbd/reply.c | 52 ++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 9 deletions(-) (limited to 'source4/smbd') diff --git a/source4/smbd/process.c b/source4/smbd/process.c index cf357ef547..81c658af06 100644 --- a/source4/smbd/process.c +++ b/source4/smbd/process.c @@ -320,7 +320,7 @@ static const struct smb_message_struct /* 0xa2 */ { "SMBntcreateX", reply_ntcreate_and_X, AS_USER | CAN_IPC }, /* 0xa3 */ { NULL, NULL, 0 }, /* 0xa4 */ { "SMBntcancel", reply_ntcancel, 0 }, -/* 0xa5 */ { NULL, NULL, 0 }, +/* 0xa5 */ { "SMBntrename", reply_ntrename, 0 }, /* 0xa6 */ { NULL, NULL, 0 }, /* 0xa7 */ { NULL, NULL, 0 }, /* 0xa8 */ { NULL, NULL, 0 }, diff --git a/source4/smbd/reply.c b/source4/smbd/reply.c index f4dd4cb50a..3d237d964d 100644 --- a/source4/smbd/reply.c +++ b/source4/smbd/reply.c @@ -2,6 +2,7 @@ Unix SMB/CIFS implementation. Main SMB reply routines Copyright (C) Andrew Tridgell 1992-2003 + Copyright (C) James J Myers 2003 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -226,17 +227,17 @@ void reply_unknown(struct request_context *req) ****************************************************************************/ static void reply_ioctl_send(struct request_context *req) { - struct smb_ioctl *io = req->async.private; + union smb_ioctl *io = req->async.private; CHECK_ASYNC_STATUS; /* the +1 is for nicer alignment */ - req_setup_reply(req, 8, io->out.blob.length+1); - SSVAL(req->out.vwv, VWV(1), io->out.blob.length); - SSVAL(req->out.vwv, VWV(5), io->out.blob.length); + req_setup_reply(req, 8, io->ioctl.out.blob.length+1); + SSVAL(req->out.vwv, VWV(1), io->ioctl.out.blob.length); + SSVAL(req->out.vwv, VWV(5), io->ioctl.out.blob.length); SSVAL(req->out.vwv, VWV(6), PTR_DIFF(req->out.data, req->out.hdr) + 1); - memcpy(req->out.data+1, io->out.blob.data, io->out.blob.length); + memcpy(req->out.data+1, io->ioctl.out.blob.data, io->ioctl.out.blob.length); req_send_reply(req); } @@ -246,14 +247,15 @@ static void reply_ioctl_send(struct request_context *req) ****************************************************************************/ void reply_ioctl(struct request_context *req) { - struct smb_ioctl *io; + union smb_ioctl *io; /* parse requst */ REQ_CHECK_WCT(req, 3); REQ_TALLOC(io, sizeof(*io)); - io->in.fnum = req_fnum(req, req->in.vwv, VWV(0)); - io->in.request = IVAL(req->in.vwv, VWV(1)); + io->ioctl.level = RAW_IOCTL_IOCTL; + io->ioctl.in.fnum = req_fnum(req, req->in.vwv, VWV(0)); + io->ioctl.in.request = IVAL(req->in.vwv, VWV(1)); req->async.send_fn = reply_ioctl_send; req->async.private = io; @@ -1628,6 +1630,40 @@ void reply_mv(struct request_context *req) } +/**************************************************************************** + Reply to an NT rename. +****************************************************************************/ +void reply_ntrename(struct request_context *req) +{ + union smb_rename *io; + char *p; + + /* parse the request */ + REQ_CHECK_WCT(req, 4); + REQ_TALLOC(io, sizeof(*io)); + + io->generic.level = RAW_RENAME_NTRENAME; + io->ntrename.in.attrib = SVAL(req->in.vwv, VWV(0)); + io->ntrename.in.flags = SVAL(req->in.vwv, VWV(1)); + io->ntrename.in.cluster_size = IVAL(req->in.vwv, VWV(2)); + + p = req->in.data; + p += req_pull_ascii4(req, &io->ntrename.in.old_name, p, STR_TERMINATE); + p += req_pull_ascii4(req, &io->ntrename.in.new_name, p, STR_TERMINATE); + + if (!io->ntrename.in.old_name || !io->ntrename.in.new_name) { + req_reply_error(req, NT_STATUS_FOOBAR); + return; + } + + req->async.send_fn = reply_simple_send; + + /* call backend */ + req->async.status = req->conn->ntvfs_ops->rename(req, io); + + REQ_ASYNC_TAIL; +} + /**************************************************************************** Reply to a file copy (async reply) ****************************************************************************/ -- cgit