Index: linux-2.6.26.noarch/fs/exec.c =================================================================== --- linux-2.6.26.noarch.orig/fs/exec.c +++ linux-2.6.26.noarch/fs/exec.c @@ -1287,6 +1287,16 @@ int do_execve(char * filename, sched_exec(); + if (filemon) { + static unsigned long prev_jiffies; + printk(KERN_DEBUG "(%2d.%02d) [+%2d.%02d] %s(%d) exec'd %s\n", + jiffies / HZ, jiffies % HZ, + (jiffies-prev_jiffies)/HZ, (jiffies-prev_jiffies) % HZ, + current->comm, task_pid_nr(current), filename); + prev_jiffies = jiffies; + } + + bprm->file = file; bprm->filename = filename; bprm->interp = filename; Index: linux-2.6.26.noarch/fs/namei.c =================================================================== --- linux-2.6.26.noarch.orig/fs/namei.c +++ linux-2.6.26.noarch/fs/namei.c @@ -588,6 +588,15 @@ static __always_inline int link_path_wal struct path save = nd->path; int result; + if (filemon) { + static unsigned long prev_jiffies; + printk(KERN_DEBUG "[%2ld.%02ld] [+%2ld.%02ld] %s(%d) link_path_walk()'d %s\n", + jiffies / HZ, jiffies % HZ, + (jiffies-prev_jiffies)/HZ, (jiffies-prev_jiffies) % HZ, + current->comm, task_pid_nr(current), name); + prev_jiffies = jiffies; + } + /* make sure the stuff we saved doesn't go away */ path_get(&save); Index: linux-2.6.26.noarch/fs/open.c =================================================================== --- linux-2.6.26.noarch.orig/fs/open.c +++ linux-2.6.26.noarch/fs/open.c @@ -1088,8 +1088,38 @@ long do_sys_open(int dfd, const char __u if (!IS_ERR(tmp)) { fd = get_unused_fd_flags(flags); + if (fd >= 0) { struct file *f = do_filp_open(dfd, tmp, flags, mode); + if (filemon) { + char comm[TASK_COMM_LEN]; + static unsigned long prev_jiffies; + + get_task_comm(comm, current); + if (IS_ERR(f)) { + printk(KERN_DEBUG "[%2ld.%02ld] [+%2ld.%02ld] %s(%d) failed to open() %s flags:[%x] mode:[%o] (ret=%ld)\n", + jiffies / HZ, jiffies % HZ, + (jiffies-prev_jiffies)/HZ, (jiffies-prev_jiffies) % HZ, + comm, task_pid_nr(current), filename, flags, mode, PTR_ERR(f)); + } else { + static char *buf; + char *p; + + if (!buf) + buf = kzalloc(1024, GFP_KERNEL); + else + memset(buf, 0, 1024); + + p = dentry_path(f->f_dentry, buf, 1023); + + printk(KERN_DEBUG "[%2ld.%02ld] [+%2ld.%02ld] %s(%d) open()'d %s flags:[%x] mode:[%o]\n", + jiffies / HZ, jiffies % HZ, + (jiffies-prev_jiffies)/HZ, (jiffies-prev_jiffies) % HZ, + comm, task_pid_nr(current), p, flags, mode); + } + prev_jiffies = jiffies; + } + if (IS_ERR(f)) { put_unused_fd(fd); fd = PTR_ERR(f); @@ -1248,3 +1278,12 @@ int nonseekable_open(struct inode *inode } EXPORT_SYMBOL(nonseekable_open); + +int filemon = 0; +static int __init filemon_setup(char *str) +{ + filemon = 1; + return 1; +} +__setup("filemon", filemon_setup); + Index: linux-2.6.26.noarch/include/linux/fs.h =================================================================== --- linux-2.6.26.noarch.orig/include/linux/fs.h +++ linux-2.6.26.noarch/include/linux/fs.h @@ -308,6 +308,8 @@ extern void __init inode_init(void); extern void __init inode_init_early(void); extern void __init files_init(unsigned long); +extern int filemon; + struct buffer_head; typedef int (get_block_t)(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create); Index: linux-2.6.26.noarch/include/linux/jiffies.h =================================================================== --- linux-2.6.26.noarch.orig/include/linux/jiffies.h +++ linux-2.6.26.noarch/include/linux/jiffies.h @@ -154,7 +154,7 @@ static inline u64 get_jiffies_64(void) * Have the 32 bit jiffies value wrap 5 minutes after boot * so jiffies wrap bugs show up earlier. */ -#define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ)) +#define INITIAL_JIFFIES ((unsigned long)(unsigned int) (0*HZ)) /* * Change timeval to jiffies, trying to avoid the