# HG changeset patch # User Yasumasa Suenaga # Date 1397481790 -32400 # Node ID 8448fe8f7fae0c1b7a1e14bfc88fbc9f4f6635c7 # Parent c721cb53d2e05c76d08e319ef88cbf3e4a6e7ad7 Bug 1735: REGRESSION: Cannot collect files from procfs reviewed-by: ykubota diff -r c721cb53d2e0 -r 8448fe8f7fae agent/ChangeLog --- a/agent/ChangeLog Mon Mar 31 11:40:13 2014 +0900 +++ b/agent/ChangeLog Mon Apr 14 22:23:10 2014 +0900 @@ -1,3 +1,7 @@ +2014-04-19 Yasumasa Suenaga + + * Bug 1735: REGRESSION: Cannot collect files from procfs + 2014-03-31 KUBOTA Yuji * Bump to 1.1.1 diff -r c721cb53d2e0 -r 8448fe8f7fae agent/src/fsUtil.cpp --- a/agent/src/fsUtil.cpp Mon Mar 31 11:40:13 2014 +0900 +++ b/agent/src/fsUtil.cpp Mon Apr 14 22:23:10 2014 +0900 @@ -111,9 +111,30 @@ } /* Copy data */ - if(unlikely(sendfile64(destFd, sourceFd, NULL, st.st_size) == -1)){ - result = errno; - PRINT_WARN_MSG("Couldn't write copy file data."); + if(st.st_size > 0){ + if(unlikely(sendfile64(destFd, sourceFd, NULL, st.st_size) == -1)){ + result = errno; + PRINT_WARN_MSG("Couldn't copy file."); + } + } + else{ /* This route is for files in procfs */ + char buf[1024]; + ssize_t read_size; + + while((read_size = read(sourceFd, buf, 1024)) > 0){ + + if(write(destFd, buf, (size_t)read_size) == -1){ + read_size = -1; + break; + } + + } + + if(read_size == -1){ + result = errno; + PRINT_WARN_MSG("Couldn't copy file."); + } + } /* Clean up */