util-linux/bash-completion/hwclock
Bastian Krause b22b78b1be hwclock: add --param-set option
Implement the RTC_PARAM_SET RTC ioctl in hwclock. The ioctl interface was
introduced with [1], which went mainline in Kernel v5.16. The parameters
are independent of hardware/driver. This means we can read and set
parameters in a generic way.

The new --param-set hwclock function accepts aliases for parameters
currently existent (Kernel v5.16). They can be extended later on. As
fallback and for values, hexadecimal (if prefixed with 0x) and decimal
values, as defined in [2], are accepted.

Example:

  $ hwclock --param-set bsm=0x0

[1] https://lore.kernel.org/all/20211018151933.76865-1-alexandre.belloni@bootlin.com/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/rtc.h

Signed-off-by: Bastian Krause <bst@pengutronix.de>
2022-01-28 11:37:47 +01:00

68 lines
1.1 KiB
Text

_hwclock_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-f'|'--rtc'|'--adjfile')
local IFS=$'\n'
compopt -o filenames
COMPREPLY=( $(compgen -f -- $cur) )
return 0
;;
'--date'|'--delay')
COMPREPLY=( $(compgen -W "time" -- $cur) )
return 0
;;
'--epoch')
COMPREPLY=( $(compgen -W "year" -- $cur) )
return 0
;;
'--param-get')
COMPREPLY=( $(compgen -W "param" -- $cur) )
return 0
;;
'--param-set')
COMPREPLY=( $(compgen -W "param=value" -- $cur) )
return 0
;;
'-h'|'-?'|'--help'|'-v'|'-V'|'--version')
return 0
;;
esac
case $cur in
-*)
OPTS="--help
--show
--get
--set
--hctosys
--systohc
--systz
--adjust
--getepoch
--setepoch
--predict
--version
--utc
--localtime
--rtc
--directisa
--date
--delay
--epoch
--param-get
--param-set
--update-drift
--noadjfile
--adjfile
--test
--debug"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
return 0
}
complete -F _hwclock_module hwclock