|
From: Naveen K. <g_n...@ya...> - 2005-08-11 22:17:08
|
POST(sys_getcwd)
{
vg_assert(SUCCESS);
if (RES != (Addr)NULL)
POST_MEM_WRITE( ARG1, RES );
}
Is the POST_MEM_WRITE second argument correct ? RES is
be an address ? Doesn't POST_MEM_WRITE expect number
of written bytes as second arg ?
Naveen
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
|
|
From: Nicholas N. <nj...@cs...> - 2005-08-11 22:26:09
|
On Thu, 11 Aug 2005, Naveen Kumar wrote:
> POST(sys_getcwd)
> {
> vg_assert(SUCCESS);
> if (RES != (Addr)NULL)
> POST_MEM_WRITE( ARG1, RES );
> }
>
> Is the POST_MEM_WRITE second argument correct ? RES is
> be an address ? Doesn't POST_MEM_WRITE expect number
> of written bytes as second arg ?
Note the comment in the pre-wrapper:
PRE(sys_getcwd)
{
// Note that the kernel version of getcwd() behaves quite differently to
// the glibc one.
PRINT("sys_getcwd ( %p, %llu )", ARG1,(ULong)ARG2);
PRE_REG_READ2(long, "getcwd", char *, buf, unsigned long, size);
PRE_MEM_WRITE( "getcwd(buf)", ARG1, ARG2 );
}
The kernel getcwd() returns the length of the string. From
linux/fs/dcache.c:
/*
* NOTE! The user-level library version returns a
* character pointer. The kernel system call just
* returns the length of the buffer filled (which
* includes the ending '\0' character), or a negative
* error value. So libc would do something like
*
* char *getcwd(char * buf, size_t size)
* {
* int retval;
*
* retval = sys_getcwd(buf, size);
* if (retval >= 0)
* return buf;
* errno = -retval;
* return NULL;
* }
*/
asmlinkage long sys_getcwd(char __user *buf, unsigned long size)
{
...
}
N
|
|
From: Naveen K. <g_n...@ya...> - 2005-08-11 22:39:42
|
--- Nicholas Nethercote <nj...@cs...> wrote:
> On Thu, 11 Aug 2005, Naveen Kumar wrote:
>
> Note the comment in the pre-wrapper:
>
> PRE(sys_getcwd)
> {
> // Note that the kernel version of getcwd()
> behaves quite differently to
> // the glibc one.
> PRINT("sys_getcwd ( %p, %llu )",
> ARG1,(ULong)ARG2);
> PRE_REG_READ2(long, "getcwd", char *, buf,
> unsigned long, size);
> PRE_MEM_WRITE( "getcwd(buf)", ARG1, ARG2 );
> }
>
> The kernel getcwd() returns the length of the
> string. From
> linux/fs/dcache.c:
>
> /*
> * NOTE! The user-level library version returns a
> * character pointer. The kernel system call just
> * returns the length of the buffer filled (which
> * includes the ending '\0' character), or a
> negative
> * error value. So libc would do something like
> *
> * char *getcwd(char * buf, size_t size)
> * {
> * int retval;
> *
> * retval = sys_getcwd(buf, size);
> * if (retval >= 0)
> * return buf;
> * errno = -retval;
> * return NULL;
> * }
> */
> asmlinkage long sys_getcwd(char __user *buf,
> unsigned long size)
> {
> ...
> }
>
> N
>
Got it. For Solaris it sys_getcwd(..) == 0 then
return buf. Thanks
Naveen
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|
|
From: Nicholas N. <nj...@cs...> - 2005-08-11 22:58:34
|
On Thu, 11 Aug 2005, Naveen Kumar wrote: >> /* >> * NOTE! The user-level library version returns a >> * character pointer. The kernel system call just >> * returns the length of the buffer filled (which >> * includes the ending '\0' character), or a >> negative >> * error value. So libc would do something like > > Got it. For Solaris it sys_getcwd(..) == 0 then > return buf. Thanks So this syscall wrapper shouldn't be in syswrap-generic.c, but should be in syswrap-linux.c and a different version in syswrap-solaris.c. N |