diff options
Diffstat (limited to 'package/cfgfs/src')
-rw-r--r-- | package/cfgfs/src/c_lzo1x1.c | 6 | ||||
-rw-r--r-- | package/cfgfs/src/c_null.c | 6 | ||||
-rw-r--r-- | package/cfgfs/src/c_zlib.c | 6 | ||||
-rw-r--r-- | package/cfgfs/src/compress.h | 6 | ||||
-rw-r--r-- | package/cfgfs/src/ft_pack.c | 1 | ||||
-rw-r--r-- | package/cfgfs/src/fwcf.sh | 63 |
6 files changed, 70 insertions, 18 deletions
diff --git a/package/cfgfs/src/c_lzo1x1.c b/package/cfgfs/src/c_lzo1x1.c index 570f8673c..94cf8322b 100644 --- a/package/cfgfs/src/c_lzo1x1.c +++ b/package/cfgfs/src/c_lzo1x1.c @@ -51,10 +51,10 @@ __RCSID("$MirOS: contrib/hosted/fwcf/c_lzo1x1.c,v 1.5 2007/03/13 18:31:07 tg Exp static void c_lzo1x1_load(void) __attribute__((constructor)); static int c_init(void); static int c_compress(char **, char *, size_t) - __attribute__((bounded (string, 2, 3))); + __attribute__((access (read_only, 2, 3))); static int c_decompress(char *, size_t, char *, size_t) - __attribute__((bounded (string, 1, 2))) - __attribute__((bounded (string, 3, 4))); + __attribute__((access (read_write, 1, 2))) + __attribute__((access (read_only, 3, 4))); static fwcf_compressor c_lzo1x1 = { c_init, /* init */ diff --git a/package/cfgfs/src/c_null.c b/package/cfgfs/src/c_null.c index 4806ae261..718550415 100644 --- a/package/cfgfs/src/c_null.c +++ b/package/cfgfs/src/c_null.c @@ -34,10 +34,10 @@ __RCSID("$MirOS: contrib/hosted/fwcf/c_null.c,v 1.5 2006/09/23 23:46:35 tg Exp $ static void c_null_load(void) __attribute__((constructor)); static int c_init(void); static int c_compress(char **, char *, size_t) - __attribute__((bounded (string, 2, 3))); + __attribute__((access (read_only, 2, 3))); static int c_decompress(char *, size_t, char *, size_t) - __attribute__((bounded (string, 1, 2))) - __attribute__((bounded (string, 3, 4))); + __attribute__((access (read_write, 1, 2))) + __attribute__((access (read_only, 3, 4))); static fwcf_compressor c_null = { c_init, /* init */ diff --git a/package/cfgfs/src/c_zlib.c b/package/cfgfs/src/c_zlib.c index 2285f2eeb..65245d507 100644 --- a/package/cfgfs/src/c_zlib.c +++ b/package/cfgfs/src/c_zlib.c @@ -34,10 +34,10 @@ __RCSID("$MirOS: contrib/hosted/fwcf/c_zlib.c,v 1.4 2006/09/23 23:46:35 tg Exp $ static void c_zlib_load(void) __attribute__((constructor)); static int c_init(void); static int c_compress(char **, char *, size_t) - __attribute__((bounded (string, 2, 3))); + __attribute__((access (read_only, 2, 3))); static int c_decompress(char *, size_t, char *, size_t) - __attribute__((bounded (string, 1, 2))) - __attribute__((bounded (string, 3, 4))); + __attribute__((access (read_write, 1, 2))) + __attribute__((access (read_only, 3, 4))); static fwcf_compressor c_zlib = { c_init, /* init */ diff --git a/package/cfgfs/src/compress.h b/package/cfgfs/src/compress.h index 413075d83..2237595c5 100644 --- a/package/cfgfs/src/compress.h +++ b/package/cfgfs/src/compress.h @@ -18,12 +18,12 @@ typedef int (*fwcf_compress_init_func)(void); /* in: *dst (malloc'd), src, size of source (max. INT_MAX) */ /* returns size of destination on success, -1 on failure */ typedef int (*fwcf_compress_work_func)(char **, char *, size_t) - __attribute__((bounded (string, 2, 3))); + __attribute__((access (read_only, 2, 3))); /* in: dst, max size of dst, src, size of source (max. INT_MAX) */ /* returns size of destination on success, -1 on failure */ typedef int (*fwcf_compress_rev_func)(char *, size_t, char *, size_t) - __attribute__((bounded (string, 1, 2))) - __attribute__((bounded (string, 3, 4))); + __attribute__((access (read_write, 1, 2))) + __attribute__((access (read_only, 3, 4))); typedef struct FWCF_COMPRESSOR { fwcf_compress_init_func init; diff --git a/package/cfgfs/src/ft_pack.c b/package/cfgfs/src/ft_pack.c index 5d04f8b5c..53fd98713 100644 --- a/package/cfgfs/src/ft_pack.c +++ b/package/cfgfs/src/ft_pack.c @@ -21,6 +21,7 @@ * the possibility of such damage or existence of a defect. */ +#define _GNU_SOURCE #include <sys/param.h> #include <sys/stat.h> #include <fcntl.h> diff --git a/package/cfgfs/src/fwcf.sh b/package/cfgfs/src/fwcf.sh index ea8452850..8954c3645 100644 --- a/package/cfgfs/src/fwcf.sh +++ b/package/cfgfs/src/fwcf.sh @@ -1,7 +1,7 @@ #!/bin/sh # Copyright (c) 2006-2007 # Thorsten Glaser <tg@mirbsd.de> -# Copyright (c) 2009-2017 +# Copyright (c) 2009-2024 # Waldemar Brodkorb <wbx@openadk.org> # # Provided that these terms and disclaimer and all copyright notices @@ -43,7 +43,7 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin wd=$(pwd) cd / -what='Configuration Filesystem Utility (cfgfs), Version 1.10' +what='Configuration Filesystem Utility (cfgfs), Version 1.12' who=$(id -u) if [ $who -ne 0 ]; then @@ -56,7 +56,7 @@ usage() { $what Usage: { halt | poweroff | reboot } [-Ffn] [-d delay] - cfgfs { commit | erase | setup | status | dump | restore } [flags] + cfgfs { commit | erase | setup | status | diff | dump | restore } [flags] EOF exit 1 } @@ -101,7 +101,7 @@ if [[ $me != cfgfs ]]; then fi case $1 in -(commit|erase|setup|status|dump|restore) ;; +(commit|erase|setup|status|diff|dump|restore) ;; (*) cat >&2 <<EOF $what Syntax: @@ -109,6 +109,7 @@ Syntax: $0 erase $0 setup [-N] $0 status [-rq] + $0 diff [<diff options>] $0 { dump | restore } [<filename>] EOF exit 1 ;; @@ -132,12 +133,25 @@ echo $rootdisk|grep mmcblk >/dev/null 2>&1 if [ $? -ne 0 ]; then rootdisk=${rootdisk%[1-9]} fi -part=$(fdisk -l $rootdisk 2>/dev/null|grep '^/dev'|tail -1|awk '{ print $1 }') +# find last partition with an 88 id +part=$(fdisk -l $rootdisk 2>/dev/null|awk '{if ($2=="*") { print $1" "$9} else {print $1" "$8}}'|grep '^/dev.*88.*'|tail -1|awk '{ print $1 }') if [ -f .cfgfs ]; then . /.cfgfs fi if [ -z $part ]; then - part=$(fdisk -l /dev/sda 2>/dev/null|grep '^/dev'|tail -1|awk '{ print $1 }') + part=$(fdisk -l /dev/sda 2>/dev/null|awk '{if ($2=="*") { print $1" "$9} else {print $1" "$8}}'|grep '^/dev.*88.*'|tail -1|awk '{ print $1 }') + # find GPT partition + if [ -z $part ]; then + partnum=$(gdisk -l $rootdisk 2>/dev/null|fgrep "cfgfs"|awk '{ print $1 }') + if [ ! -z $partnum ]; then + echo $rootdisk|grep mmcblk >/dev/null 2>&1 + if [ $? -eq 0 ]; then + part=${rootdisk}p${partnum} + else + part=${rootdisk}${partnum} + fi + fi + fi if [ -z $part ]; then # otherwise search for MTD device with name cfgfs part=/dev/mtd$(fgrep '"cfgfs"' /proc/mtd 2>/dev/null | sed 's/^mtd\([^:]*\):.*$/\1/')ro @@ -434,5 +448,42 @@ if test $1 = restore; then exit 0 fi +if test $1 = diff; then + if test ! -e /tmp/.cfgfs; then + cat >&2 <<-EOF + cfgfs: error: not yet initialised + explanation: "cfgfs setup" was not yet run + EOF + [[ $1 = -f ]] || exit 11 + fi + shift + tempd=/tmp/.cfgfs/temp + mount -t tmpfs none $tempd + (cd /tmp/.cfgfs/root; tar cf - .) | (cd $tempd; tar xpf - 2>/dev/null) + x=$(dd if="$part" bs=4 count=1 2>/dev/null) + [[ "$x" = "FWCF" ]] && cfgfs.helper -U $tempd <"$part" + + if test -e $tempd/.cfgfs_deleted; then + while IFS= read -r file; do + rm -f "$tempd/$file" + done <$tempd/.cfgfs_deleted + rm -f $tempd/.cfgfs_deleted + fi + (cd /etc; find . -type f; \ + cd $tempd; find . -type f \ + ) | grep -v -e '^./.cfgfs' -e '^./.rnd$' | sort -u | while read f; do + f=${f#./} + if [ ! -e "/etc/$f" ]; then + echo "Deleted: /etc/$f" + elif [ ! -e "$tempd/$f" ]; then + echo "New: /etc/$f" + else + diff "$@" "$tempd/$f" "/etc/$f" + fi + done + umount $tempd + exit 0 +fi + echo 'cfgfs: cannot be reached...' exit 255 |