Mateusz Moscicki [Wed, 22 Jan 2025 11:51:12 +0000 (12:51 +0100)]
Fix coverity issues
Change-Id: Id7f0fe4fd2d803d5d16c003dec33aa1cc9260856
Adam Michalski [Fri, 22 Nov 2024 15:38:17 +0000 (16:38 +0100)]
Add timeout handling for RW-Upgrade scripts
Introduced timeout handling for RW-Upgrade scripts execution.
- Added `run-with-timeout.sh` for executing scripts with a specified
default timeout.
- Modified `update.sh.in` to:
- Use `run-with-timeout.sh` with the default timeout value.
- Parse `###Timeout = <value>` in each script for custom timeouts.
- Default to `INDIVIDUAL_SCRIPT_TIMEOUT` if no custom timeout is set.
- Reads /etc/upgrade/conf.d/rw-upgrade-scripts.conf and sets the
timeout value for all scripts based on it, otherwise sets it to
25 seconds.
- Ensure backward compatibility for scripts without custom timeouts.
- Improve error handling for individual and total timeout violations.
This ensures stricter control over script execution timing and
improves the reliability of the RW-Upgrade process.
Change-Id: Id80f8912e7e4a96251e76cd87ea0131ed2700215
SangYoun Kwak [Tue, 31 Dec 2024 03:18:26 +0000 (12:18 +0900)]
upgrade-apply: Modify to check th_get_size
The return value of th_get_size() is int type, which means it can be
negative value. Previously, the lvalue of assignment was size_t, which
is unsigned integer while rvalue is the return value of th_get_size().
If the return value is positive, it is ok since size_t contains the
range of positive range of int type. But if it is negative it can be a
problem.(also it is an error)
To resolve this issue, a code to check if the return value is negative
or not before assigning it to size_t type variable.
Change-Id: I947484daca4722d3783964ffb98ea85255998164
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
SangYoun Kwak [Mon, 30 Dec 2024 09:38:41 +0000 (18:38 +0900)]
SS_FSUpdate: Fix to cast into bigger type before operation
Since the operands are int, SS_UINT32(unsigned int) and long type, it is
required to cast them into a big enough type before adding them.
(Thier value are all non-negative values)
To resolve this issue, operands are casted to uint64_t, which is big
enough to store the value of the variables and the result of the
arithmetic operation.
Change-Id: Iecf8ffa3be11984ce6fdc3d850f9b9c9f74c7186
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
SangYoun Kwak [Mon, 30 Dec 2024 08:36:08 +0000 (17:36 +0900)]
dynamic-partitions: Add null check for builder lib
The function FindGroup() in MetadataBuilder class can return nullptr if
the name(passed by its parameter) is not exist in its group list(vector).
To resolve this issue, null checking code is added for the return value
of FindGroup() to its caller. Also for the object that gives the name
also null-checked since it is passed by parameter an "can" be null.
Practically, the return value of FindGroup() cannot be null because the
passed name is always exist in this project. Also they are only used in
this project. But it is good practice to check if pointer is null or
not.
Change-Id: I0c42f318d34afec8d1a3b289049a0fba530daa1d
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
SangYoun Kwak [Fri, 13 Dec 2024 10:20:19 +0000 (19:20 +0900)]
Revert "Fix SVACE issues"
Since the original code was OK but the SVACE issue was false positive,
revert it and return to the original code.
Below is an explanation why the original is OK:
The second parameter of lseek() is __off64_t, which is a 64-bit signed
integer and the type of dwPosition is unsigned int, which is a 32-bit
unsigned integer. Since 64-bit signed integer can represent all possible
values of 32-bit unsigned integer, it is OK to use dwPosition as the
second parameter of lseek().
The issue says that __off64_t is long type, but it is only when the
build architecture is 64-bit. When the build architecture is 32-bit the
__off64_t is defined as __int64_t which is 64-bit signed integer.
Thus, the issue of the patch
2d5b2b6 is false positive and patch should
be reverted.
This reverts commit
2d5b2b6fc3a1a9cb45976a47565a03b3f6d6e515.
Change-Id: I8314655deed1be0802865fa1b9be270483a7eb4e
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
Adam Michalski [Fri, 29 Nov 2024 13:06:48 +0000 (14:06 +0100)]
Fix SVACE issues
WID:
12150987 Unsafe conversion of expression 'dwPosition' with type
'SS-UINT32' to type __off64_t.
Change-Id: Ie1fbc1222bc238665ce3767f2909949a2c316177
Jacek Kryszyn [Fri, 29 Nov 2024 13:34:29 +0000 (14:34 +0100)]
Fix SVACE issues
WID:
12148743 Unsafe conversion of expression 'max_slots'
with type 'uint32_t' to type 'int64_t'.
Change-Id: I3ab2334ee5db2f39b62fa33fe247e342decb42af
Mateusz Moscicki [Fri, 29 Nov 2024 12:16:35 +0000 (13:16 +0100)]
Merge branch 'tizen' into tizen_9.0
Change-Id: Icad9f0a9826120f9a2a60818828709942ba2187d
Mateusz Moscicki [Fri, 29 Nov 2024 11:09:30 +0000 (12:09 +0100)]
Fix SVACE issue
Use _FILE_OFFSET_BITS=64 to make sure the off_t (in lseek()) type is
greather than unsigned int
Change-Id: I7bc4d05e8fd824859d00c9bd7711e1a18054c92e
Mateusz Moscicki [Thu, 28 Nov 2024 11:12:41 +0000 (12:12 +0100)]
Merge branch 'tizen' into tizen_9.0
Change-Id: I3f93b257b089c20283849682217f7125e0ac990d
Mateusz Moscicki [Thu, 28 Nov 2024 11:03:04 +0000 (12:03 +0100)]
Fix potential integer overflow
Change-Id: I18569b78274535c25585dfa330e1e6c562b98739
Mateusz Moscicki [Tue, 22 Oct 2024 15:15:16 +0000 (17:15 +0200)]
Add esd-group, ac, package-manager sockets to system-update.target.wants/
When pkg_upgrade is started during RW Upgrade, its child processes try
to connect to various sockets that do not exist at the moment. E.g:
...
access("/run/aul/rpcport/.d::org.tizen.appfw.service.esd::EventSystem", F_OK) = -1 ENOENT (No such file or directory)
nanosleep({tv_sec=0, tv_nsec=
100000000}, NULL) = 0
access("/run/aul/rpcport/.d::org.tizen.appfw.service.esd::EventSystem", F_OK) = -1 ENOENT (No such file or directory)
nanosleep({tv_sec=0, tv_nsec=
100000000}, NULL) = 0
access("/run/aul/rpcport/.d::org.tizen.appfw.service.esd::EventSystem", F_OK) = -1 ENOENT (No such file or directory)
nanosleep({tv_sec=0, tv_nsec=
100000000}, NULL) = 0
...
This can significantly extend RW Upgrade process to more than half an
hour.
Change-Id: I718fcede5364f0fb75226b5bfa0ddf41d40cf721
Jacek Kryszyn [Fri, 4 Oct 2024 10:43:07 +0000 (12:43 +0200)]
scripts: move reboot to the main upgrade script
This solves few issues with upgrade scripts. Before
this change reboot was executed in upgrade-fota.sh which
was executed by upgrade-trigger.sh. There had to be
some checks to decide if upgrade-fota.sh was interrupted
by reboot or for other reasons. In case of interruption
by reboot there were some unwanted error messages anyway.
Moving reboot to upgrade-trigger.sh simplifies scripts.
Now it is certain that if the exit status of upgrade-fota.sh
is different than 0 then it has to be treated as an error.
This change unifies the way how set flags are used and
error_exit function is used more often instead of
combination of setting upgrade progess status and exit.
Change-Id: I7850e498fb26cd52565fd320709b4e38cf4f221a
Jacek Kryszyn [Tue, 10 Sep 2024 05:00:04 +0000 (07:00 +0200)]
blkid-print: handle /dev/vdX devices
In QEMU virtual disks are named /dev/vdX. blkid-print
would put "p" letter between "vdX" and the number of
a device. This change fixes the issue.
Change-Id: I523ce5837f3c2ca727ad41875a51cde3fe872fa4
Mateusz Mościcki [Wed, 14 Aug 2024 11:44:00 +0000 (11:44 +0000)]
Merge "Refactor code to improve the SAM score" into tizen
Adam Michalski [Tue, 13 Aug 2024 13:41:18 +0000 (15:41 +0200)]
Fix clone_partitions not performing cloning in online upgrade
In order for the upgrade state to be completed, upgrade_progress_status
must be equal to 100. Previously this value was set by the
online-update-success service, but this service is executed after the
upgrade-manager service. As a result, the upgrade state is never
switched from "ready" to "completed" preventing clone_partitions from
taking its job.
The solution is to take over the responsibility for setting the upgrade
progress status by the update.sh script instead of the
online-update-success.sh (which is executed from online-update-success
service). This way handling of the progress becomes unified regardless
of the upgrade type.
Change-Id: I1d599251986dac7a378a44545e8dcce285ccab89
Mateusz Moscicki [Tue, 13 Aug 2024 14:00:28 +0000 (16:00 +0200)]
Refactor code to improve the SAM score
Change-Id: I2a1a27e67d761e67a4881294580a1fe8ad1bd710
Adam Michalski [Tue, 23 Jul 2024 11:50:57 +0000 (13:50 +0200)]
Separate ISU data migration part from system RW-upgrade script
This commit is the first in the pair of commits that are going to
move ISU data migration part from the main OS-Upgrade script to
the component RW-upgrade scripts (/usr/share/upgrade/scripts/).
Change-Id: I400e03e12a800c984efee01544083ba2248851ac
SangYoun Kwak [Mon, 29 Jul 2024 09:12:42 +0000 (18:12 +0900)]
upgrade-apply-deltafs: Remove unused function and sensitive data
The function SS_FSAvailiableFreeSpace is not used anywhere so it can be
removed. Also this function prints f_bfree, which is a sensitive value
from statfs so it is removed too.
Another sensitive data from statfs f_bavail is printed as a log, this
log is also removed.
Change-Id: Ic95f76742c95d19bf2146d6bbb45c8372ef10d7c
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
SangYoun Kwak [Mon, 29 Jul 2024 06:06:05 +0000 (15:06 +0900)]
upgrade-apply: Fix to check return value properly
tar_block_read() function can return negative integer and it should be
handled properly. In the previous code, only '-1' and '0' cases are
handled but no negative values less than '-1'.
To fix this issue, negative values less than '-1' is also handled.
Change-Id: Ib3fd0478b008cbe298694ccc10ddf66cfbb7604e
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
SangYoun Kwak [Mon, 22 Jul 2024 06:48:15 +0000 (15:48 +0900)]
clone_partition: Modify background clone conditions
Previously, to determine whether clone or not, checking bootmode was
sufficient.
Since the online upgrade feature is supported and it boots with bootmode
fota.
Thus, to determine if it is safe to clone or not, conditions below are
going to be checked:
* upgrade state is "completed"
* (bootmode is normal)
or
(bootmode is fota and upgrade type is online)
Also, due to it checks the upgrade state, clone_partition.service has to
wait the update-manager.service to be started since it changes the
upgrade state.
Change-Id: I103a39dbe12d4cfab2f4844206b9341c3323f793
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
SangYoun Kwak [Mon, 22 Jul 2024 05:55:05 +0000 (14:55 +0900)]
clone_partitions: Separate clone actions into functions
To increase the readability and remove duplicated codes, codes for
cloning actions are separated as functions.
Change-Id: Icad1d3a1d1bbaafab7cf2ac30509aeb9321ce29a
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
SangYoun Kwak [Mon, 22 Jul 2024 02:47:56 +0000 (11:47 +0900)]
copy-blockdev: Modify to use strerror_r instead of %m
'%m' formatting is an glibc extension, it can be not-supported according
to the build environment. It is not supported in VD environment, so it
is replaced with strerror_r.
Change-Id: I3bb8b458b3b7f47e36d9e6c22d9b03e946aab30f
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
SangYoun Kwak [Thu, 18 Jul 2024 04:06:20 +0000 (13:06 +0900)]
copy-blockdev: Modify to use %m format instead of strerror
strerror() is not guaranteed as thread-safe. To solve this issue, errno
is set as the return value of posix_fadvise and print it with "%m"
format if it is not zero.
This will solve SVACE issue with WGID 226619.
Change-Id: I53aa630c50ba31ed925acff0a57414b972e1a25b
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
SangYoun Kwak [Tue, 16 Jul 2024 11:47:02 +0000 (20:47 +0900)]
copy-blockdev: Fix to handle error case first
The previous code works ok but it can be lead to the reader
misunderstand its behavior.
To make it clear that error case is handled, some codes are rearranged.
Also, to clarify the error handling and flow of the code, switch
statement is replaced to if statement.
Change-Id: I65de34aab245c20ba3b6869cea1931edf99594d5
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
SangYoun Kwak [Tue, 16 Jul 2024 10:58:31 +0000 (19:58 +0900)]
copy-blockdev: Add to print log if posix_fadvise is failed
posix_fadvise() returns non-zero value(error number) if fails.
To make debug easier, log message is added if it returns non-zero value.
Change-Id: I5436897f11a7cd6a98210df7a53f16f427b2f034
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
Adam Michalski [Wed, 3 Jul 2024 14:53:09 +0000 (16:53 +0200)]
Fix SVACE issue.
Reference WGID #220706.
Change-Id: I9c2f5f7a1811a6c4690d0eef4a111f4dc2cdc9b9
Mateusz Moscicki [Thu, 27 Jun 2024 12:35:20 +0000 (14:35 +0200)]
upgrade-apply: Fix different signedness comparison
Change-Id: I6612a640eb3376e6d1860b17b32bfb8055b56849
SangYoun Kwak [Wed, 5 Jun 2024 11:10:46 +0000 (20:10 +0900)]
Modify "upgrade status" to "upgrade progress status"
The commands and api functions about 'get/set upgrade status' are
changed to 'upgrade progress status like below:
* device_board_get_upgrade_status
-> device_board_get_upgrade_progress_status
* device_board_set_upgrade_status
-> device_board_set_upgrade_progress_status
* hal_device_board_get_upgrade_status
-> hal_device_board_get_upgrade_progress_status
* hal_device_board_set_upgrade_status
-> hal_device_board_set_upgrade_progress_status
Thus, the corresponding scripts and source files should be modified too.
Change-Id: Ifc32791c5d04c2ce44e61fd69a36cd710d2af257
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
Yunhee Seo [Mon, 10 Jun 2024 04:56:51 +0000 (13:56 +0900)]
upgrade-apply-deltafs: Change hal-device-board module inclusion path
As HAL ABI versioning is applied to hal-api-device-board module,
inclusion path and file path is changed.
Change-Id: Ic874c84bd752c0f6cabfc1ca2f9e6ee67804c438
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
SangYoun Kwak [Tue, 11 Jun 2024 04:28:02 +0000 (13:28 +0900)]
upgrade-apply: Fix print format for uint64_t
The printf format for uint64_t was "%ld", so it is fixed with "PRIu64",
which can be used for uint64_t portably.
Change-Id: I2f62f30b5b3ae44eb5feb38d07f37f2050814bb0
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
Mateusz Moscicki [Tue, 14 May 2024 15:00:15 +0000 (17:00 +0200)]
Change the way Online Upgrade works.
The Online Upgrade runs old offline-upgrade, and after this
the normal boot (without reboot) is performed.
Change-Id: I84dd183daba33e8060ddf7df4f0b25358e2c0d46
Antoni [Tue, 21 May 2024 14:13:52 +0000 (16:13 +0200)]
Allow for up to two deltas to be given to upgrade scripts.
If a single delta is provided, it has to be either delta-platform or
regular delta. The second delta is optional, and it has to be
delta-boot. The script does not check the type of deltas, it is up
to the script user.
Change-Id: Ia112cc2f95e41a06a337dc0a3a504ab953436208
Mateusz Moscicki [Wed, 15 May 2024 11:21:11 +0000 (13:21 +0200)]
Change the smack label for data-checkpoint.service
The service needs a higher permission to set a proper smack label "_" on
the target directory ("/opt").
Change-Id: Ifab76559dd0b3b0d930f164f492c56aa52d9afd5
Mateusz Moscicki [Wed, 8 May 2024 16:18:46 +0000 (18:18 +0200)]
Add ability to do checkpoint in init
The system-data partition should be mounted before system starts to
boot, due to the configuration files that may reside on it.
Therefore, the script that created checkpoints needed to be modified so
that it could be run from both - systemd service and init.
Change-Id: I6a46c420de1ddc6c7e3ece02f58e132b792a3e47
Mateusz Mościcki [Tue, 4 Jun 2024 13:09:28 +0000 (13:09 +0000)]
Merge "Report upgrade progress for DELTA_IMAGE type deltas" into tizen
Mateusz Mościcki [Tue, 4 Jun 2024 13:09:08 +0000 (13:09 +0000)]
Merge "Exit with new code when trying to finish before RO update completes" into tizen
Adam Michalski [Thu, 11 Apr 2024 14:15:27 +0000 (16:15 +0200)]
Add ISU rpk package removal during OS Upgrade
Removal of the ISU packages from /opt/isu has already been done, but
in addition to that removing files from /opt/usr/globalapps needs to
be done as well.
Change-Id: I10c751fbae0693a1f1510e27ab71151893918d41
Antoni [Thu, 4 Apr 2024 11:23:09 +0000 (13:23 +0200)]
Report upgrade progress for DELTA_IMAGE type deltas
This requires a new file (update-progress-info.ini) in archive.
Change-Id: I8108bb69a1fd0e2bb41548c1003218f99df6b829
Antoni [Fri, 17 May 2024 10:54:08 +0000 (12:54 +0200)]
Exit with new code when trying to finish before RO update completes
Change-Id: Id1ef08ccb72b6b3b9a1eed7b4bde6df3fe53c268
Jacek Kryszyn [Tue, 23 Apr 2024 12:13:24 +0000 (14:13 +0200)]
Show progress of copying
Use copy-blockdev to show progress of partitions copying
as well as update status during upgrade.
Change-Id: I4fe531a59e99396bcc658a67cc730279deb75b4e
Jacek Kryszyn [Mon, 8 Apr 2024 08:44:30 +0000 (10:44 +0200)]
Add copy-blockdev tool
copy-blockdev is a tool which copies one block device
to another (just like head -c $src > $dst or dd) but
it is also able to modify status of upgrade during
copying and to wcheck sha1 hash of both files after the
operation. It will be used during partitions cloning
during upggrade.
Change-Id: I53ece0156bc68181173a87b7ca58ef5810d09493
Youngjae Cho [Tue, 7 May 2024 00:32:04 +0000 (09:32 +0900)]
Remove always false condition
(size_t)dest_size > SIZE_MAX is always false.
Change-Id: Iaefc4b21be4a42b0881f2245b525dc30df7d02c1
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
Youngjae Cho [Mon, 29 Apr 2024 06:32:34 +0000 (15:32 +0900)]
Fix error -Werror=sign-compare
Change-Id: Iba8b94f3eaa7cbc9fa8357cb540001e4669fbad3
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
Chanwoo Choi [Mon, 29 Apr 2024 08:23:43 +0000 (17:23 +0900)]
Revert "upgrade-apply-deltafs: Change hal-device-board module inclusion path"
This reverts commit
22673b882aeb15496e9e86bd98fc1951a165a0ba.
Change-Id: Ib5a270ef1b9ffb9c3880db3bae8644fc79a2ad23
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Mateusz Moscicki [Fri, 5 Apr 2024 16:30:52 +0000 (18:30 +0200)]
Separation of OS Upgrade into two stages
If ugprade-trigger.sh is called without any additional parameters, the
behavior will be as before - an OS Upgrade will be performed and then a
reboot.
You can also use additional options:
upgrade-trigger.sh --ro-update <delta_file> - only the upgrade will be done.
upgrade-trigger.sh --finish - the active slot will be changed and a reboot will occur
Change-Id: I4e343a4791e8f94bb39ec3bc592127562c9aa8b8
Yunhee Seo [Tue, 9 Apr 2024 06:59:17 +0000 (15:59 +0900)]
upgrade-apply-deltafs: Change hal-device-board module inclusion path
As HAL ABI versioning is applied to hal-api-device-board module,
inclusion path and file path is changed.
Change-Id: Ib584d14bd9c821eb348580dfa20cd27b5299e7e5
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
Mateusz Moscicki [Wed, 17 Apr 2024 10:09:32 +0000 (12:09 +0200)]
Add support for the "Online Update"
"Online Update" is a new type of OS Update.
After "reboot fota" the normal boot will be performed, and in addition
the following targets will be run:
* online-update-pre.target - this target startup is reached very realy -
after mouting the file system and before starting services. Within
this target, changes to permission and directory structure, for
example, should take place.
* online-update.target - this target is started after the basic services
(like dlog, dbus) are started. Data migration of services should take
place within this target.
If a service requires data migration after an upgrade, it should provide
a service that will perform the migration at the appropriate time of
system startup. For example:
[Unit]
Description=Bluetooth upgrade service
ConditionKernelCommandLine=bootmode=fota
Before=online-update.target bluetooth-share.service
After=opt.mount
DefaultDependencies=no
[Service]
Type=oneshot
ExecStart=/usr/share/upgrade/scripts/bluetooth-share/bluetooth-share_upgrade.sh
SmackProcessLabel=System
[Install]
RequiredBy=online-update.target
The lines:
Before=online-update.target bluetooth-share.service
After=opt.mount
are responsible for starting the service at the right time.
The old upgrade type is still supported. If the system is booted like
this:
/usr/lib/systemd/systemd --unit=system-update.target
the old upgrade (Offline) will be performed. And if it runs like this:
/usr/lib/systemd/system --unit=online-update.target
then the new upgrade (Online) will be performed.
Change-Id: I691af6c500da66fb537fd744e40fec2e7a607242
Mateusz Moscicki [Fri, 16 Feb 2024 13:46:00 +0000 (14:46 +0100)]
Add data-checkpoint.service to local-fs.target.wants
When the system starts in FOTA mode, data checkpoint of system-data and
user partitions must be created so that data can be resotred in case of
upgrade (data migration) failure.
Change-Id: I5deffff111bd6527295a963b9904a087a649c23c
Jacek Kryszyn [Wed, 3 Apr 2024 14:16:11 +0000 (16:16 +0200)]
Clone partitions using head instead of dd
Instead of cloning partitions (whole disks) using dd,
head -c $part_size is used to copy only necessary bytes.
This can be much faster in case of partitions placed
on much bigger disks.
Change-Id: Ie15b9f543bac8ef351ef0a4ed4e9adfd148cf704
Antoni [Fri, 22 Mar 2024 12:54:29 +0000 (13:54 +0100)]
Add some small fixes suggested by shellcheck
Some suggestions were ignored, for example if they made code less
readable.
Change-Id: I7063c5a192ea677e4d32628ca9160da32894d702
Antoni [Fri, 22 Mar 2024 12:02:36 +0000 (13:02 +0100)]
Log output of upgrade binaries
Some more logs are also added when calling upgrade binaries.
Change-Id: I4a23d5d994604a112ff4805110749db38ed718dc
Antoni [Fri, 15 Mar 2024 09:56:23 +0000 (10:56 +0100)]
Refactor and unify logging in upgrade-support scripts
All messages will now be both logged to file and printed.
Change-Id: I7be56b787027f5f8e2d626e2c078b6aedabb31cc
Jacek Kryszyn [Tue, 19 Mar 2024 11:27:06 +0000 (12:27 +0100)]
Dynamic Partitions - fix remove partitions after cloning
Dynamic partitions from the next slot are removed after
cloning using dmsetup remove. Sometimes this operation
fails due to devices being busy. This fix changes the
way that partitions are removed. dmsetup remove is
repeated five times and --retry flag is used which makes
dmsetup try to remove the device for a couple of seconds
until it will fail.
Change-Id: I2b13055981ed9d4ed5f6b69b516b932c96da020f
Mateusz Moscicki [Tue, 23 Apr 2024 12:17:41 +0000 (14:17 +0200)]
Fix a missing argument
Change-Id: Ib343925388826c79e60a7e9d60b7f2b62e8aceeb
Youngjae Cho [Tue, 23 Apr 2024 10:35:59 +0000 (19:35 +0900)]
Fix error -Werror=shadow
Fix constructor parameter identifier to be suffixed with _.
Change-Id: I8a56b643387e68d3c9031e2324f7acec388ffdfd
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
Youngjae Cho [Tue, 23 Apr 2024 09:59:49 +0000 (18:59 +0900)]
Fix error -Werror=sign-compare
It blames comparing signed type with unsigned type.
Fix it in two step:
1. If signed variable is definitely a nonnegative value at the
code context, cast it into unsigned type directly.
2. If it is unclear whether a signed variable is nonnegative, then
add assertion for testing the variable is nonnegative. After
that assertion, cast it into unsigned type. It helps catching
violation that casting negative value into unsigned variable.
Change-Id: Ib4f2a2cb2ad1901518d0726de6035ac4a033bc67
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
Jaehoon Chung [Mon, 25 Mar 2024 02:12:31 +0000 (11:12 +0900)]
dynamic-partition: liblp: Fix an abnormal completion to do strncpy
Fix an abnormal completion to do strncpy.
Use deviceinfo.partition_name.size instead of sizeof(out.partiton_name).
Change-Id: I8b3605f609a731f5529b1e6b1b8702fb549e08d5
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Jaehoon Chung [Mon, 25 Mar 2024 02:07:58 +0000 (11:07 +0900)]
dynamic-partitions: testlib: Fix overflow coverity issue
It should be overflow according to multiply number_of_parts by
PART_SIZE_B. The type of number_of_parts is 'int'. To prevent
incorrect operation, cast a proper type.
Change-Id: I8fd44cc7622b25631f49f7df670a7a5bf435997e
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Mateusz Moscicki [Tue, 19 Dec 2023 14:34:00 +0000 (15:34 +0100)]
Add check for dm-bow error during upgrade
If such an error occurs, the partition will be remounted as RO.
Therefore, before commiting the data, a check is made to ensure that the
partition is not in this mode.
Change-Id: I43cb571b646f2e0403e2e1138f455c8afe571d59
Jacek Kryszyn [Tue, 20 Feb 2024 15:00:49 +0000 (16:00 +0100)]
parse-dynparts: list free space on super
Added --free-space flag which allows to list free space on
super partition. Can be combined with --list-tables to print
table as multiple lines. Refactored parse-dynparts a bit so
it doesn't matter in which order --list-tables and --free-space
are given. Filename of super still has to be given as a first
argument to maintain compatibility with existing scripts.
Tests of parse-dynparts were refactored in order to be easier
to maintain. Test data is now created using functions from
liblp instead of external tools and hard to understand
operations on raw structures.
Change-Id: If6446618dae03ff31dc7972c94cc84781dc1b9bb
SangYoun Kwak [Wed, 6 Mar 2024 02:27:50 +0000 (11:27 +0900)]
dynamic-partitions: Modify to cast before multiply
Previously, some variables(which are int32_t) are multiplied then casted
to int64_t. It is pointless since it can cause casting after overflow.
To prevent overflow, expression is modified to cast first operand and
then perform multiplication.
This solves a bug reported by SVACE with the following WGIDs:
701511 701817 701826 711926
Change-Id: Ic51b4f608d36850162e42330a7162e41e4b73f6e
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
Jacek Kryszyn [Tue, 13 Feb 2024 08:42:58 +0000 (09:42 +0100)]
liblp: build on 32-bit architectures
Due to a missing definition it was impossible to build liblp
required by parse-dynparts and resize-dynparts on 32-bit
architectures.
Change-Id: I489abc3beea3ea1871078e5d3198e3ea36ed8f23
Jacek Kryszyn [Mon, 12 Feb 2024 12:56:24 +0000 (13:56 +0100)]
Use resize-dynparts from delta file during OS Upgrade
During OS Upgrade we can not rely on the scripts and programs available
on the system, so from this point on, instead of using resize-dynparts
that is on the system, we use the one provided in the delta file.
Change-Id: I2ff7702dcab670d05e7366d573e461a79c3d06a6
Jacek Kryszyn [Wed, 31 Jan 2024 14:34:03 +0000 (15:34 +0100)]
Dynamic Partitions: allow partition resizing
This patch modifies scripts launched during upgrade/partition
cloning by allowing modification of metadata stored on a super
partition in order to resize dynamic partitions.
Change-Id: I338f383d34553f04429c77f85c0720f8c992c94e
Jacek Kryszyn [Wed, 31 Jan 2024 14:26:52 +0000 (15:26 +0100)]
Dynamic Partitions: resizing utility
This patch adds a utility called resize-dynparts which allows
modification of metadata stored on super in order to resize
dynamic partitions.
Change-Id: Idb22f21240a8716d5b303b6cfc456f17f399699e
Jacek Kryszyn [Wed, 31 Jan 2024 13:53:14 +0000 (14:53 +0100)]
Import parse-dynparts
The project allows to read metadata of a super partition and mount partitions
stored on the super partition using dm-linear. Will be used to implement
the super partition with hal/rootfs dm-linear partitions.
Project url: https://github.com/tchebb/parse-android-dynparts. parse-dynparts
was moved from initrd where it was imported for the first time from
parse-android-dynparts master branch (commit
c8837c1). This commit is based
on initrd commit
e92dfb3.
Change-Id: I5753df5fd7924fb9d698059406ea322369fc2d7c
Mateusz Moscicki [Fri, 9 Feb 2024 12:03:26 +0000 (13:03 +0100)]
Use blkid-print from delta file during OS Upgrade
During OS Upgrade we can not rely on the scripts and programs available
on the system, so from this point on, instead of using blkid-print that
is on the system, we use the one provided in the delta file.
Change-Id: I94d0a6dd86f229a4e53184d7ca300e6dcb03d6bb
Mateusz Moscicki [Thu, 1 Feb 2024 14:25:14 +0000 (15:25 +0100)]
blkid-print: Disable the display of help message when partition not found
Displaying a help message may suggest that the program was called with
incorrect parameters.
Change-Id: Ifb6d036b3d78f76da32ce37bc3210a339df09314
Mateusz Moscicki [Thu, 1 Feb 2024 14:24:19 +0000 (15:24 +0100)]
upgrade-scripts: Get rid of error info during reboot
Change-Id: Ibb5cc7de302a319f0c29bb7f2c936e71f1068ae2
Jacek Kryszyn [Fri, 8 Dec 2023 09:53:42 +0000 (10:53 +0100)]
Allow upgrade of Tizen with dynamic partitions
This change adds support of dynamic partitions mapped from super
partition during upgrade. blkid-print was modified in order to
a) print usage and error messages on stderr instead of stdout
b) return output in a form which was extracted using sed anyway
Change-Id: Ibef751fd011dc3baf09df753cc4e8b81a583a0c2
Jaehoon Chung [Thu, 9 Nov 2023 10:54:46 +0000 (19:54 +0900)]
scripts: upgrade-support: Add more information into log message
Add more information into log message.
To know exact sequence and time, add a LOG_DATE and totaltime about
background_copy.
After applying this patch,
[01/01/1970 09:29:21] [upgrade-prepare-partitions.sh][Info] Background copy rootfs, from: /dev/mmcblk0p2 to /dev/mmcblk0p12
[01/01/1970 09:32:29] [upgrade-prepare-partitions.sh][Info] Finished background copy rootfs from /dev/mmcblk0p2 to /dev/mmcblk0p12
[01/01/1970 09:32:29] [upgrade-prepare-partitions.sh][Info] Checksum verification for rootfs
[01/01/1970 09:34:47] [upgrade-prepare-partitions.sh][Info] Partition rootfs was cloned correctly
[01/01/1970 09:34:47] [upgrade-prepare-partitions.sh][Info] Background copy hal, from: /dev/mmcblk0p10 to /dev/mmcblk0p16
[01/01/1970 09:35:05] [upgrade-prepare-partitions.sh][Info] Finished background copy hal from /dev/mmcblk0p10 to /dev/mmcblk0p16
[01/01/1970 09:35:05] [upgrade-prepare-partitions.sh][Info] Finished Background copying A|B partitions for update...Total Time : 356 sec
[01/01/1970 09:35:05] [upgrade-prepare-partitions.sh]RO update preparation: upgrade-prepare-partitions.sh success
[01/01/1970 09:29:09] [upgrade-trigger.sh][Info] Triggered upgrade..
[01/01/1970 09:29:09] [upgrade-trigger.sh][Info] Using <delta.tar> delta file.
[01/01/1970 09:29:09] [upgrade-trigger.sh]set_upgrade_status success: 1
[01/01/1970 09:29:09] [upgrade-trigger.sh][Info] Package verifier is found. Verify delta.tar
[01/01/1970 09:29:09] [upgrade-trigger.sh][Info] Update package verification PASSED!
[01/01/1970 09:29:09] [upgrade-trigger.sh]set_upgrade_status success: 5
[01/01/1970 09:29:09] [upgrade-trigger.sh]Starting to prepare the partitions for upgrade..
[01/01/1970 09:35:05] [upgrade-trigger.sh]set_upgrade_status success: 20
The developers can know how long time takes for background copy with
Total Time.
Change-Id: I4cb004f14480c804dca2df3f15dddf5a83160dd3
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Jaehoon Chung [Wed, 8 Nov 2023 11:20:15 +0000 (20:20 +0900)]
upgrade-scripts: Store the log message before exit_error
The created files of tmp directory will be removed after rebooting.
That makes a difficult to debug when there is a problem.
To remain the log message, copy all log files from /tmp/ to /var/log/fota/ before exit_error.
If error is occurred, there should be the log files.
Change-Id: I63bd28c9e2256ea3a417ee02c3f6c7a0e49641cf
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
SangYoun Kwak [Fri, 13 Oct 2023 11:15:22 +0000 (20:15 +0900)]
upgrade-scripts: Fix to invoke as an error when untar fails
Previously, if the untaring of any delta file from the delta.tar.gz
fails, then the script ignored it and continued to the next delta file.
This may cause some delta files to be not applied which causes the
failure of the FOTA as a result.
To prevent this, the log message was changed to 'Error' from 'Info" and
'exit_error' was used instead of 'continue'.
Change-Id: Idffe1387a58b9a358f717bae4a334405b8946da4
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
Jacek Kryszyn [Wed, 11 Oct 2023 12:18:20 +0000 (14:18 +0200)]
blkid-print: fix partition path for /dev/sdX devices
This change fixes output in case of partitions on /dev/sdX devices.
Previously comparison of a device name with the "dev/sd" string
using strncmp would always return a value different than 0.
Change-Id: I77c471d174e87a70401cddab5464b8c1f671dc3d
Mateusz Moscicki [Thu, 28 Sep 2023 14:02:35 +0000 (16:02 +0200)]
Remove installed ISU package if the new Tizen does not contain it
Change-Id: I60f957afb64c438ab99fff52272a83a4e6841e2c
Mateusz Moscicki [Fri, 1 Sep 2023 11:42:16 +0000 (13:42 +0200)]
Add support for /etc/isu/upgrade.cfg
Configuration file /etc/isu/upgrade.conf specifies what fields will be
checked when verifying the compatiblity of the ISU package during OS
Upgrade.
Fields that should be taken into account should be specified as comma
separated list for option:
platform_major_version_fields=
Change-Id: I7c0251117516080b6d362991770cc6abff113d5e
Mateusz Moscicki [Mon, 7 Aug 2023 09:31:22 +0000 (11:31 +0200)]
Remove ISU packages during major OS upgrade
If the system release name has changed, remove incompatible packages, as
they may not be compatible with the new system version.
Change-Id: I43663bda0f50fbdcd608cd7e65881bd644b36476
Mateusz Moscicki [Thu, 11 May 2023 11:49:03 +0000 (13:49 +0200)]
rw-upgrade: Remove deprecated ISU Pkgs after OS upgrade
Change-Id: Ibe1a96ce2f29a64348a02ab95172e17c69870f66
Mateusz Moscicki [Wed, 10 May 2023 12:02:24 +0000 (14:02 +0200)]
upgrade-apply: Stop copying data twice
In case the destination partition is the clone of the source partition,
then there is no need to copy data again, because it is already in
place.
Change-Id: I31efe018a76f1237452109fd463056c949e88bf9
Karol Lewandowski [Wed, 19 Jul 2023 22:45:16 +0000 (00:45 +0200)]
Switch to openssl3
Change-Id: I0008df12ce2bad49c966dcfd57979f090ae69319
Mateusz Moscicki [Fri, 3 Feb 2023 12:57:40 +0000 (13:57 +0100)]
Version 7.5.7
Change-Id: Ib3c0aad68a42ad69846b4c8297b2d66027cb46a0
Karol Lewandowski [Tue, 20 Dec 2022 22:57:08 +0000 (23:57 +0100)]
upgrade-apply-deltafs: Drop executable bit from file permissions
Change-Id: Ib46ba63a39620840f09c226a5965897315c762a5
Mateusz Moscicki [Fri, 3 Feb 2023 12:04:24 +0000 (13:04 +0100)]
upgrade-apply-deltafs: Fix coverity issues
Change-Id: I40ca168f50b981f359a69d31389a741ee74c09cb
Mateusz Moscicki [Mon, 30 Jan 2023 14:45:23 +0000 (15:45 +0100)]
upgrade-apply-deltafs: Fix memory leak
Change-Id: Ifbcc809a3888c76032ff9b91a5b6b9c57f0055f2
Mateusz Moscicki [Thu, 26 Jan 2023 09:21:18 +0000 (10:21 +0100)]
upgrade-apply-deltafs: Return an error when attribute file cannot be opened
Change-Id: I3c2c65878c14924ba60d50d0603cf8364d455778
Karol Lewandowski [Tue, 18 Oct 2022 21:53:37 +0000 (23:53 +0200)]
Add Dockerfile to make it easy to build host version of upgrade-apply and upgrade-apply-deltafs
This is supposed to be used as part of CI.
Change-Id: If69c1e75002297773fbfc11434e4ab7162fb2d02
Karol Lewandowski [Tue, 31 Jan 2023 17:02:23 +0000 (18:02 +0100)]
cmake: Install upgrade-apply-deltafs to default location
Change-Id: I41e10c4093098e5c1402e1f9f636dbf39e4914e2
Karol Lewandowski [Thu, 2 Feb 2023 11:03:06 +0000 (12:03 +0100)]
cmake: Explicitly set install prefix to /usr
Change-Id: Ia5f6949128eb7ccd95220a8e59cfac424f7c750c
Mateusz Moscicki [Mon, 16 Jan 2023 16:38:55 +0000 (17:38 +0100)]
Version 7.5.6
Change-Id: I77ea1541ccb7388d5a3f930499e0bf1ff36487ba
Mateusz Moscicki [Thu, 19 Jan 2023 09:34:55 +0000 (10:34 +0100)]
Fix SVACE issues
Change-Id: Ied2611d4afd457651b41f0aa068c8b230973118f
Mateusz Moscicki [Mon, 16 Jan 2023 16:32:09 +0000 (17:32 +0100)]
Use delta-verifier provided in the delta archive
Change-Id: I0fb336f6126f4727b473b1e2a1cfdf995aee42ed
Mateusz Mościcki [Tue, 10 Jan 2023 13:23:29 +0000 (13:23 +0000)]
Merge changes I272886ee,I817fbcfe,I90795b82,I2cfcb411 into tizen
* changes:
upgrade-apply-deltafs: Fix missleading debug message in SS_Unlink()
upgrade-apply-deltafs: Stop trying to apply attributes after a faluire
upgrade-apply-deltafs: Stop upgrade process immediately after failure
Fail DELTA_FS type upgrade if there is not enough disk space
Antoni Adaszkiewicz [Tue, 10 Jan 2023 12:32:45 +0000 (13:32 +0100)]
upgrade-apply-deltafs: Fix missleading debug message in SS_Unlink()
ENOENT is handled by upgrade-apply-deltafs, but previous debug
messages suggested that ENOENT was an error.
Change-Id: I272886ee2f66d4efb0ee64b13af018c98b6362a2
Antoni Adaszkiewicz [Tue, 10 Jan 2023 11:30:43 +0000 (12:30 +0100)]
upgrade-apply-deltafs: Stop trying to apply attributes after a faluire
Previously we tried to apply attributes even after previous failures to
try to ensure a successful boot in order to retry upgrade process.
Currently when retrying to upgrade we start from the ground up as
thre are recovery mechanisms available (getting the system to
pre-upgrade state).
Change-Id: I817fbcfecfcaea9ab65570128b15a149df31ac91
Antoni Adaszkiewicz [Tue, 10 Jan 2023 10:37:12 +0000 (11:37 +0100)]
upgrade-apply-deltafs: Stop upgrade process immediately after failure
Previously even after critical failures (e.g. no space left) delta
would still continue be applied (with no chance of success at the end)
Change-Id: I90795b82c2bc276f6f4a5f701af1aa17b71e8bef
Antoni Adaszkiewicz [Thu, 5 Jan 2023 15:35:39 +0000 (16:35 +0100)]
Fail DELTA_FS type upgrade if there is not enough disk space
Change-Id: I2cfcb4113093aab111e64677e453c65892e97a26
Karol Lewandowski [Thu, 5 Jan 2023 10:46:29 +0000 (10:46 +0000)]
Merge "Drop redundant parts of CMake for host build" into tizen
Karol Lewandowski [Thu, 5 Jan 2023 10:46:24 +0000 (10:46 +0000)]
Merge "upgrade-apply-deltafs: Add minor changes in CMakeList.host-build" into tizen