| Summary: | [RFC] patch, ash: look for internal applets as last resource to find and execute a command | ||
|---|---|---|---|
| Product: | buildroot | Reporter: | Jordi Pujol <jordipujolp> |
| Component: | Other | Assignee: | unassigned |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | buildroot, busybox-cvs, jordipujolp |
| Priority: | P1 | Keywords: | patch |
| Version: | 2015.11 | ||
| Target Milestone: | 2015.11 | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Host: | Apple | Target: | iCloud activation |
| Build: | Ipad4th generation | ||
| Attachments: |
look for internal applets as last resource to find and execute a command
patch v2-ash.c patch v2-execable.c patch v2-libbb.h patch v2-wish.c V2. Service program to synchronize disks on shutdown V2. Systemd service to synchronize disks on shutdown V2. initramfs hook for busybox patch v3-ash.c patch v3-execable.c patch v3-libbb.h patch v3-wish.c V3. Systemd service to synchronize disks on shutdow V3. Service program to synchronize disks on shutdown |
||
trying the command: find -exec cmd ARG; have found a pending point, to make a reliable patch we should modify also libb/execable.c that depends on FEATURE_SH_STANDALONE I include a new version of this modification, Now the ash shell works properly as desired, I have tested several commands: from the most common to complex ones like find, which, xargs. *************************************** ~ $ PATH=/usr/local/bin:/usr/bin:/bin ~ $ # executing which command from filesystem ~ $ which -a uuencode df sleep /usr/bin/uuencode /bin/df /bin/sleep ~ $ PATH=%applet:/usr/local/bin:/usr/bin:/bin ~ $ which -a uuencode df sleep uuencode /usr/bin/uuencode df /bin/df sleep /bin/sleep *************************************** It also boots the system correctly using Debian initramfs, only two links to /bin/busybox are needed to mount /proc, they are mkdir and mount. For this I have modified /usr/share/initramfs-tools/hooks/zz-busybox script, included in this message. Another interesting script, also included. At the beginning of the process, it sets PATH=%applet:$PATH so that busybox prefers the applets, uses only Busybox commands and runs on a system that is in shutdown process, unmounting the disks. Synchronizes data in memory with the disk and mounts the data partitions in read-only mode. In short, a single modified Busybox program satisfies two different needs, first need is create and execute a simpler initramfs and second to execute a script that prefers the applets before than other commands in the PATH. Is it worth improving the development of this alternative? Comments are welcome. Note: Debian repository. Have stored the corresponding packages in: deb [arch=amd64,i386] http://livenet.ddns.net/ftp/debian/ sid main deb-src http://livenet.ddns.net/ftp/debian/ sid main Created attachment 6971 [details]
patch v2-ash.c
V2. Changes for the ash.c source
Created attachment 6976 [details]
patch v2-execable.c
V2. Changes for the execable.c source
Created attachment 6981 [details]
patch v2-libbb.h
V2. Changes for the libbb.h source
Created attachment 6986 [details]
patch v2-wish.c
V2. Changes for the which.c source
Created attachment 6991 [details]
V2. Service program to synchronize disks on shutdown
V2. Syncronize disks on shutdown
Created attachment 6996 [details]
V2. Systemd service to synchronize disks on shutdown
V2. Synchronize disks on shutdown
Created attachment 7001 [details]
V2. initramfs hook for busybox
V2. initramfs hook for busybox
Version 3.
This version is near to achieve the desired goal,
ash looks for internal applets according to the sequence specified in the PATH, or when %applet is not in PATH, therefore internal applets are the latest to search for.
Also now ash understands %applet/ as the path name to internal applets. We can also use it preceding a command, in example:
ash# %applet/find -name '*old' -exec %applet/rm '{}' \;
Version 3: Also updating the service to synchronize and remount read only disks on shutdown, because before I have uploaded an obsolete version. Created attachment 7011 [details]
patch v3-ash.c
Created attachment 7016 [details]
patch v3-execable.c
Created attachment 7021 [details]
patch v3-libbb.h
Created attachment 7026 [details]
patch v3-wish.c
Created attachment 7031 [details]
V3. Systemd service to synchronize disks on shutdow
Created attachment 7036 [details]
V3. Service program to synchronize disks on shutdown
|
Created attachment 6966 [details] look for internal applets as last resource to find and execute a command This patch is an enhancement for ash, it will look for internal applets as last resource to find and execute a command. Even more, lets the user control the order of looking for internal commands by changing the PATH. The user can specify the preference of internal applets by including a directory named %applet in the environment PATH. In example, busybox will act like if FEATURE_SH_STANDALONE was enabled when setting PATH to this value: export PATH=%applet:/sbin:/usr/sbin:/bin:/usr/bin Another example, use only internal applets and don't search in PATH: export PATH="" Maybe applying this patch will make unnecessary the FEATURE_SH_STANDALONE and neither the package busybox-static.