1274955Ssvnmir/* 2274955Ssvnmir * Copyright (c) 2000, Boris Popov 3353358Sdim * All rights reserved. 4353358Sdim * 5353358Sdim * Redistribution and use in source and binary forms, with or without 6274955Ssvnmir * modification, are permitted provided that the following conditions 7274955Ssvnmir * are met: 8274955Ssvnmir * 1. Redistributions of source code must retain the above copyright 9274955Ssvnmir * notice, this list of conditions and the following disclaimer. 10274955Ssvnmir * 2. Redistributions in binary form must reproduce the above copyright 11274955Ssvnmir * notice, this list of conditions and the following disclaimer in the 12274955Ssvnmir * documentation and/or other materials provided with the distribution. 13274955Ssvnmir * 3. All advertising materials mentioning features or use of this software 14280031Sdim * must display the following acknowledgement: 15280031Sdim * This product includes software developed by Boris Popov. 16274955Ssvnmir * 4. Neither the name of the author nor the names of any co-contributors 17280031Sdim * may be used to endorse or promote products derived from this software 18274955Ssvnmir * without specific prior written permission. 19274955Ssvnmir * 20288943Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21288943Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22274955Ssvnmir * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23274955Ssvnmir * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 24274955Ssvnmir * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25296417Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26296417Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27296417Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28296417Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29296417Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30274955Ssvnmir * SUCH DAMAGE. 31274955Ssvnmir * 32274955Ssvnmir * $Id: file.c,v 1.2 2001/04/16 04:33:01 bp Exp $ 33274955Ssvnmir * $FreeBSD$ 34353358Sdim */ 35274955Ssvnmir#include <sys/param.h> 36274955Ssvnmir#include <sys/sysctl.h> 37296417Sdim#include <sys/ioctl.h> 38274955Ssvnmir#include <sys/time.h> 39274955Ssvnmir#include <sys/mount.h> 40274955Ssvnmir#include <fcntl.h> 41274955Ssvnmir#include <ctype.h> 42274955Ssvnmir#include <errno.h> 43274955Ssvnmir#include <stdio.h> 44288943Sdim#include <string.h> 45341825Sdim#include <stdlib.h> 46274955Ssvnmir#include <pwd.h> 47274955Ssvnmir#include <grp.h> 48288943Sdim#include <unistd.h> 49274955Ssvnmir 50274955Ssvnmir#include <netsmb/smb_lib.h> 51353358Sdim#include <netsmb/smb_conn.h> 52288943Sdim#include <cflib.h> 53274955Ssvnmir 54274955Ssvnmirint 55274955Ssvnmirsmb_read(struct smb_ctx *ctx, smbfh fh, off_t offset, size_t count, char *dst) 56274955Ssvnmir{ 57296417Sdim struct smbioc_rw rwrq; 58274955Ssvnmir 59274955Ssvnmir rwrq.ioc_fh = fh; 60274955Ssvnmir rwrq.ioc_base = dst; 61274955Ssvnmir rwrq.ioc_cnt = count; 62274955Ssvnmir rwrq.ioc_offset = offset; 63274955Ssvnmir if (ioctl(ctx->ct_fd, SMBIOC_READ, &rwrq) == -1) 64274955Ssvnmir return -1; 65274955Ssvnmir return rwrq.ioc_cnt; 66274955Ssvnmir} 67274955Ssvnmir 68353358Sdimint 69274955Ssvnmirsmb_write(struct smb_ctx *ctx, smbfh fh, off_t offset, size_t count, 70274955Ssvnmir const char *src) 71274955Ssvnmir{ 72288943Sdim struct smbioc_rw rwrq; 73296417Sdim 74288943Sdim rwrq.ioc_fh = fh; 75288943Sdim rwrq.ioc_base = (char *)src; 76360784Sdim rwrq.ioc_cnt = count; 77288943Sdim rwrq.ioc_offset = offset; 78360784Sdim if (ioctl(ctx->ct_fd, SMBIOC_WRITE, &rwrq) == -1) 79341825Sdim return -1; 80288943Sdim return rwrq.ioc_cnt; 81288943Sdim} 82360784Sdim