From: Dmitry Bogatov Date: Fri, 20 Sep 2013 09:53:27 +0000 (+0400) Subject: [PROTO] Send probes from {r,v,}{read,write} only for socket and reg files X-Git-Tag: Tizen_SDK_2.3~142 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=272fced7a209be0528725870a135393d9fc43e58;p=platform%2Fcore%2Fsystem%2Fswap-probe.git [PROTO] Send probes from {r,v,}{read,write} only for socket and reg files See-also: 02637c31710324818e36a0455c6f79c0def786ea Change-Id: I66760615a24c02e2ae7054dcc745db0d3ab7341d Signed-off-by: Dmitry Bogatov --- diff --git a/probe_file/da_io.h b/probe_file/da_io.h index a32390f..3b34d9c 100755 --- a/probe_file/da_io.h +++ b/probe_file/da_io.h @@ -143,23 +143,44 @@ POST_PACK_PROBEBLOCK_MIDDLE_FD(SIZE, _fd, APITYPE); \ POST_PACK_PROBEBLOCK_END() +/*! + * Macros {BEFORE,AFTER}_ORIGINAL_START_END_FD only used in {p,v,}{read,write} + * in which we should log only about files and sockets. Given this lucky + * coincidence we can implement this login in macros. As such, they should not + * be used in functions for which this logic do not apply. + */ +static inline bool stat_regular_or_socket_p(struct stat *buf) +{ + return S_ISREG(buf->st_mode) || S_ISSOCK(buf->st_mode); +} +#define BEFORE_ORIGINAL_START_END_FD(API_ID, FUNCNAME, LIBNAME, FD, APITYPE, INPUTFORMAT, ...) \ + DECLARE_VARIABLE_FD; \ + GET_REAL_FUNC(FUNCNAME, LIBNAME); \ + PRE_PROBEBLOCK_BEGIN(); \ + _fstatret = fstat(FD, &_statbuf); \ + if (stat_regular_or_socket_p(&_statbuf)) { \ + DEFINE_FILESIZE_FD(fd); \ + PREPARE_LOCAL_BUF(); \ + PACK_COMMON_BEGIN(MSG_PROBE_RESOURCE, API_ID, INPUTFORMAT, __VA_ARGS__); \ + PACK_COMMON_END(0, 0, blockresult); \ + PACK_RESOURCE(0, FD, APITYPE, _filesize, _filepath); \ + FLUSH_LOCAL_BUF(); \ + PRE_PROBEBLOCK_END(); \ + } -// ================================================================== -// START_END macro for file -// ================================================================== -#define BEFORE_ORIGINAL_START_END_FD(API_ID, FUNCNAME, LIBNAME, FD, APITYPE, INPUTFORMAT, ...) \ - DECLARE_VARIABLE_FD; \ - GET_REAL_FUNC(FUNCNAME, LIBNAME); \ - PRE_PROBEBLOCK_BEGIN(); \ - _fstatret = fstat(FD, &_statbuf); \ - DEFINE_FILESIZE_FD(fd); \ - PREPARE_LOCAL_BUF(); \ - PACK_COMMON_BEGIN(MSG_PROBE_RESOURCE, API_ID, INPUTFORMAT, __VA_ARGS__); \ - PACK_COMMON_END(0, 0, blockresult); \ - PACK_RESOURCE(0, FD, APITYPE, _filesize, _filepath); \ - FLUSH_LOCAL_BUF(); \ - PRE_PROBEBLOCK_END() +#define AFTER_ORIGINAL_START_END_FD(API_ID, RVAL, SIZE, FD, APITYPE, INPUTFORMAT, ...) \ + POST_PACK_PROBEBLOCK_BEGIN(); \ + setProbePoint(&probeInfo); \ + _fstatret = fstat(FD, &_statbuf); \ + if (stat_regular_or_socket_p(&_statbuf)) { \ + PREPARE_LOCAL_BUF(); \ + PACK_COMMON_BEGIN(MSG_PROBE_RESOURCE, API_ID, INPUTFORMAT, __VA_ARGS__); \ + PACK_COMMON_END(RVAL, newerrno, blockresult); \ + PACK_RESOURCE(SIZE, FD, APITYPE, _filesize, _filepath); \ + FLUSH_LOCAL_BUF(); \ + POST_PACK_PROBEBLOCK_END(); \ + } #define BEFORE_ORIGINAL_START_END_NOFD(API_ID, FUNCNAME, LIBNAME, APITYPE, INPUTFORMAT, ...) \ DECLARE_VARIABLE_FD; \ @@ -186,17 +207,6 @@ POST_PACK_PROBEBLOCK_MIDDLE_FD(0, _fd, APITYPE); \ PRE_PROBEBLOCK_END() -#define AFTER_ORIGINAL_START_END_FD(API_ID, RVAL, SIZE, FD, APITYPE, INPUTFORMAT, ...) \ - POST_PACK_PROBEBLOCK_BEGIN(); \ - setProbePoint(&probeInfo); \ - _fstatret = fstat(FD, &_statbuf); \ - PREPARE_LOCAL_BUF(); \ - PACK_COMMON_BEGIN(MSG_PROBE_RESOURCE, API_ID, INPUTFORMAT, __VA_ARGS__); \ - PACK_COMMON_END(RVAL, newerrno, blockresult); \ - PACK_RESOURCE(SIZE, FD, APITYPE, _filesize, _filepath); \ - FLUSH_LOCAL_BUF(); \ - POST_PACK_PROBEBLOCK_END() - #define AFTER_ORIGINAL_START_END_NOFD(API_ID, RVAL, SIZE, APITYPE, INPUTFORMAT, ...) \ POST_PACK_PROBEBLOCK_BEGIN(); \ setProbePoint(&probeInfo); \