Fix dreport os-release script point to a symbolic link
The os-release file in the dump points to a symbolic link
rather than the actual release details.
As "cp -r" command is used to copy the contents of a symbolic
link file, it copies the link rather than the actual file.
Modified to use cp command to copy the contents of the file
Tested:
before fix
root@witherspoon:/tmp# mkdir test1
root@witherspoon:/tmp# cp -r /etc/os-release test1/
root@witherspoon:/tmp# ls -la test1/
drwxr-xr-x 2 root root 60 Jun 6 12:27 .
drwxrwxrwt 13 root root 320 Jun 6 12:26 ..
lrwxrwxrwx 1 root root 21 Jun 6 12:27 os-release -> ../usr/lib/os-release
after fix
root@witherspoon:/tmp# mkdir test2
root@witherspoon:/tmp# cp /etc/os-release test2/
root@witherspoon:/tmp# ls -la test2/
-rw-r--r-- 1 root root 295 Jun 6 12:27 os-release
Change-Id: I6980ffa40b925fb02be0bf53704d17ebc7995af0
Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
diff --git a/tools/dreport.d/include.d/functions b/tools/dreport.d/include.d/functions
index e2fb44f..3cd57c3 100755
--- a/tools/dreport.d/include.d/functions
+++ b/tools/dreport.d/include.d/functions
@@ -46,6 +46,28 @@
log_warning "Skipping copy $desc $file_name"
fi
}
+# @brief Copy the symbolic link file to the dreport packaging,
+# if it is in the user allowed dump size limit.
+# @param $1 symbolic link file name
+# @param $2 Plugin description used for logging.
+function add_copy_sym_link_file()
+{
+ file_name="$1"
+ desc="$2"
+
+ cp $file_name $name_dir
+ if [ $? -ne 0 ]; then
+ log_error "Failed to copy $desc $file_name"
+ return $RESOURCE_UNAVAILABLE
+ fi
+ if check_size "$name_dir/$(basename "$file_name")"; then
+ log_info "Copied $desc $file_name"
+ return $SUCCESS
+ else
+ log_warning "Skipping copy $desc $file_name"
+ return $RESOURCE_UNAVAILABLE
+ fi
+}
# @brief Calculate file or directory compressed size based on input
# and check whether the size in the allowed size limit.