Reputation: 771
I already posted the following Question got a solution and moving forward
I am using ptrace to find what all are the arguments that are passed to the system call.
The program is fetching me values in ebx, ecx, edx. Now for a open system call I got the foll
SYSCALL 5: ebx :bf9748af ecx: 00008000 edx: 00000000 /open
SYSCALL 5: ebx :80485b3 ecx: 00000242 edx: 000001b6 /open
I used strace and it magically converts the above like this:
open("test.txt", O_RDONLY|O_LARGEFILE) = 3
open("test.txt", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3
How can I do this manually? Is there any place I can find out the values for O_LARGEFILE?
I searched a lot and came across this But it doesnt have everything. Also tried reading strace code but did not come across the code for this conversion.
If someone can help me out it would be very helpful for me. Also If you know where this is written in strace I want to take a peek at it. Thanks in advance.
Upvotes: 1
Views: 543
Reputation: 117681
You can read out those values from this header file:
#define O_ACCMODE 0003
#define O_RDONLY 00
#define O_WRONLY 01
#define O_RDWR 02
#define O_CREAT 0100 /* not fcntl */
#define O_EXCL 0200 /* not fcntl */
#define O_NOCTTY 0400 /* not fcntl */
#define O_TRUNC 01000 /* not fcntl */
#define O_APPEND 02000
#define O_NONBLOCK 04000
#define O_NDELAY O_NONBLOCK
#define O_SYNC 010000
#define O_FSYNC O_SYNC
#define O_ASYNC 020000
But the portable way of doing it is by using the macros for those values.
Upvotes: 1
Reputation: 145829
O_LARGEFILE
is implementation specific and is defined in LSB (Linux Standard Base) as
0100000
(equal to 0x8000
) for Linux x86 (in fcntl.h
)
See LSB reference:
http://linuxbase.org/navigator/browse/constant.php?cmd=list-by-name&Cname=O_LARGEFILE
O_RDONLY
value being 0
, O_RDONLY | O_LARGEFILE
is then equal to 0x8000
.
Upvotes: 1