I have an embedded linux system that can update itself from a USB card. The interface program detects the USB insertion and looks for the upgraded executable. I currently copy it to a local file and install some commands in rc5.d to copy the file over the existing exe on the next boot. Then I have the software reboot.
Is there a better way to do this?
The upgrade can be run while the program runs, but the running program you see is actually the old version of it. The old binary remains on the disk until you close the program. Explanation: on Linux systems, a file is just an inode, which can have several links to it.
Please note that executables can also be located in /opt//bin and in /opt//sbin. Further, there are often in /usr/libexec also. Show activity on this post. Note that you can execute from virtually any location, e.g. Documents, as long as the x bit is set and you have access.
The standard Linux executable format is named Executable and Linking Format ( ELF). It was developed by Unix System Laboratories and is now the most widely used format in the Unix world.
You don't need to have it copy the file over on next boot. Instead, this sequence will work fine:
The application will keep running after the unlink()
- the kernel won't release the underlying data until all executing copies are finished.
You can then even just use execve()
to have the currently-running process replace itself with the newly uploaded version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With