Skip to content
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

[cmds] Update 'sys' and 'mknod' to work for updating ELKS #2186

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions elkscmd/file_utils/cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ int do_symlink(char *symlnk, char *file)
{
if (opt_verbose) printf("Symlink %s -> %s\n", file, symlnk);

if (opt_force)
unlink(file);
if (symlink(symlnk, file) < 0) {
fprintf(stderr, "Can't create symlink "); fflush(stderr);
perror(symlnk);
Expand Down
6 changes: 3 additions & 3 deletions elkscmd/file_utils/mknod.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ int main(int argc, char **argv)
/* preserve option */
struct stat sb;
if (stat(argv[2], &sb) == 0) {
if (S_ISCHR(sb.st_mode) && argv[3] && (argv[3][0] == 'c' || argv[3][0] == 'u')) return 1;
if (S_ISBLK(sb.st_mode) && argv[3] && argv[3][0] == 'b') return 1;
if (S_ISFIFO(sb.st_mode) && argv[3] && argv[3][0] == 'p') return 1;
if (S_ISCHR(sb.st_mode) && argv[3] && (argv[3][0] == 'c' || argv[3][0] == 'u')) return 0;
if (S_ISBLK(sb.st_mode) && argv[3] && argv[3][0] == 'b') return 0;
if (S_ISFIFO(sb.st_mode) && argv[3] && argv[3][0] == 'p') return 0;
}
/* valid node not there yet, so we advance and create it */
argc--;
Expand Down
10 changes: 7 additions & 3 deletions elkscmd/rootfs_template/bin/sys
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# sys - create bootable system
# sys - create or update system from booted volume
# Creates and/or updates /dev, /etc, /bin and /linux on drive passed as argument
set -e

usage()
{
Expand Down Expand Up @@ -116,7 +118,7 @@ copy_etc_files()
}

# sys script starts here
echo "Installing/Updating ELKS"
echo "Installing/updating ELKS on $1"
MNT=/tmp/mnt
small=0
arg=-s
Expand All @@ -126,8 +128,10 @@ if test "$1" = "-3"; then shift; small=1; fi
if test "$#" -lt 1; then usage; fi

# returns fstype, 1=MINIX, 2=FAT
set +e
makeboot $arg $1
FSTYPE=$?
set -e
if test "$FSTYPE" = "255"; then exit 1; fi;

mkdir -p $MNT
Expand All @@ -143,4 +147,4 @@ sync
umount $1
rmdir $MNT
sync
echo "Finished."
echo "Finished successfully."
Loading