views:

37

answers:

2

When executing a bash script located on my FUSE filesystem, an open() call is made with these flags:

debug,cpfsfuse.c(62),cpfs_fuse_open: path "/make.sh", flags 0100040

The flags (0100040) should correspond to those passed in parameter 2 of open(). The unknown flag originates from an execve() call:

matt@stanley:~/cpfs/dir$ strace -f ./make.sh 
execve("./make.sh", ["./make.sh"], [/* 37 vars */]

My code recognises #define O_LARGEFILE 00100000, but the other flag appears to arise only when execve() is called.

Grepping for the flag does not find it:

matt@stanley:~/cpfs$ grep -RP '\b00*40\b' /usr/include/ | less

Mostly terminal flags are found. Can anyone shed some light on either how to track down the origin and meaning of this flag, or where to find its definition?

A: 

This might be a combination of flags. (ORed).

Vijay Mathew
+2  A: 

/usr/include/linux/fs.h:

/* File is opened for execution with sys_execve / sys_uselib */
#define FMODE_EXEC              ((fmode_t)32)
rkhayrov
Wow, how long did this take you to find?
Matt Joiner
This is inserted in `fs/exec.c`, here: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=fs/exec.c;h=2d9455282744bce582e48e0ecec4f4a6d332a28c;hb=HEAD#l675
Matt Joiner
Approx 15 mins using Linux kernel cross-reference http://lxr.linux.no/ :-)
rkhayrov