From: Dmitry Bogatov Date: Fri, 20 Sep 2013 11:57:14 +0000 (+0400) Subject: [PROTO] Send probes only for regular files or descriptors X-Git-Tag: Tizen_SDK_2.3~139 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3eaa02fbb16f74cd840ad1193cd365fbc20e39ce;p=platform%2Fcore%2Fsystem%2Fswap-probe.git [PROTO] Send probes only for regular files or descriptors Affected functions: creat dup dup2 fchmod fchown fcntl fdatasync fstat fsync ftruncate futimens lockf lseek open openat Change-Id: I846aecb520169a9a5d4e3738fb1b3199311b1648 Signed-off-by: Dmitry Bogatov --- diff --git a/probe_file/da_io.h b/probe_file/da_io.h index 71d7512..49e8928 100755 --- a/probe_file/da_io.h +++ b/probe_file/da_io.h @@ -110,17 +110,20 @@ #define DEFINE_FILESIZE_FP(fp) _fd = checked_fileno(fp); _filesize = get_fd_filesize(_fd); #define DEFINE_FILESIZE_0() _fd = _filesize = 0; -// ================================================================== -// AFTER_ORIGINAL macro for file -// ================================================================== - -#define AFTER_PACK_ORIGINAL_FD(API_ID, RVAL, SIZE, FD, APITYPE, INPUTFORMAT, ...) \ - POST_PACK_PROBEBLOCK_BEGIN(); \ - PREPARE_LOCAL_BUF(); \ - PACK_COMMON_BEGIN(MSG_PROBE_RESOURCE, API_ID, INPUTFORMAT, __VA_ARGS__); \ - PACK_COMMON_END(RVAL, newerrno, blockresult); \ - _fstatret = fstat(FD, &_statbuf); \ - POST_PACK_PROBEBLOCK_MIDDLE_FD(SIZE, FD, APITYPE); \ +/*! + * Macro AFTER_PACK_ORIGINAL_FD is used in and only in functions, which should report + * only about regular files or sockets, so this logic implemented in macro. + * Watch out when reusing it somewhere else + */ +#define AFTER_PACK_ORIGINAL_FD(API_ID, RVAL, SIZE, FD, APITYPE, INPUTFORMAT, ...) \ + POST_PACK_PROBEBLOCK_BEGIN(); \ + _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); \ + POST_PACK_PROBEBLOCK_MIDDLE_FD(SIZE, FD, APITYPE); \ + } \ POST_PACK_PROBEBLOCK_END() #define AFTER_PACK_ORIGINAL_NOFD(API_ID, RVAL, SIZE, APITYPE, INPUTFORMAT, ...) \