summaryrefslogtreecommitdiff
path: root/usr/src/lib/libsmbfs/smb/file.c
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2019-03-15 13:22:00 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2019-03-15 13:22:00 +0000
commita062971fb96ae7154d88ab408f899f56aaf6df6b (patch)
tree9907dea0824c38373ef2913fd84385ed07a56c3a /usr/src/lib/libsmbfs/smb/file.c
parent0b570b3cb1c0bf505f1b1bd352664d638b8cc359 (diff)
parentb4a8b33babbf9a7a5de61ea06d09e1eb537f1f6e (diff)
downloadillumos-joyent-a062971fb96ae7154d88ab408f899f56aaf6df6b.tar.gz
[illumos-gate merge]
commit b4a8b33babbf9a7a5de61ea06d09e1eb537f1f6e 10483 aac: cast between incompatible function types commit a00b240dc61ea7ab64e3881b755fca973a531e89 10146 core_pcbe_event_coverage() is missing an else commit 542a7b7f5ccc44e3c95d6dce4ec0566f60bd9ff4 7780 mdb could extract NT_PRPSINFO information from core files commit 2f7dba3e6747cbaaf1deb86e6ca1e2a5c96332ac 10524 wsdiff much slower after move from deprecated commands module 10448 wsdiff explodes on encoding error 10525 wsdiff output is not correct for a binary file 10526 wsdiff tries to spawn 4.8 threads commit adee678425979226b2b55d1a0b39ce4c989382e9 9735 Need to provide SMB 2.1 Client commit 40c0e2317898b8c774791bdc2b30bd50111ab1fa 9875 SMB client connection setup rework commit 8329232e00f1048795bae53acb230316243aadb5 9874 Add fksmbcl development tool Conflicts: usr/src/cmd/mdb/common/modules/libc/libc.c
Diffstat (limited to 'usr/src/lib/libsmbfs/smb/file.c')
-rw-r--r--usr/src/lib/libsmbfs/smb/file.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/usr/src/lib/libsmbfs/smb/file.c b/usr/src/lib/libsmbfs/smb/file.c
index 8ca9d2cee1..3d2a431142 100644
--- a/usr/src/lib/libsmbfs/smb/file.c
+++ b/usr/src/lib/libsmbfs/smb/file.c
@@ -33,9 +33,10 @@
*/
/*
- * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright 2018 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/param.h>
@@ -62,10 +63,16 @@
#include "private.h"
+/*
+ * It's not actually necessary to call the CLOSEFH ioctl, but doing it
+ * makes debugging a little easier. If we were to skip the ioctl,
+ * nsmb_close would cleanup the handle, here or in process exit.
+ */
int
smb_fh_close(int fd)
{
- return (close(fd));
+ (void) nsmb_ioctl(fd, SMBIOC_CLOSEFH, NULL);
+ return (nsmb_close(fd));
}
int
@@ -96,7 +103,7 @@ smb_fh_ntcreate(
goto errout;
}
from_fd = ctx->ct_dev_fd;
- if (ioctl(new_fd, SMBIOC_DUP_DEV, &from_fd) == -1) {
+ if (nsmb_ioctl(new_fd, SMBIOC_DUP_DEV, &from_fd) == -1) {
err = errno;
goto errout;
}
@@ -111,7 +118,7 @@ smb_fh_ntcreate(
ioc.ioc_share_acc = share_acc;
ioc.ioc_open_disp = open_disp;
ioc.ioc_creat_opts = create_opts;
- if (ioctl(new_fd, SMBIOC_NTCREATE, &ioc) == -1) {
+ if (nsmb_ioctl(new_fd, SMBIOC_NTCREATE, &ioc) == -1) {
err = errno;
goto errout;
}
@@ -120,7 +127,7 @@ smb_fh_ntcreate(
errout:
if (new_fd != -1)
- close(new_fd);
+ nsmb_close(new_fd);
errno = err;
return (-1);
}
@@ -210,11 +217,10 @@ smb_fh_read(int fd, off64_t offset, size_t count,
struct smbioc_rw rwrq;
bzero(&rwrq, sizeof (rwrq));
- rwrq.ioc_fh = -1; /* tell driver to supply this */
rwrq.ioc_base = dst;
rwrq.ioc_cnt = count;
rwrq.ioc_offset = offset;
- if (ioctl(fd, SMBIOC_READ, &rwrq) == -1) {
+ if (nsmb_ioctl(fd, SMBIOC_READ, &rwrq) == -1) {
return (-1);
}
return (rwrq.ioc_cnt);
@@ -227,11 +233,10 @@ smb_fh_write(int fd, off64_t offset, size_t count,
struct smbioc_rw rwrq;
bzero(&rwrq, sizeof (rwrq));
- rwrq.ioc_fh = -1; /* tell driver to supply this */
rwrq.ioc_base = (char *)src;
rwrq.ioc_cnt = count;
rwrq.ioc_offset = offset;
- if (ioctl(fd, SMBIOC_WRITE, &rwrq) == -1) {
+ if (nsmb_ioctl(fd, SMBIOC_WRITE, &rwrq) == -1) {
return (-1);
}
return (rwrq.ioc_cnt);
@@ -251,21 +256,23 @@ smb_fh_xactnp(int fd,
int *rdlen, char *rdata, /* receive */
int *more)
{
- int err, rparamcnt;
- uint16_t setup[2];
-
- setup[0] = TRANS_TRANSACT_NAMED_PIPE;
- setup[1] = 0xFFFF; /* driver replaces this */
- rparamcnt = 0;
+ smbioc_xnp_t ioc;
- err = smb_t2_request(fd, 2, setup, "\\PIPE\\",
- 0, NULL, /* TX paramcnt, params */
- tdlen, (void *)tdata,
- &rparamcnt, NULL, /* no RX params */
- rdlen, rdata, more);
+ /* this gets copyin & copyout */
+ bzero(&ioc, sizeof (ioc));
+ ioc.ioc_tdlen = tdlen;
+ ioc.ioc_rdlen = *rdlen;
+ ioc.ioc_more = 0;
+ ioc.ioc_tdata = (char *)tdata;
+ ioc.ioc_rdata = rdata;
- if (err)
+ if (nsmb_ioctl(fd, SMBIOC_XACTNP, &ioc) == -1) {
*rdlen = 0;
+ return (-1);
+ }
+
+ *rdlen = ioc.ioc_rdlen;
+ *more = ioc.ioc_more;
- return (err);
+ return (0);
}