[PROTO] Send probes only for regular files or descriptors
authorDmitry Bogatov <d.bogatov@samsung.com>
Fri, 20 Sep 2013 11:57:14 +0000 (15:57 +0400)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Fri, 20 Sep 2013 13:28:38 +0000 (13:28 +0000)
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 <d.bogatov@samsung.com>
probe_file/da_io.h

index 71d7512..49e8928 100755 (executable)
 #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, ...)                \