Re: chdir on linux does not work
Timo Lindfors <[email protected]> Wed, 24 May 2006 07:26:14 +0300
| Newsgroups | org.kernel.vger.linux-assembly |
|---|---|
| Message-ID | <[email protected]> |
Hi,
On Tue, May 23, 2006 at 07:49:29PM -0700, Noprianto wrote:
> -> from what i read, chdir is system call number 12
Yep, but better use something like
%define __NR_chdir 12
to make code more readable. Also, your example works just fine here:
$ nasm a.asm -f elf
$ gcc a.o -o a -nostdlib
$ strace ./a
execve("./a", ["./a"], [/* 30 vars */]) = 0
chdir("/bin") = 0
_exit(0) = ?
Remember that chdir affects only the process that calls chdir. You
can't e.g. write a replacement for shell's builtin "cd" command that
way.
best regards,
Timo Lindfors
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFEc+BmQwOiFKptEGsRAi8WAKCsLs/lhDRnntWAorQy/RmIQLKPsACeN5oY W2xjjWL580Y4IbqG5Ks5hi4= =hndJ -----END PGP SIGNATURE-----