On Wed, Jan 21, 2009 at 6:03 PM, Edward <yanggongming at huawei.com> wrote: > Hi Martin, > yes I use fopen() otherwise it can't pass compile :-) . > the file are scha_api_rpc.c and scds_fm.c > in rgm_president.cc, we can use os:: functions. > yet scha_api_rpc.c is c file , and can't use os:: .
All of the above files belong to user land libraries. As Marty said, there is no reason that code should run in the kernel. Being a c-file does not prohibit linking to c++ objects. You only need to tell cc/ld you are calling a C++ function. http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B#Linking_C_and_C.2B.2B_code You said earlier Edward> I am trying to debug some code in the RGM,yet ,I don't know how to do it. Edward> so I want to use the log information to record some information. Edward> in some code of RGM,it seems run in the kernel, so i can't use FILE struction. You can use cmn_err() or printf() to log messages to system logs. Agreed it won't be a dedicated log. You could also allocate a buffer, log the data you need to it and later use mdb to read and dump the buffer. You can kobj_* functions to write to a file if you absolutely must. BTW, how did you conclude the code you are debugging is running in the kernel and not just making a syscall? Did you try dtrace to trace the entire path? Most important, can you be more specific on what problem you are trying to debug? cheers Binu > In os::, it use "struct _buf *fp;" > yet I down't know how to use this *fp. > > Thanks > Edward > > > > ----- Original Message ----- > From: Martin Rattner > To: Edward > Cc: ha-clusters-discuss at opensolaris.org > Sent: Thursday, January 22, 2009 9:39 AM > Subject: Re: [ha-clusters-discuss] Hi all, How to open a file in _kernel > state? > Edward, > > The rgmd is userland code. If you are actually modifying rgmd code, the > _KERNEL > macro will be undefined. Perhaps you could give more details of which > source > file you are modifying, and what error messages were produced by the > compiler. > > Did you #include <stdio.h> in the file where you attempted this? That is > necessary. Also, your example below calls "fileopen" which does not exist. > The > correct name of the function is "fopen". It is documented in the fopen(3C) > man > page. > > > On 01/21/09 16:49, Edward wrote: >> Hi Andrew and all, >> I am trying to debug some code in the RGM,yet ,I don't know how to do it. >> so I want to use the log information to record some information. >> in some code of RGM,it seems run in the kernel, so i can't use FILE >> struction. >> >> I just want to record some code infomation in the file to better >> understand the code. >> >> >> Thanks >> Edward >> >> ----- Original Message ----- >> *From:* Andrew Hisgen <mailto:Andrew.Hisgen at Sun.COM> >> *To:* yang <mailto:yanggongming at huawei.com> >> *Cc:* ha-clusters-discuss at opensolaris.org >> <mailto:ha-clusters-discuss at opensolaris.org> >> *Sent:* Wednesday, January 21, 2009 11:36 PM >> *Subject:* Re: [ha-clusters-discuss] Hi all, How to open a file in >> _kernel state? >> >> Hi Yang, >> >> Can you clarify what you are trying to do? >> Are you trying to open a file for writing from within >> the kernel? That is, is the code that you are writing >> intended to run in the kernel? >> >> thanks, >> Andy >> >> yang wrote: >> > Hi all, >> > when define _KERNEL, I use: >> > FILE * fp; >> > fp=fileopen("path","w"); >> > >> > >> > and the sun studio compile promp errors. >> > >> > So in C files , how can I open a fild and write something into it >> in _KERNEL stat? >> > >> > Thanks >> >> >> -- >> Email: Andrew.Hisgen at sun.com <mailto:Andrew.Hisgen at sun.com> >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> ha-clusters-discuss mailing list >> ha-clusters-discuss at opensolaris.org >> http://mail.opensolaris.org/mailman/listinfo/ha-clusters-discuss > > _______________________________________________ > ha-clusters-discuss mailing list > ha-clusters-discuss at opensolaris.org > http://mail.opensolaris.org/mailman/listinfo/ha-clusters-discuss > >