Skip to content

Commit

Permalink
[cmds] Update 'sys' and 'mknod' to work for updating ELKS
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Jan 16, 2025
1 parent 2e20e1f commit 640b078
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
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."

0 comments on commit 640b078

Please sign in to comment.