-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/shell log #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Feature/shell log #109
Changes from all commits
ef3e491
d634268
6ee21a3
e0b542a
9bb9f60
1d910c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -44,6 +44,26 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* RDK Logging component name for Backup Logs */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* Backup-specific symlink-aware file existence check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * This function checks if a file or symlink exists, regardless of whether the symlink target exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Uses lstat() instead of stat() to examine the symlink itself, not its target | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| static int backup_file_exists_check(const char *file_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!file_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return -1; // Invalid parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| struct stat sfile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| memset(&sfile, 0, sizeof(sfile)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* Use lstat() to check the file/symlink itself, not the target */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (lstat(file_name, &sfile) != 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return -1; // File/symlink doesn't exist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 0; // File or symlink exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+47
to
+64
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* Backup-specific symlink-aware file existence check | |
| * This function checks if a file or symlink exists, regardless of whether the symlink target exists | |
| * Uses lstat() instead of stat() to examine the symlink itself, not its target | |
| */ | |
| static int backup_file_exists_check(const char *file_name) { | |
| if (!file_name) { | |
| return -1; // Invalid parameter | |
| } | |
| struct stat sfile; | |
| memset(&sfile, 0, sizeof(sfile)); | |
| /* Use lstat() to check the file/symlink itself, not the target */ | |
| if (lstat(file_name, &sfile) != 0) { | |
| return -1; // File/symlink doesn't exist | |
| } | |
| return 0; // File or symlink exists | |
| /* Shared symlink-aware file existence check implemented in backup_logs.c | |
| * This function checks if a file or symlink exists, regardless of whether the | |
| * symlink target exists. It uses lstat() internally to examine the symlink | |
| * itself, not its target. | |
| */ | |
| extern int backup_filePresentCheck_symlink_aware(const char *file_name); | |
| /* Backup-specific wrapper for the shared symlink-aware file existence check. | |
| * Keeping this function preserves the local interface while centralizing the | |
| * actual existence-checking logic in backup_filePresentCheck_symlink_aware(). | |
| */ | |
| static int backup_file_exists_check(const char *file_name) { | |
| return backup_filePresentCheck_symlink_aware(file_name); |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,8 +1,8 @@ | ||||
| /* | ||||
| * If not stated otherwise in this file or this component's LICENSE file the | ||||
| * following copyright and licenses apply: | ||||
| * If not stated otherwise in this file or this component's LICENSE | ||||
| * file the following copyright and licenses apply: | ||||
| * | ||||
| * Copyright 2026 RDK Management | ||||
| * Copyright 2024 Comcast Cable Communications Management, LLC | ||||
| * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | ||||
|
|
@@ -15,13 +15,17 @@ | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | ||||
| * | ||||
| * SPDX-License-Identifier: Apache-2.0 | ||||
| */ | ||||
|
|
||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
| #include <unistd.h> | ||||
| #include <getopt.h> | ||||
| #include <time.h> | ||||
| #include <sys/stat.h> | ||||
|
|
||||
|
|
||||
|
|
||||
|
Comment on lines
+28
to
31
|
||||
| #include <sys/stat.h> |
Copilot
AI
Apr 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clock_gettime(CLOCK_MONOTONIC, ...) return values are not checked. If either call fails (e.g., unsupported clock id on some platforms), program_start/program_end may contain garbage and the runtime log becomes incorrect. Please handle failures (e.g., skip timing/log an error) or guard the calculation on successful calls.
Copilot
AI
Apr 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The runtime measurement uses double arithmetic for seconds, which can increase code size and CPU cost on embedded targets (especially without an FPU). Consider logging an integer duration (e.g., milliseconds as int64_t) to avoid floating-point and keep the binary lightweight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching from
filePresentCheck()to astatichelper that callslstat()will bypass the existing unit-test mocks:backup_logs/unittest/backup_engine_gtest.cppwrapsfilePresentCheck/statbut does not wraplstat, and many tests assertfilePresentCheck_called. As-is, the tests will start hitting the real filesystem or fail assertions. Consider providing a non-static wrapper that tests can__wrap_..., adding an__wrap_lstat, or updating the tests accordingly.