From: Vasiliy Ulyanov Date: Wed, 21 May 2014 06:47:45 +0000 (+0400) Subject: [FEATURE] File analysis: add file lock msg types X-Git-Tag: Tizen_SDK_2.3~48 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=353bcc9699c13f45aad1bc0f5a142f8d7e86a04a;p=platform%2Fcore%2Fsystem%2Fswap-probe.git [FEATURE] File analysis: add file lock msg types Change-Id: I731f95f97da0744d66733d610c6d5d061be0e01c Signed-off-by: Vasiliy Ulyanov --- diff --git a/include/probeinfo.h b/include/probeinfo.h index 258a8fa..5700442 100755 --- a/include/probeinfo.h +++ b/include/probeinfo.h @@ -86,6 +86,8 @@ extern "C"{ #define FD_API_RECEIVE 10 #define FD_API_OPTION 11 #define FD_API_MANAGE 12 +#define FD_API_LOCK_START 14 +#define FD_API_LOCK_END 15 #define SOCKET_API_FD_OPEN 0 diff --git a/probe_file/da_io_posix.c b/probe_file/da_io_posix.c index 68aa65b..79f7644 100755 --- a/probe_file/da_io_posix.c +++ b/probe_file/da_io_posix.c @@ -226,12 +226,24 @@ int fchown(int fd, uid_t owner, gid_t group) int lockf(int fd, int function, off_t size) { static int (*lockfp)(int fd, int function, off_t size); + int api_type = FD_API_PERMISSION; BEFORE_ORIGINAL_FILE(lockf, LIBC); ret = lockfp(fd, function, size); + + switch (function) { + case F_LOCK: + case F_TLOCK: + api_type = FD_API_LOCK_START; + break; + case F_ULOCK: + api_type = FD_API_LOCK_END; + break; + } + AFTER_PACK_ORIGINAL_FD(API_ID_lockf, - 'd', ret, (unsigned int)size, fd, FD_API_PERMISSION, - "ddx", fd, function, (uint64_t)(size)); + 'd', ret, (unsigned int)size, fd, api_type, + "ddx", fd, function, (uint64_t)(size)); return ret; } @@ -380,7 +392,7 @@ ssize_t writev(int fd, const struct iovec *iov, int iovcnt) int fcntl(int fd, int cmd, ...) { static int (*fcntlp)(int fd, int cmd, ...); - int arg = 0; + int arg = 0, api_type = FD_API_OTHER; BEFORE_ORIGINAL_FILE(fcntl, LIBC); @@ -391,8 +403,32 @@ int fcntl(int fd, int cmd, ...) ret = fcntlp(fd, cmd, arg); - AFTER_PACK_ORIGINAL_FD(API_ID_fcntl, - 'd', ret, 0, fd, FD_API_OTHER, "ddd", fd, cmd, arg); + if (cmd == F_SETLK || cmd == F_SETLKW) { + struct flock *flock = (struct flock *)arg; + int type = flock->l_type; + int whence = flock->l_whence; + int64_t /*off_t*/ start = flock->l_start; + int64_t /*off_t*/ len = flock->l_len; + + switch (type) { + case F_RDLCK: + case F_WRLCK: + api_type = FD_API_LOCK_START; + break; + case F_UNLCK: + api_type = FD_API_LOCK_END; + break; + } + + AFTER_PACK_ORIGINAL_FD(API_ID_fcntl, + 'd', ret, 0, fd, api_type, + "ddddxx", fd, cmd, type, + whence, start, len); + } else { + AFTER_PACK_ORIGINAL_FD(API_ID_fcntl, + 'd', ret, 0, fd, api_type, + "ddd", fd, cmd, arg); + } return ret; }