Sponsored Content
Top Forums Programming which function copies data from user to kernel mode Post 302431705 by fpmurphy on Tuesday 22nd of June 2010 03:58:07 PM
Old 06-22-2010
On Solaris 10:
Code:
#define COPY_FROM_USER(target, source, offs, count) \
        if (uiomove((target), count, UIO_WRITE, source)) { \
                cmn_err(CE_WARN, "Bad copyin()!\n"); \
        }

#define COPY_TO_USER(target, offs, source, count) \
        if (uiomove((source), count, UIO_READ, target)) { \
                cmn_err(CE_WARN, "Bad copyout()!\n"); \
        }

 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

k_trap - kernel mode trap type 0x0000000E

HELP is urgently required, I run on SCO Unix 3 and this is the panic message that I get every time that I reboot 10U k_trap - kernel mode trap type 0x0000000E I have checked the swap already having the following results: #swap -l path dev swaplo blocks free... (3 Replies)
Discussion started by: alex_slb
3 Replies

2. SCO

unexpected trap in kernel mode

hi, I am trying to install sco openserver 5.0.4 on an old system. However, l was not able to proceed after putting the bootstr l have this panic message of PANIC: K_trap - kernel mode trap tupe 0x00000006 will someone kindly help to decode this error kayode (1 Reply)
Discussion started by: kayode
1 Replies

3. Programming

Aplication user and kernel mode (data access)

Hi all, I am trying to setup a program to use a device driver and am confusing buffer access between User and Kernel mode. I think all applications running in User space have to communicate with the device drivers using io control calls and then have some functions called back from the driver... (1 Reply)
Discussion started by: Brendan Kennedy
1 Replies

4. UNIX for Dummies Questions & Answers

Kernel Mode

Hi all i have queastion. Can anybody pease help me what is user mode and kernel mode and the term "De-mountable volumes" means? Thanks Palash (2 Replies)
Discussion started by: palash2k
2 Replies

5. Shell Programming and Scripting

MODE function in awk

Hello, Can someone pls help me with some statistical calculation in awk In excel there is a statistical function called "Mode". How Mode works: MODE returns the most frequently occurring, or repetitive, value in array or range. Eg if we have 5 numbers in 5 different columns... (12 Replies)
Discussion started by: Needhelp2
12 Replies

6. SCO

PANIC: k_trap - Kernel mode trap type 0x0000000E

Hi, i'm another question: I'm a directory /usr/data on my server sco unix 5.0.5: # du /usr/data 4386948 /usr/data I'm tried to connect to ftp directory /usr/data to this server and: PANIC: k_trap - Kernel mode trap type 0x0000000E Cannot dump 262040 pages to dumpdev hd(1/41):space... (3 Replies)
Discussion started by: sebpes
3 Replies

7. Programming

Execute code in kernel mode.

Hi everyone. I would like to hook a system function (gettimeofday) to modify it. I guess I'll need kernel mode to do that. By the way, how could I do it (c++ or c)? I want to modify that function for one process which I know the PID. So I need to return my own value for that PID and real value... (29 Replies)
Discussion started by: lilezek
29 Replies

8. Programming

HELP!!: CPU resource allocation between kernel modules and user mode process

Hi,all: I run my program which consists of one kernel module and one user mode process on a dual core server. The problem here is the kernel module consumes 100% of one core while the user mode process only consumes 10% of the other core, is there any solution that I can assign some computing... (1 Reply)
Discussion started by: neyshule
1 Replies

9. UNIX for Dummies Questions & Answers

Kernel Stack vs User Mode Stack

Hi, I am new to the linux kernel development area. I want to know what is the difference between kernel mode stack and user mode stack? Does each process has a user mode stack and a kernel mode stack?? Or Each process has a user mode stack and there is only one kernel mode stack that is shared by... (4 Replies)
Discussion started by: saurabhkoar
4 Replies

10. UNIX for Advanced & Expert Users

Precaution to access user mode buffers from kernel

When accessing a user mode buffers from kernel space drivers what precautions must we take and how those precautions need to be implemented? (0 Replies)
Discussion started by: rupeshkp728
0 Replies
UIO(9)							   BSD Kernel Developer's Manual						    UIO(9)

NAME
uio, uiomove, uiomove_nofault -- device driver I/O routines SYNOPSIS
#include <sys/types.h> #include <sys/uio.h> struct uio { struct iovec *uio_iov; /* scatter/gather list */ int uio_iovcnt; /* length of scatter/gather list */ off_t uio_offset; /* offset in target object */ ssize_t uio_resid; /* remaining bytes to copy */ enum uio_seg uio_segflg; /* address space */ enum uio_rw uio_rw; /* operation */ struct thread *uio_td; /* owner */ }; int uiomove(void *buf, int howmuch, struct uio *uiop); int uiomove_nofault(void *buf, int howmuch, struct uio *uiop); DESCRIPTION
The functions uiomove() and uiomove_nofault() are used to transfer data between buffers and I/O vectors that might possibly cross the user/kernel space boundary. As a result of any read(2), write(2), readv(2), or writev(2) system call that is being passed to a character-device driver, the appropriate driver d_read or d_write entry will be called with a pointer to a struct uio being passed. The transfer request is encoded in this struc- ture. The driver itself should use uiomove() or uiomove_nofault() to get at the data in this structure. The fields in the uio structure are: uio_iov The array of I/O vectors to be processed. In the case of scatter/gather I/O, this will be more than one vector. uio_iovcnt The number of I/O vectors present. uio_offset The offset into the device. uio_resid The remaining number of bytes to process, updated after transfer. uio_segflg One of the following flags: UIO_USERSPACE The I/O vector points into a process's address space. UIO_SYSSPACE The I/O vector points into the kernel address space. UIO_NOCOPY Do not copy, already in object. uio_rw The direction of the desired transfer, either UIO_READ or UIO_WRITE. uio_td The pointer to a struct thread for the associated thread; used if uio_segflg indicates that the transfer is to be made from/to a process's address space. The function uiomove_nofault() requires that the buffer and I/O vectors be accessible without incurring a page fault. The source and desti- nation addresses must be physically mapped for read and write access, respectively, and neither the source nor destination addresses may be pageable. Thus, the function uiomove_nofault() can be called from contexts where acquiring virtual memory system locks or sleeping are pro- hibited. RETURN VALUES
On success uiomove() and uiomove_nofault() will return 0; on error they will return an appropriate error code. EXAMPLES
The idea is that the driver maintains a private buffer for its data, and processes the request in chunks of maximal the size of this buffer. Note that the buffer handling below is very simplified and will not work (the buffer pointer is not being advanced in case of a partial read), it is just here to demonstrate the uio handling. /* MIN() can be found there: */ #include <sys/param.h> #define BUFSIZE 512 static char buffer[BUFSIZE]; static int data_available; /* amount of data that can be read */ static int fooread(struct cdev *dev, struct uio *uio, int flag) { int rv, amnt; rv = 0; while (uio->uio_resid > 0) { if (data_available > 0) { amnt = MIN(uio->uio_resid, data_available); rv = uiomove(buffer, amnt, uio); if (rv != 0) break; data_available -= amnt; } else tsleep(...); /* wait for a better time */ } if (rv != 0) { /* do error cleanup here */ } return (rv); } ERRORS
uiomove() and uiomove_nofault() will fail and return the following error code if: [EFAULT] The invoked copyin(9) or copyout(9) returned EFAULT In addition, uiomove_nofault() will fail and return the following error code if: [EFAULT] A page fault occurs. SEE ALSO
read(2), readv(2), write(2), writev(2), copyin(9), copyout(9), sleep(9) HISTORY
The uio mechanism appeared in some early version of UNIX. AUTHORS
This manual page was written by Jorg Wunsch. BSD
January 19, 2012 BSD
All times are GMT -4. The time now is 04:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy