How do I call the lstat system call in linux/c, not the lstat wrapper around it (lstat(3))? There is no SYS_lstat for syscall(SYS_lstat...
+2
A:
Perhaps you have incomplete headers, SYS_lstat is listed in /usr/include/bits/syscall.h on my Ubuntu 10.4 system.
#define SYS_lstat __NR_lstat
Then in asm/unistd_64.h:
#define __NR_lstat 6
Or perhaps asm/unistd_32.h:
#define __NR_lstat 107
Hope that helps.
eclark
2010-08-08 03:50:41
I have it on CentOS 5 as well.
cHao
2010-08-08 03:54:50
it is in the headers on mine as well but the compiler still does not recognise it.
BobTurbo
2010-08-08 05:44:00
+3
A:
If you're using the syscall directly, you need to make sure your definition of struct stat
and the kernel's definition agree. Also if you're on a 32-bit machine you should probably never use the deprecated lstat
syscall but instead the lstat64
one, since the former will fail on large files. These and numerous other issues are why it's a bad idea to make syscalls yourself instead of using the standard library; the latter wraps around all the legacy compatibility cruft and gives you a standards-compliant POSIX interface.
R..
2010-08-08 03:55:26