ROM-only Files System

關於 ROM-only Files System

這幾天在弄 WinCE 5.0 OS

OS Catalog 裡面 Core OS/Windows CE devices/ Files Systems and Data Store

下面 有一個 File System - Internal(Choose 1)

有一個 RAM and ROM File System

ROM-only File System

選了 ROM-Only , 原本使用 mDOC 會在掛在 /Mounted Volume 變成掛在 "/"(Root) 下面

WinCE Help 裡的 Object Store 泛指系統內的各種被儲存的物件(Object) (Ex. Registry, Files, .......)

而選了 RAM and ROM 在下面所述應該會可以將Object 存在 RAM 裡面, 這樣有了一個問題在於 Suspend 需要將 RAM 內的 Object 保存的問題。

而採用 ROM-only 如果有一個 External Files System 則可以將 Object 存在 External Files System ( CF Card, SD, mDOC, OneNAND)


來自MSDN http://msdn2.microsoft.com/en-us/library/ms886144.aspx

Platform Builder for Microsoft Windows CE 5.0

Selecting the Internal File System for your Target Device

The internal file system in your target device controls access to ROM. The file system can also provide file storage in the object store, which is in RAM. Two internal file system options are available: the RAM and ROM file system and the ROM-only file system. These have different properties and you will want to select the correct one for your target device. Both internal file systems provide the ability to mount additional external file systems, such as file allocation table (FAT).

The RAM and ROM file system provides file storage in the object store, as well as access to the ROM. The object store is the root of the file system, and all data under the root is stored in the object store, with the exception of external file systems, which are mounted as directories under the root. Data in ROM is accessible through the Windows directory. The RAM and ROM file system is most useful in target devices that continuously power RAM because the object store is lost when RAM is not refreshed.

The ROM-only file system does not allow applications to place files in the object store. Data in ROM is accessible through the Windows directory, and external file systems are again mounted as directories under the root. Additionally, with the ROM-only file system, you have the option of choosing an external file system to be placed at the root of the file system. If you mount a file system as the root, all data below the root directory is stored in that file system, with the exception of other external file systems.


來自 MSDN http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcedata5/html/wce50conMountinganInstallableFileSystemastheRootDirectory.asp

Platform Builder for Microsoft Windows CE 5.0

 

Mounting an Installable File System as the Root Directory

Send Feedback on this topic to the authors

A Windows Mobile-based device can mount an installable file system as the root of the virtual file system ("/"). When you mount an external file system as the root, all data below the root directory is stored in the mounted file system. Files and directories of the external file system appear as directories off the root directory; subdirectories of the external file system appear as subdirectories of the root directory. Calls routed to other external volumes, such as /NETWORK or /HardDisk, will retain those names, and calls into those volumes will be routed appropriately.

Including the ROM-only component

To implement an installable file system as the root, you must include the ROM-only file system component in the run-time image instead of the ROM/RAM file system component (SYSGEN_FSROMONLY=1). If the combined RAM and ROM object store system is present in the run-time image, then the object store will always become the root file system.

Note   If you choose to use a file system other than the object store as the root file system, the majority of ActiveSync functionality will not work correctly. ActiveSync assumes that the object store is used as the root file system.

Only one file system may be registered as the root file system. After one root file system is registered, any subsequent file system making the attempt will be registered, but will not become the root file system. To register a different file system as the root file system, first de-register the previous root file system. At that point, there will be no root file system and the directory Windows will no longer be shadowed.

Registering the file system as root

When drivers are loaded and file systems are mounted, the desired file system is registered in a special way to indicate that it should become the root. Before this registration is made, all file API calls accessing files or directories in paths off the root will fail, except those paths that are in ROM.

The following list describes important registry values that must be set in the HKEY_LOCAL_MACHINE/System/StorageManager/Profiles/<MyProfile>/<MyFileSystem> registry key.

Value:type

Description

MountAsRoot: dword

To explicitly mount a file system as the root directory, set the MountAsRoot value to 1.

The root file system is defined as the first file system volume to mount that has the MountAsRoot property. The property is specified in the registry profile of a storage device.

MountAsBootable: dword

To explicitly mount a file system as the boot file system, set the MountAsBootable value to 1.

If multiple mounted file systems have the MountAsBootable value set, the first one to mount will be used as the boot file system.

For most target devices, Microsoft recommends mounting the same file system as both the root and boot file system.

MountPermanent

To explicitly prevent a file system from being programmatically dismounted, set the MountPermanent value to 1.

A boot partition typically contains critical system files, such as the registry. If you mount a partition as bootable, this value ensures that the bootable partition cannot later be programmatically dismounted.

Example

The following example mounts the first FATFS partition on a storage device reporting profile MyProfile as both the root and boot file system, and makes the partition permanent to prevent programmatic dismounting:

[HKEY_LOCAL_MACHINE/System/StorageManager/Profiles/<MyProfile>/FATFS]

    "MountAsRoot"=dword:1

    "MountAsBootable"=dword:1

    "MountPermanent"=dword:1

File shadowing

In Windows CE 4.x, true shadowing was not possible; the /Windows directory was either the installed file system, or a ROM-only file system, rather than the combination of both implied by the term shadow.

In Windows CE versions 5.0 and later, an installed file system provides true shadowing between a Windows directory at the root and the ROM; that is, the files a user sees are in a combination of the two places.

See Also

Installable File System

 

Form:

http://kunyi.spaces.live.com/blog/cns!30484CDA412A1D29!545.entry

D:\Users\Downloads\Log\youtube\bugreport-RMX5313IN-AP3A.240905.015.A2-2025-06-19-11-34-32\bugreport-RMX5313IN-AP3A.240905.015.A2-2025-06-19-11-34-32.txt (155 hits) Line 15125: WINDOW MANAGER LAST ANR (dumpsys window lastanr) Line 116973: ------ VM TRACES AT LAST ANR (/data/anr/anr_2025-06-19-11-19-10-783: 2025-06-19 11:19:18) ------ Line 116973: ------ VM TRACES AT LAST ANR (/data/anr/anr_2025-06-19-11-19-10-783: 2025-06-19 11:19:18) ------ Line 116986: anr < Line 116996: anr < Line 117006: anr < Line 117016: anr < Line 199851: "anrV33-1" prio=5 tid=16 TimedWaiting Line 201580: at anrp.run(PG:35) Line 201676: at anrp.run(PG:35) Line 201731: at anrp.run(PG:35) Line 201752: at anrp.run(PG:35) Line 221720: ------ ANR FILES (ls -lt /data/anr/) ------ Line 221722: -rw------- 1 system system 4661511 2025-06-19 11:19 anr_2025-06-19-11-19-10-783 Line 221723: -rw------- 1 system system 5125123 2025-06-19 11:18 anr_2025-06-19-11-18-28-676 Line 221724: -rw------- 1 system system 5110113 2025-06-19 11:18 anr_2025-06-19-11-17-59-943 Line 221725: -rw------- 1 system system 5170843 2025-06-19 11:15 anr_2025-06-19-11-15-30-180 Line 221726: -rw------- 1 system system 5211710 2025-06-19 11:15 anr_2025-06-19-11-14-59-431 Line 221727: -rw------- 1 system system 5249604 2025-06-19 11:13 anr_2025-06-19-11-13-33-120 Line 221728: -rw------- 1 system system 2550071 2025-06-18 12:01 anr_2025-06-18-12-01-29-071 Line 221729: -rw------- 1 system system 2661757 2025-06-18 12:01 temp_anr_204762592841438826.txt Line 221730: -rw------- 1 system system 4501038 2025-06-18 12:01 anr_2025-06-18-12-00-54-648 Line 221731: -rw------- 1 system system 2790621 2025-06-18 12:00 temp_anr_6131620412329269920.txt Line 221732: -rw------- 1 system system 4774064 2025-06-18 12:00 anr_2025-06-18-12-00-30-005 Line 221733: -rw------- 1 system system 2962603 2025-06-18 12:00 temp_anr_4436968846206332345.txt Line 221734: -rw------- 1 system system 4909259 2025-06-18 12:00 anr_2025-06-18-12-00-06-676 Line 221735: -rw------- 1 system system 5561152 2025-06-18 11:59 anr_2025-06-18-11-59-15-525 Line 221736: -rw------- 1 system system 2486347 2025-06-18 11:58 anr_2025-06-18-11-58-50-107 Line 221737: -rw------- 1 system system 2513502 2025-06-18 11:58 temp_anr_7627520979123128223.txt Line 221738: -rw------- 1 system system 2547664 2025-06-18 11:58 temp_anr_7306873162887901303.txt Line 221739: -rw------- 1 system system 4468182 2025-06-18 11:58 anr_2025-06-18-11-58-19-450 Line 221740: -rw------- 1 system system 5457289 2025-06-18 11:56 anr_2025-06-18-11-56-37-891 Line 221741: -rw------- 1 system system 1325229 2025-06-18 11:54 anr_2025-06-18-11-53-47-163 Line 221742: -rw------- 1 system system 5504454 2025-06-18 11:52 anr_2025-06-18-11-52-01-409 Line 239615: backstage_power/android.app.gate_fgs_timeout_anr_behavior: READ_ONLY + DISABLED (system), DISABLED (device_config) Line 240829: system_performance/com.android.server.utils.anr_timer_freezer: READ_ONLY + DISABLED (system), DISABLED (device_config) Line 240830: system_performance/com.android.server.utils.anr_timer_service: READ_ONLY + DISABLED (system), DISABLED (device_config) Line 259422: service_start_foreground_anr_delay_ms=10000 Line 259437: short_fgs_anr_extra_wait_duration=10000 Line 288694: ACTIVITY MANAGER LAST ANR (dumpsys activity lastanr) Line 300808: importance=400 pss=0.00 rss=0.00 description=bg anr: Input dispatching timed out (Application does not have a focused window). state=empty trace=/data/system/procexitstore/anr_2025-06-18-11-53-47-163.gz Line 300808: importance=400 pss=0.00 rss=0.00 description=bg anr: Input dispatching timed out (Application does not have a focused window). state=empty trace=/data/system/procexitstore/anr_2025-06-18-11-53-47-163.gz Line 307584: importance=230 pss=0.00 rss=347MB description=user request after error: No response to onStartJob state=empty trace=/data/system/procexitstore/anr_2025-06-19-11-19-10-783.gz Line 307588: importance=230 pss=0.00 rss=483MB description=remove task state=empty trace=/data/system/procexitstore/anr_2025-06-19-11-17-59-943.gz Line 307604: importance=230 pss=0.00 rss=452MB description=user request after error: Input dispatching timed out (8b6aa1e com.google.android.youtube/com.google.android.youtube.app.honeycomb.Shell$HomeActivity (server) is not responding. Waited 5001ms for FocusEvent(hasFocus=true)). state=empty trace=/data/system/procexitstore/anr_2025-06-19-11-15-30-180.gz Line 307608: importance=100 pss=0.00 rss=0.00 description=user request after error: Input dispatching timed out (96080e6 com.google.android.youtube/com.google.android.youtube.app.honeycomb.Shell$HomeActivity (server) is not responding. Waited 5000ms for FocusEvent(hasFocus=true)). state=empty trace=/data/system/procexitstore/anr_2025-06-19-11-14-59-431.gz Line 437707: Job Completions com.coloros.gallery3d/com.oplus.gallery.framework.abilities.scan.manager.GalleryScanService: successful_finish(7x) anr(1x) Line 437719: 11 starts, 1 anrs Line 439978: Job Completions @androidx.work.systemjobscheduler@com.google.android.youtube/androidx.work.impl.background.systemjob.SystemJobService: unknown:-1(1x) canceled(14x) successful_finish(24x) anr(1x) Line 439989: 15 starts, 6 anrs Line 441158: Job Completions in.mohalla.sharechat/androidx.work.impl.background.systemjob.SystemJobService: canceled(5x) successful_finish(6x) anr(9x) Line 441159: Job Completions in.mohalla.sharechat/com.google.android.datatransport.runtime.scheduling.jobscheduling.JobInfoSchedulerService: successful_finish(3x) anr(6x) Line 473593: backstage_power/android.app.gate_fgs_timeout_anr_behavior=false Line 475571: system_performance/com.android.server.utils.anr_timer_freezer=false Line 475572: system_performance/com.android.server.utils.anr_timer_service=false Line 476935: 2025-06-17 11:36:45 system_app_anr (compressed text, 232873 bytes) Line 476936: 2025-06-17 11:37:09 system_app_anr (compressed text, 201571 bytes) Line 476937: 2025-06-17 11:40:22 system_app_anr (compressed text, 222123 bytes) Line 476938: 2025-06-17 11:41:13 system_app_anr (compressed text, 185557 bytes) Line 476939: 2025-06-17 11:41:38 system_app_anr (compressed text, 241609 bytes) Line 476940: 2025-06-17 11:42:13 system_app_anr (compressed text, 248915 bytes) Line 476941: 2025-06-17 11:54:53 system_app_anr (compressed text, 167694 bytes) Line 476942: 2025-06-17 11:55:43 system_app_anr (compressed text, 190039 bytes) Line 476943: 2025-06-17 11:58:39 system_app_anr (compressed text, 245539 bytes) Line 476944: 2025-06-17 12:17:04 system_app_anr (compressed text, 214445 bytes) Line 476945: 2025-06-17 12:22:01 system_app_anr (compressed text, 241492 bytes) Line 476947: 2025-06-18 11:52:20 system_app_anr (compressed text, 260400 bytes) Line 476948: 2025-06-18 11:54:13 system_app_anr (compressed text, 196046 bytes) Line 476949: 2025-06-18 11:57:01 system_app_anr (compressed text, 245540 bytes) Line 476950: 2025-06-18 11:58:36 system_app_anr (compressed text, 256724 bytes) Line 476951: 2025-06-18 11:58:53 system_app_anr (compressed text, 83697 bytes) Line 476952: 2025-06-18 11:59:29 system_app_anr (compressed text, 255379 bytes) Line 476953: 2025-06-18 12:00:19 system_app_anr (compressed text, 248849 bytes) Line 476959: 2025-06-19 11:13:43 system_app_anr (compressed text, 238808 bytes) Line 476960: 2025-06-19 11:15:08 system_app_anr (compressed text, 236177 bytes) Line 476961: 2025-06-19 11:15:37 system_app_anr (compressed text, 220894 bytes) Line 476962: 2025-06-19 11:18:08 system_app_anr (compressed text, 223886 bytes) Line 476963: 2025-06-19 11:18:36 system_app_anr (compressed text, 218263 bytes) Line 476964: 2025-06-19 11:19:19 system_app_anr (compressed text, 236600 bytes) Line 483662: es_u_anr_count=3 Line 483663: es_u_anr_window_ms=21600000 Line 483780: <0>com.google.android.youtube::anr: Line 483792: <0>in.mohalla.sharechat::anr: Line 483836: <0>com.google.android.apps.subscriptions.red::anr: Line 483844: <0>com.google.android.youtube::anr: Line 483852: <0>com.google.android.googlequicksearchbox::anr: Line 483858: <0>com.android.providers.calendar::anr: Line 483868: <0>com.android.providers.downloads::anr: Line 483876: <0>com.google.android.apps.messaging::anr: Line 483884: <0>com.oplus.sau::anr: Line 483892: <0>com.heytap.market::anr: Line 483900: <0>com.google.android.configupdater::anr: Line 483908: <0>com.google.android.providers.media.module::anr: Line 483916: <0>com.google.android.apps.safetyhub::anr: Line 483924: <0>in.mohalla.sharechat::anr: Line 483932: <0>com.android.vending::anr: Line 483942: <0>com.google.android.adservices.api::anr: Line 483950: <0>android::anr: Line 483958: <0>com.android.launcher3::anr: Line 483966: <0>com.instagram.android::anr: Line 483974: <0>com.google.android.deskclock::anr: Line 483982: <0>com.google.android.as::anr: Line 483990: <0>com.google.android.gm::anr: Line 484000: <0>com.google.android.apps.tachyon::anr: Line 484008: <0>com.google.android.permissioncontroller::anr: Line 484014: <0>com.google.android.setupwizard::anr: Line 484022: <0>com.android.providers.settings::anr: Line 484030: <0>com.facebook.services::anr: Line 484038: <0>com.google.android.as.oss::anr: Line 484046: <0>com.google.android.apps.wellbeing::anr: Line 484054: <0>com.google.android.dialer::anr: Line 484062: <0>com.google.android.apps.nbu.files::anr: Line 484070: <0>com.google.android.apps.docs::anr: Line 484078: <0>com.google.android.apps.maps::anr: Line 484086: <0>com.google.android.webview::anr: Line 484094: <0>com.coloros.weather2::anr: Line 484102: <0>com.google.android.networkstack::anr: Line 484110: <0>com.google.android.rkpdapp::anr: Line 484118: <0>com.google.android.contacts::anr: Line 484126: <0>com.android.chrome::anr: Line 484134: <0>com.nearme.gamecenter::anr: Line 484142: <0>com.nearme.statistics.rom::anr: Line 484150: <0>com.google.android.gms::anr: Line 484158: <0>com.google.android.tts::anr: Line 484166: <0>com.google.android.apps.walletnfcrel::anr: Line 484174: <0>com.google.android.partnersetup::anr: Line 484182: <0>com.google.android.videos::anr: Line 484190: <0>com.coloros.lockassistant::anr: Line 484200: <0>com.google.android.apps.photos::anr: Line 484208: <0>com.google.android.calendar::anr: Line 484218: <0>com.facebook.katana::anr: Line 484226: <0>com.coloros.phonemanager::anr: Line 484234: <0>com.android.imsserviceentitlement::anr: Line 484242: <0>com.android.settings::anr: Line 484250: <0>com.fitbit.FitbitMobile::anr: Line 484258: <0>com.grofers.customerapp::anr: Line 484266: <0>com.myntra.android::anr: Line 484274: <0>com.google.android.apps.turbo::anr: Line 484282: <0>com.oplus.lfeh::anr: Line 484288: <0>com.google.android.apps.carrier.carrierwifi::anr: Line 484298: <0>com.oppo.quicksearchbox::anr: Line 484306: <0>com.google.android.apps.youtube.music::anr: Line 484314: <0>com.facebook.appmanager::anr: Line 484322: <0>com.coloros.gallery3d::anr: Line 484330: <0>com.snapchat.android::anr: Line 484340: <0>com.google.android.inputmethod.latin::anr: Line 484348: <0>com.glance.internet::anr: Line 484354: <0>com.google.android.apps.restore::anr: Line 484363: Category{anr}: 3 events in +6h0m0s0ms Line 506990: 4x unknown:-1, 38x canceled, 82x successful_finish, 1x anr Line 544392: com.unisoc.traceur.anrstartdumpperfetto: Line 546673: com.unisoc.traceur.anrsavedumpperfetto: Line 708996: _id:585 name:anr_show_background pkg:com.android.settings value:0 default:0 defaultSystemSet:true Line 709073: _id:275 name:dropbox:data_app_anr pkg:com.google.android.gms value:disabled Line 709643: setting: anr_show_background generation:2
07-04
#!/bin/sh . /lib/functions.sh . /lib/functions/system.sh . /usr/share/libubox/jshn.sh # File-local constants CONF_TAR=/tmp/sysupgrade.tgz ETCBACKUP_DIR=/etc/backup INSTALLED_PACKAGES=${ETCBACKUP_DIR}/installed_packages.txt COMMAND=/lib/upgrade/do_stage2 # File-local globals ADD_PROVISIONING=0 SAVE_OVERLAY=0 SAVE_OVERLAY_PATH= SAVE_PARTITIONS=1 SAVE_INSTALLED_PKGS=0 SKIP_UNCHANGED=0 CONF_IMAGE= CONF_BACKUP_LIST=0 CONF_BACKUP= CONF_RESTORE= USE_CURR_PART=0 NEED_IMAGE= HELP=0 TEST=0 # Globals accessed in other files export MTD_ARGS="" export MTD_CONFIG_ARGS="" export INTERACTIVE=0 export VERBOSE=1 export SAVE_CONFIG=1 export IGNORE_MINOR_COMPAT=0 export FORCE=0 export CONFFILES=/tmp/sysupgrade.conffiles # parse options while [ -n "$1" ]; do case "$1" in -i) export INTERACTIVE=1;; -v) export VERBOSE="$(($VERBOSE + 1))";; -q) export VERBOSE="$(($VERBOSE - 1))";; -n) export SAVE_CONFIG=0;; -c) SAVE_OVERLAY=1 SAVE_OVERLAY_PATH=/etc;; -o) SAVE_OVERLAY=1 SAVE_OVERLAY_PATH=/;; -p) SAVE_PARTITIONS=0;; -P) ADD_PROVISIONING=1;; -k) SAVE_INSTALLED_PKGS=1;; -u) SKIP_UNCHANGED=1;; -b|--create-backup) CONF_BACKUP="$2" NEED_IMAGE=1; shift;; -r|--restore-backup) CONF_RESTORE="$2" NEED_IMAGE=1; shift;; -l|--list-backup) CONF_BACKUP_LIST=1;; -f) CONF_IMAGE="$2"; shift;; -s) USE_CURR_PART=1;; -F|--force) export FORCE=1;; -T|--test) TEST=1;; -h|--help) HELP=1; break;; --ignore-minor-compat-version) export IGNORE_MINOR_COMPAT=1;; -*) echo "Invalid option: $1" >&2 exit 1 ;; *) break;; esac shift; done print_help() { cat <<EOF Usage: $0 [<upgrade-option>...] <image file or URL> $0 [-q] [-i] [-c] [-u] [-o] [-k] [-P] <backup-command> <file> upgrade-option: -f <config> restore configuration from .tar.gz (file or url) -i interactive mode -c attempt to preserve all changed files in /etc/ -o attempt to preserve all changed files in /, except those from packages but including changed confs. -u skip from backup files that are equal to those in /rom -n do not save configuration over reflash -p do not attempt to restore the partition table after flash. -k include in backup a list of current installed packages at $INSTALLED_PACKAGES -s stay on current partition (for dual firmware devices) -P create provisioning partition to keep sensitive data across factory resets. -T | --test Verify image and config .tar.gz but do not actually flash. -F | --force Flash image even if image checks fail, this is dangerous! --ignore-minor-compat-version Flash image even if the minor compat version is incompatible. -q less verbose -v more verbose -h | --help display this help backup-command: -b | --create-backup <file> create .tar.gz of files specified in sysupgrade.conf then exit. Does not flash an image. If file is '-', i.e. stdout, verbosity is set to 0 (i.e. quiet). -r | --restore-backup <file> restore a .tar.gz created with sysupgrade -b then exit. Does not flash an image. If file is '-', the archive is read from stdin. -l | --list-backup list the files that would be backed up when calling sysupgrade -b. Does not create a backup file. EOF } IMAGE="$1" if [ $HELP -gt 0 ]; then print_help exit 0 fi if [ -z "$IMAGE" -a -z "$NEED_IMAGE" -a $CONF_BACKUP_LIST -eq 0 ]; then print_help exit 1 fi [ -n "$IMAGE" -a -n "$NEED_IMAGE" ] && { cat <<-EOF -b|--create-backup and -r|--restore-backup do not perform a firmware upgrade. Do not specify both -b|-r and a firmware image. EOF exit 1 } # prevent messages from clobbering the tarball when using stdout [ "$CONF_BACKUP" = "-" ] && export VERBOSE=0 list_conffiles() { if [ -f /usr/lib/opkg/status ]; then awk ' BEGIN { conffiles = 0 } /^Conffiles:/ { conffiles = 1; next } !/^ / { conffiles = 0; next } conffiles == 1 { print } ' /usr/lib/opkg/status elif [ -d /lib/apk/packages ]; then conffiles="" for file in /lib/apk/packages/*.conffiles_static; do conffiles="$(echo -e "$(cat $file)\n$conffiles")" done echo "$conffiles" fi } list_changed_conffiles() { # Cannot handle spaces in filenames - but opkg cannot either... list_conffiles | while read file csum; do [ -r "$file" ] || continue echo "${csum} ${file}" | busybox sha256sum -sc - || echo "$file" done } list_static_conffiles() { local filter=$1 find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \ /etc/sysupgrade.conf /lib/upgrade/keep.d/* 2>/dev/null) \ \( -type f -o -type l \) $filter 2>/dev/null } build_list_of_backup_config_files() { local file="$1" ( list_static_conffiles "$find_filter"; list_changed_conffiles ) | sort -u > "$file" return 0 } build_list_of_backup_overlay_files() { local file="$1" local packagesfiles=$1.packagesfiles touch "$packagesfiles" if [ "$SAVE_OVERLAY_PATH" = / ]; then local conffiles=$1.conffiles local keepfiles=$1.keepfiles list_conffiles | cut -f2 -d ' ' | sort -u > "$conffiles" # backup files from /etc/sysupgrade.conf and /lib/upgrade/keep.d, but # ignore those aready controlled by opkg conffiles list_static_conffiles | sort -u | grep -h -v -x -F -f $conffiles > "$keepfiles" # backup conffiles, but only those changed if '-u' [ $SKIP_UNCHANGED = 1 ] && list_changed_conffiles | sort -u > "$conffiles" # do not backup files from packages, except those listed # in conffiles and keep.d { find /usr/lib/opkg/info -type f -name "*.list" -exec cat {} \; find /usr/lib/opkg/info -type f -name "*.control" -exec sed \ -ne '/^Alternatives/{s/^Alternatives: //;s/, /\n/g;p}' {} \; | cut -f2 -d: } | grep -v -x -F -f $conffiles | grep -v -x -F -f $keepfiles | sort -u > "$packagesfiles" rm -f "$keepfiles" "$conffiles" fi # busybox grep bug when file is empty [ -s "$packagesfiles" ] || echo > $packagesfiles ( cd /overlay/upper/; find .$SAVE_OVERLAY_PATH \( -type f -o -type l \) $find_filter | sed \ -e 's,^\.,,' \ -e '\,^/etc/board.json$,d' \ -e '\,/[^/]*-opkg$,d' \ -e '\,^/etc/urandom.seed$,d' \ -e "\,^$INSTALLED_PACKAGES$,d" \ -e '\,^/usr/lib/opkg/.*,d' \ ) | grep -v -x -F -f $packagesfiles > "$file" rm -f "$packagesfiles" return 0 } if [ $SAVE_OVERLAY = 1 ]; then [ ! -d /overlay/upper/etc ] && { echo "Cannot find '/overlay/upper/etc', required for '-c' or '-o'" >&2 exit 1 } sysupgrade_init_conffiles="build_list_of_backup_overlay_files" else sysupgrade_init_conffiles="build_list_of_backup_config_files" fi find_filter="" if [ $SKIP_UNCHANGED = 1 ]; then [ ! -d /rom/ ] && { echo "'/rom/' is required by '-u'" exit 1 } find_filter='( ( -exec test -e /rom/{} ; -exec cmp -s /{} /rom/{} ; ) -o -print )' fi include /lib/upgrade create_backup_archive() { local conf_tar="$1" local disabled local err [ "$(rootfs_type)" = "tmpfs" ] && { echo "Cannot save config while running from ramdisk." >&2 ask_bool 0 "Abort" && exit return 0 } run_hooks "$CONFFILES" $sysupgrade_init_conffiles ask_bool 0 "Edit config file list" && vi "$CONFFILES" [ "$conf_tar" != "-" ] || conf_tar="" v "Saving config files..." [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V="" sed -i -e 's,^/,,' "$CONFFILES" set -o pipefail { local ret=0 if [ $ret -eq 0 ]; then for service in /etc/init.d/*; do if ! $service enabled >/dev/null 2>&1; then disabled="$disabled$service disable\n" fi done disabled="$disabled\nexit 0" tar_print_member "/etc/uci-defaults/10_disable_services" "$(echo -e $disabled)" "$(date -r /etc/rc.d "+%s")" || ret=1 fi # Part of archive with installed packages info if [ $ret -eq 0 ]; then if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then # Format: pkg-name<TAB>{rom,overlay,unknown} # rom is used for pkgs in /rom, even if updated later if [ -d "/usr/lib/opkg/info" ]; then tar_print_member "$INSTALLED_PACKAGES" "$(find /usr/lib/opkg/info -name "*.control" \( \ \( -exec test -f /rom/{} \; -exec echo {} rom \; \) -o \ \( -exec test -f /overlay/upper/{} \; -exec echo {} overlay \; \) -o \ \( -exec echo {} unknown \; \) \ \) | sed -e 's,.*/,,;s/\.control /\t/')" || ret=1 elif [ -d "/lib/apk/packages" ]; then tar_print_member "$INSTALLED_PACKAGES" "$(find /lib/apk/packages -name "*.list" \( \ \( -exec test -f /rom/{} \; -exec echo {} rom \; \) -o \ \( -exec test -f /overlay/upper/{} \; -exec echo {} overlay \; \) -o \ \( -exec echo {} unknown \; \) \ \) | sed -e 's,.*/,,;s/\.list /\t/')" || ret=1 fi fi fi # Rest of archive with config files and ending padding if [ $ret -eq 0 ]; then tar c${TAR_V} -C / -T "$CONFFILES" || ret=1 fi [ $ret -eq 0 ] } | gzip > "${conf_tar:-/proc/self/fd/1}" err=$? set +o pipefail if [ "$err" -ne 0 ]; then echo "Failed to create the configuration backup." [ -f "$conf_tar" ] && rm -f "$conf_tar" fi rm -f "$CONFFILES" return "$err" } if [ $CONF_BACKUP_LIST -eq 1 ]; then run_hooks "$CONFFILES" $sysupgrade_init_conffiles [ "$SAVE_INSTALLED_PKGS" -eq 1 ] && echo ${INSTALLED_PACKAGES} >> "$CONFFILES" cat "$CONFFILES" rm -f "$CONFFILES" exit 0 fi if [ -n "$CONF_BACKUP" ]; then create_backup_archive "$CONF_BACKUP" exit fi if [ -n "$CONF_RESTORE" ]; then if [ "$CONF_RESTORE" != "-" ] && [ ! -f "$CONF_RESTORE" ]; then echo "Backup archive '$CONF_RESTORE' not found." >&2 exit 1 fi [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V="" v "Restoring config files..." if [ "$(type -t platform_restore_backup)" == 'platform_restore_backup' ]; then platform_restore_backup "$TAR_V" else tar -C / -x${TAR_V}zf "$CONF_RESTORE" fi exit $? fi type platform_check_image >/dev/null 2>/dev/null || { echo "Firmware upgrade is not implemented for this platform." >&2 exit 1 } case "$IMAGE" in http://*|\ https://*) wget -O/tmp/sysupgrade.img "$IMAGE" || exit 1 IMAGE=/tmp/sysupgrade.img ;; esac IMAGE="$(readlink -f "$IMAGE")" case "$IMAGE" in '') echo "Image file not found." >&2 exit 1 ;; /tmp/*) ;; *) v "Image not in /tmp, copying..." cp -f "$IMAGE" /tmp/sysupgrade.img IMAGE=/tmp/sysupgrade.img ;; esac json_load "$(/usr/libexec/validate_firmware_image "$IMAGE")" || { echo "Failed to check image" exit 1 } json_get_var valid "valid" json_get_var forceable "forceable" [ "$valid" -eq 0 ] && { if [ $FORCE -eq 1 ] && [ "$forceable" -eq 1 ]; then echo "Image check failed but --force given - will update anyway!" >&2 else echo "Image check failed." >&2 exit 1 fi } if [ -n "$CONF_IMAGE" ]; then case "$(get_magic_word $CONF_IMAGE cat)" in # .gz files 1f8b) ;; *) echo "Invalid config file. Please use only .tar.gz files" >&2 exit 1 ;; esac get_image "$CONF_IMAGE" "cat" > "$CONF_TAR" export SAVE_CONFIG=1 elif ask_bool $SAVE_CONFIG "Keep config files over reflash"; then [ $TEST -eq 1 ] || create_backup_archive "$CONF_TAR" || exit export SAVE_CONFIG=1 else [ $TEST -eq 1 ] || rm -f "$CONF_TAR" export SAVE_CONFIG=0 fi if [ $TEST -eq 1 ]; then exit 0 fi install_bin /sbin/upgraded v "Commencing upgrade. Closing all shell sessions." if [ -n "$FAILSAFE" ]; then printf '%s\x00%s\x00%s' "$RAM_ROOT" "$IMAGE" "$COMMAND" >/tmp/sysupgrade lock -u /tmp/.failsafe else json_init json_add_string prefix "$RAM_ROOT" json_add_string path "$IMAGE" [ $FORCE -eq 1 ] && json_add_boolean force 1 [ $SAVE_CONFIG -eq 1 ] && json_add_string backup "$CONF_TAR" json_add_string command "$COMMAND" json_add_object options json_add_int save_partitions "$SAVE_PARTITIONS" json_add_int add_provisioning "$ADD_PROVISIONING" [ $USE_CURR_PART -eq 1 ] && json_add_boolean use_curr_part 1 json_close_object ubus call system sysupgrade "$(json_dump)" fi 这个是openwrt的sysupgrade脚本文件,请逐行进行详细注释说明
最新发布
09-18
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值