Operating System - HP-UX
1753776 Members
7542 Online
108799 Solutions
New Discussion юеВ

Re: how open a file in Kernel Space

 
kaijile
Frequent Advisor

how open a file in Kernel Space

Is there any interface for opening a file in a kernel module, such as aix's vn_open,vn_rdwr

how open a file in Kernel Space?
4 REPLIES 4
Jov
Honored Contributor

Re: how open a file in Kernel Space

Hi,

What are you trying to do?

Jov
kaijile
Frequent Advisor

Re: how open a file in Kernel Space

I want to write log in my dlkm.
kaijile
Frequent Advisor

Re: how open a file in Kernel Space

In /usr/include/sys/vnode.h

has the function vn_open, but there is no man page for it.

extern int vn_open __((char *, int, int, int, int, struct vnode **));


what are four int type parameters?
Laurent Menase
Honored Contributor

Re: how open a file in Kernel Space

In /usr/include/sys/vnode.h

has the function vn_open, but there is no man page for it.

extern int vn_open __((char *, int, int, int, int, struct vnode **));


what are four int type parameters?
(char *pnamep, int seg, int filemode, int createmode, int plainmode, stru
ct vnode **vpp)

just a remark, you can also open it at user level, and use it from kernel.

filemode being FREAD|FWRITE|....FCREAT...
plainmode and createmode are used only when FCREAT is used

vn_rdwr(enum uio_rw rw, struct vnode *vp, char *base, size_t len, k_off_t offset, int seg, int ioflag, long *aresid, int fpflags)


but basically is it often more confortable and less problematic to have a user level daemon which read() from your device the messages to log and log them from user level;
The risk is much less than making that sort of thing from the kernel, due to the fact for instance that kernel is not preemtable,

for instance nettl is doing this that way.
ntl_reader running at rt prio is logging the nettl traces and logs.
So my advice is use a user level daemon to log to a file. it will work more easily with no risk