version inc
[dracut.git] / dracut-functions
blob56ebd882d99007da031b4832d9ca5725956beb4d
1 #!/bin/bash
3 # functions used by dracut and other tools.
5 # Copyright 2005-2009 Red Hat, Inc. All rights reserved.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 IF_RTLD=""
22 IF_dynamic=""
24 # Generic substring function. If $2 is in $1, return 0.
25 strstr() { [[ $1 =~ $2 ]]; }
27 # Create all subdirectories for given path without creating the last element.
28 # $1 = path
29 mksubdirs() { mkdir -p ${1%/*}; }
31 # Version comparision function. Assumes Linux style version scheme.
32 # $1 = version a
33 # $2 = comparision op (gt, ge, eq, le, lt, ne)
34 # $3 = version b
35 vercmp() {
36 local n1=(${1//./ }) op=$2 n2=(${3//./ }) i res
38 for ((i=0; ; i++))
40 if [[ ! ${n1[i]}${n2[i]} ]]; then res=0
41 elif ((${n1[i]:-0} > ${n2[i]:-0})); then res=1
42 elif ((${n1[i]:-0} < ${n2[i]:-0})); then res=2
43 else continue
45 break
46 done
48 case $op in
49 gt) ((res == 1));;
50 ge) ((res != 2));;
51 eq) ((res == 0));;
52 le) ((res != 1));;
53 lt) ((res == 2));;
54 ne) ((res != 0));;
55 esac
58 # Log initrd creation.
59 if ! [[ $dracutlogfile ]]; then
60 [[ $dracutbasedir = /usr/share/dracut ]] && \
61 dracutlogfile=/var/log/dracut.log || \
62 dracutlogfile=/tmp/dracut.log
63 # [[ -w $dracutlogfile ]] || dracutlogfile=/tmp/dracut.log
64 if [[ -w $dracutlogfile ]]; then
65 >"$dracutlogfile"
69 dwarning() {
70 echo "W: $@" >&2
71 [[ -w $dracutlogfile ]] && echo "W: $@" >>"$dracutlogfile"
74 dinfo() {
75 [[ $beverbose ]] && echo "I: $@" >&2
76 [[ -w $dracutlogfile ]] && echo "I: $@" >>"$dracutlogfile"
79 derror() {
80 echo "E: $@" >&2
81 [[ -w $dracutlogfile ]] && echo "E: $@" >>"$dracutlogfile"
84 # Function prints global variables in format name=value line by line.
85 # $@ = list of global variables' name
86 print_vars() {
87 local var value
89 for var in $@
91 value=$(eval echo \$$var)
92 [[ ${value} ]] && echo "${var}=\"${value}\""
93 done
96 get_fs_env() {
97 [[ $1 ]] || return
98 eval $(udevadm info --query=env --name=$1|egrep 'ID_FS_(TYPE|UUID)=')
99 [[ $ID_FS_TYPE ]] && return
101 if [[ -x /lib/udev/vol_id ]]; then
102 eval $(/lib/udev/vol_id --export $1)
103 elif find_binary blkid >/dev/null; then
104 eval $(blkid -o udev $1)
105 else
106 return 1
110 get_fs_type() (
111 [[ $1 ]] || return
112 if [[ $1 != ${1#/dev/block/nfs:} ]] \
113 || [[ $1 != ${1#/dev/block/nfs3:} ]] \
114 || [[ $1 != ${1#/dev/block/nfs4:} ]]; then
115 echo "nfs"
116 return
118 get_fs_env $1 || return
119 echo $ID_FS_TYPE
122 get_fs_uuid() (
123 get_fs_env $1 || return
124 echo $ID_FS_UUID
127 # finds the major:minor of the block device backing the root filesystem.
128 find_block_device() {
129 local x mpt majmin dev fs misc maj min
130 if [[ $use_fstab != yes ]]; then
131 while read x x majmin x mpt x x fs misc; do
132 [[ $fs = nfs ]] && { echo $dev; return 0;}
133 [[ $fs = nfs3 ]] && { echo $dev; return 0;}
134 [[ $fs = nfs4 ]] && { echo $dev; return 0;}
135 if [[ $mpt = $1 ]] && [[ ${majmin#0:} = $majmin ]]; then
136 echo $majmin;
137 return 0 # we have a winner!
139 done < /proc/self/mountinfo
141 # fall back to /etc/fstab
142 while read dev mpt fs misc; do
143 if [[ $mpt = $1 ]]; then
144 [[ $fs = nfs ]] && { echo $dev; return 0;}
145 [[ $fs = nfs3 ]] && { echo $dev; return 0;}
146 [[ $fs = nfs4 ]] && { echo $dev; return 0;}
147 [[ $dev != ${dev#UUID=} ]] && dev=/dev/disk/by-uuid/${dev#UUID=}
148 [[ $dev != ${dev#LABEL=} ]] && dev=/dev/disk/by-label/${dev#LABEL=}
149 [[ -b $dev ]] || return 1 # oops, not a block device.
150 ls -nLl "$dev" | {
151 read x x x x maj min x;
152 maj=${maj//,/};
153 echo $maj:$min;
154 } && return 0
156 done < /etc/fstab
157 return 1;
160 find_root_block_device() { find_block_device /; }
162 # Walk all the slave relationships for a given block device.
163 # Stop when our helper function returns success
164 # $1 = function to call on every found block device
165 # $2 = block device in major:minor format
166 check_block_and_slaves() {
167 local x
168 [[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
169 "$1" $2 && return
170 check_vol_slaves "$@" && return 0
171 if [[ -f "/sys/dev/block/$2/../dev" ]]; then
172 check_block_and_slaves $1 $(cat "/sys/dev/block/$2/../dev") && return 0
174 [[ -d /sys/dev/block/$2/slaves ]] || return 1
175 for x in /sys/dev/block/$2/slaves/*/dev; do
176 [[ -f $x ]] || continue
177 check_block_and_slaves $1 $(cat "$x") && return 0
178 done
179 return 1
182 get_numeric_dev() {
183 ls -lH "$1" | { read a b c d maj min rest; printf "%d:%d" ${maj%%,} $min;}
186 # ugly workaround for the lvm design
187 # There is no volume group device,
188 # so, there are no slave devices for volume groups.
189 # Logical volumes only have the slave devices they really live on,
190 # but you cannot create the logical volume without the volume group.
191 # And the volume group might be bigger than the devices the LV needs.
192 check_vol_slaves() {
193 for i in /dev/mapper/*; do
194 lv=$(get_numeric_dev $i)
195 if [[ $lv = $2 ]]; then
196 vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
197 # strip space
198 vg=$(echo $vg)
199 if [[ $vg ]]; then
200 for pv in $(lvm vgs --noheadings -o pv_name "$vg" 2>/dev/null); \
202 check_block_and_slaves $1 $(get_numeric_dev $pv) \
203 && return 0
204 done
207 done
208 return 1
211 # Install a directory, keeping symlinks as on the original system.
212 # Example: if /lib64 points to /lib on the host, "inst_dir /lib/file"
213 # will create ${initdir}/lib64, ${initdir}/lib64/file,
214 # and a symlink ${initdir}/lib -> lib64.
215 inst_dir() {
216 local dir="$1"
217 [[ -e "${initdir}$dir" ]] && return 0
219 # iterate over parent directories
220 local file=""
221 local IFS="/"
222 for part in $dir; do
223 [ -z "$part" ] && continue
224 file="$file/$part"
225 [[ -e "${initdir}$file" ]] && continue
227 if [ -L "$file" ]; then
228 # create link as the original
229 local target=$(readlink "$file")
230 ln -sfn "$target" "${initdir}$file" || return 1
231 # resolve relative path and recursively install destionation
232 [[ "$target" = "${target##*/}" ]] && target="${file%/*}/$target"
233 inst_dir "$target"
234 else
235 # create directory
236 mkdir -p "${initdir}$file" || return 1
238 done
241 # $1 = file to copy to ramdisk
242 # $2 (optional) Name for the file on the ramdisk
243 # Location of the image dir is assumed to be $initdir
244 # We never overwrite the target if it exists.
245 inst_simple() {
246 local src target
247 [[ -f $1 ]] || return 1
248 src=$1 target="${2:-$1}"
249 if ! [[ -d ${initdir}$target ]]; then
250 [[ -e ${initdir}$target ]] && return 0
251 inst_dir "${target%/*}"
253 dinfo "Installing $src"
254 cp -pfL "$src" "${initdir}$target"
257 # find symlinks linked to given library file
258 # $1 = library file
259 # Function searches for symlinks by stripping version numbers appended to
260 # library filename, checks if it points to the same target and finally
261 # prints the list of symlinks to stdout.
263 # Example:
264 # rev_lib_symlinks libfoo.so.8.1
265 # output: libfoo.so.8 libfoo.so
266 # (Only if libfoo.so.8 and libfoo.so exists on host system.)
267 rev_lib_symlinks() {
268 [[ ! $1 ]] && return 0
270 local fn="$1" orig="$(readlink -f "$1")" links=''
272 [[ ${fn} =~ .*\.so\..* ]] || return 1
274 until [[ ${fn##*.} == so ]]; do
275 fn="${fn%.*}"
276 [[ -L ${fn} && $(readlink -f "${fn}") == ${orig} ]] && links+=" ${fn}"
277 done
279 echo ${links}
282 # Same as above, but specialized to handle dynamic libraries.
283 # It handles making symlinks according to how the original library
284 # is referenced.
285 inst_library() {
286 local src=$1 dest=${2:-$1} lib reallib symlink
287 [[ -e $initdir$dest ]] && return 0
288 if [[ -L $src ]]; then
289 reallib=$(readlink -f "$src")
290 lib=${src##*/}
291 inst_simple "$reallib" "$reallib"
292 inst_dir "${dest%/*}"
293 (cd "${initdir}${dest%/*}" && ln -s "$reallib" "$lib")
294 else
295 inst_simple "$src" "$dest"
298 # Create additional symlinks. See rev_symlinks description.
299 for symlink in $(rev_lib_symlinks $src) $(rev_lib_symlinks $reallib); do
300 [[ ! -e $initdir$symlink ]] && {
301 dinfo "Creating extra symlink: $symlink"
302 inst_symlink $symlink
304 done
307 # find a binary. If we were not passed the full path directly,
308 # search in the usual places to find the binary.
309 find_binary() {
310 local binpath="/bin /sbin /usr/bin /usr/sbin" p
311 [[ -z ${1##/*} && -x $1 ]] && { echo $1; return 0; }
312 for p in $binpath; do
313 [[ -x $p/$1 ]] && { echo "$p/$1"; return 0; }
314 done
315 return 1
318 # Same as above, but specialized to install binary executables.
319 # Install binary executable, and all shared library dependencies, if any.
320 inst_binary() {
321 local bin target
322 bin=$(find_binary "$1") || return 1
323 target=${2:-$bin}
324 inst_symlink $bin $target && return 0
325 local LDSO NAME IO FILE ADDR I1 n f TLIBDIR
326 [[ -e $initdir$target ]] && return 0
327 # I love bash!
328 LC_ALL=C ldd $bin 2>/dev/null | while read line; do
329 [[ $line = 'not a dynamic executable' ]] && return 1
330 if [[ $line =~ not\ found ]]; then
331 derror "Missing a shared library required by $bin."
332 derror "Run \"ldd $bin\" to find out what it is."
333 derror "dracut cannot create an initrd."
334 exit 1
336 so_regex='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
337 [[ $line =~ $so_regex ]] || continue
338 FILE=${BASH_REMATCH[1]}
339 [[ -e ${initdir}$FILE ]] && continue
340 # see if we are loading an optimized version of a shared lib.
341 lib_regex='^(/lib[^/]*).*'
342 if [[ $FILE =~ $lib_regex ]]; then
343 TLIBDIR=${BASH_REMATCH[1]}
344 BASE=${FILE##*/}
345 # prefer nosegneg libs, then unoptimized ones.
346 for f in "$TLIBDIR/i686/nosegneg" "$TLIBDIR"; do
347 [[ -e $f/$BASE ]] || continue
348 FILE=$f/$BASE
349 break
350 done
351 inst_library "$FILE" "$TLIBDIR/$BASE"
352 IF_dynamic=yes
353 continue
355 inst_library "$FILE"
356 done
357 inst_simple "$bin" "$target"
360 # same as above, except for shell scripts.
361 # If your shell script does not start with shebang, it is not a shell script.
362 inst_script() {
363 [[ -f $1 ]] || return 1
364 local line
365 read -r -n 80 line <"$1"
366 # If debug is set, clean unprintable chars to prevent messing up the term
367 [[ $debug ]] && line=$(echo -n "$line" | tr -c -d '[:print:][:space:]')
368 shebang_regex='(#! *)(/[^ ]+).*'
369 [[ $line =~ $shebang_regex ]] || return 1
370 inst "${BASH_REMATCH[2]}" && inst_simple "$@"
373 # same as above, but specialized for symlinks
374 inst_symlink() {
375 local src=$1 target=$initdir${2:-$1} realsrc
376 [[ -L $1 ]] || return 1
377 [[ -L $target ]] && return 0
378 realsrc=$(readlink -f "$src")
379 [[ $realsrc = ${realsrc##*/} ]] && realsrc=${src%/*}/$realsrc
380 inst "$realsrc" && ln -s "$realsrc" "$target"
383 # find a udev rule in the usual places.
384 find_rule() {
385 [[ -f $1 ]] && { echo "$1"; return 0; }
386 for r in . /lib/udev/rules.d /etc/udev/rules.d $dracutbasedir/rules.d; do
387 [[ -f $r/$1 ]] && { echo "$r/$1"; return 0; }
388 done
389 return 1
392 # udev rules always get installed in the same place, so
393 # create a function to install them to make life simpler.
394 inst_rules() {
395 local target=/etc/udev/rules.d rule found
397 inst_dir "/lib/udev/rules.d"
398 inst_dir "$target"
399 for rule in "$@"; do
400 found=$(find_rule "$rule") && \
401 inst_simple "$found" "$target/${found##*/}" \
402 || dinfo "Skipping udev rule: $rule"
403 done
406 # general purpose installation function
407 # Same args as above.
408 inst() {
409 case $# in
410 1) ;;
412 [[ -z $initdir ]] && [[ -d $2 ]] && export initdir=$2
413 [[ $initdir = $2 ]] && set $1
416 [[ -z $initdir ]] && export initdir=$2
417 set $1 $3
420 derror "inst only takes 1 or 2 or 3 arguments"
421 exit 1
423 esac
424 for x in inst_symlink inst_script inst_binary inst_simple; do
425 $x "$@" && return 0
426 done
427 return 1
430 # install function specialized for hooks
431 # $1 = type of hook, $2 = hook priority (lower runs first), $3 = hook
432 # All hooks should be POSIX/SuS compliant, they will be sourced by init.
433 inst_hook() {
434 if ! [[ -f $3 ]]; then
435 derror "Cannot install a hook ($3) that does not exist."
436 derror "Aborting initrd creation."
437 exit 1
438 elif ! strstr "$hookdirs" "$1"; then
439 derror "No such hook type $1. Aborting initrd creation."
440 exit 1
442 inst_simple "$3" "/${1}/${2}${3##*/}"
445 dracut_install() {
446 if [[ $1 = '-o' ]]; then
447 local optional=yes
448 shift
450 while (($# > 0)); do
451 if ! inst "$1" ; then
452 if [[ $optional = yes ]]; then
453 dwarning "Skipping program $1 as it cannot be found and is flagged to be optional"
454 else
455 derror "Failed to install $1"
456 exit 1
459 shift
460 done
463 # install function decompressing the target and handling symlinks
464 # $@ = list of compressed (gz or bz2) files or symlinks pointing to such files
466 # Function install targets in the same paths inside overlay but decompressed
467 # and without extensions (.gz, .bz2).
468 inst_decompress() {
469 local src dst realsrc realdst cmd
471 for src in $@
473 case ${src} in
474 *.gz) cmd='gzip -d' ;;
475 *.bz2) cmd='bzip2 -d' ;;
476 *) return 1 ;;
477 esac
479 if [[ -L ${src} ]]
480 then
481 realsrc="$(readlink -f ${src})" # symlink target with extension
482 dst="${src%.*}" # symlink without extension
483 realdst="${realsrc%.*}" # symlink target without extension
484 mksubdirs "${initdir}/${src}"
485 # Create symlink without extension to target without extension.
486 ln -s "${realdst}" "${initdir}/${dst}"
489 # If the source is symlink we operate on its target.
490 [[ ${realsrc} ]] && src=${realsrc}
491 inst ${src}
492 # Decompress with chosen tool. We assume that tool changes name e.g.
493 # from 'name.gz' to 'name'.
494 ${cmd} "${initdir}${src}"
495 done
498 # It's similar to above, but if file is not compressed, performs standard
499 # install.
500 # $@ = list of files
501 inst_opt_decompress() {
502 local src
504 for src in $@
506 inst_decompress "${src}" || inst "${src}"
507 done
510 check_module_deps() {
511 local moddir dep ret
512 # if we are already set to be loaded, we do not have to be checked again.
513 strstr " $mods_to_load " " $1 " && return
514 strstr " $omit_dracutmodules " " $1 " && return 1
515 # turn a module name into a directory, if we can.
516 moddir=$(echo ${dracutbasedir}/modules.d/??${1})
517 [[ -d $moddir && -x $moddir/install ]] || return 1
518 # if we do not have a check script, we are unconditionally included
519 if [[ -x $moddir/check ]]; then
520 "$moddir/check"
521 ret=$?
522 # a return value of 255 = load module only as a dependency.
523 ((ret==0||ret==255)) || return 1
524 for dep in $("$moddir/check" -d); do
525 check_module_deps "$dep" && continue
526 dwarning "Dependency $mod failed."
527 return 1
528 done
530 mods_to_load+=" $1 "
533 should_source_module() {
534 local dep
535 local ret
536 if [[ $kernel_only = yes ]]; then
537 [[ -x $1/installkernel ]] && return 0
538 return 1
540 [[ -x $1/install ]] || [[ -x $1/installkernel ]] || return 1
541 [[ -x $1/check ]] || return 0
542 "$1/check" $hostonly || continue
543 for dep in $("$1/check" -d); do
544 check_module_deps "$dep" && continue
545 dwarning "Cannot load dracut module \"$mod\", dependencies failed."
546 return 1
547 done
550 check_modules() {
551 local modcheck;
552 local mod;
553 for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
554 local mod=${moddir##*/}; mod=${mod#[0-9][0-9]}
555 # If we are already scheduled to be loaded, no need to check again.
556 strstr " $mods_to_load " " $mod " && continue
557 # This should never happen, but...
558 [[ -d $moddir ]] || continue
559 strstr " $omit_dracutmodules " " $mod " && continue
561 if ! strstr " $dracutmodules $add_dracutmodules " " $mod "; then
562 # module not in our list
563 if [[ $dracutmodules = all ]]; then
564 # check, if we can install this module
565 should_source_module "$moddir" || continue
566 else
567 # skip this module
568 continue
570 else
571 if [ -x "$moddir/check" ] \
572 && "$moddir/check" -d > /dev/null 2>&1; then
573 check_module_deps "$mod" || {
574 dwarning "Cannot load dracut module \"$mod\", dependencies failed."
575 continue
580 mods_to_load+=" $mod "
581 done
583 modcheck=$add_dracutmodules
584 [[ $dracutmodules != all ]] && modcheck="$m $dracutmodules"
585 for mod in $modcheck; do
586 strstr " $mods_to_load " " $mod " && continue
587 strstr " $omit_dracutmodules " " $mod " && continue
588 dwarning "Dracut module \"$mod\" cannot be found."
589 done
592 # Install a single kernel module along with any firmware it may require.
593 # $1 = full path to kernel module to install
594 install_kmod_with_fw() {
595 local modname=${1##*/} fwdir found
596 modname=${modname%.ko*}
597 inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" || \
598 return 0 # no need to go further if the module is already installed
599 for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do
600 found=''
601 for fwdir in $fw_dir; do
602 if [[ -d $fwdir && -f $fwdir/$fw ]]; then
603 inst_simple "$fwdir/$fw" "/lib/firmware/$fw"
604 found=yes
606 done
607 if [[ $found != yes ]]; then
608 dinfo "Possible missing firmware \"${fw}\" for kernel module \"${mod}.ko\""
610 done
613 # Do something with all the dependencies of a kernel module.
614 # Note that kernel modules depend on themselves using the technique we use
615 # $1 = function to call for each dependency we find
616 # It will be passed the full path to the found kernel module
617 # $2 = module to get dependencies for
618 # rest of args = arguments to modprobe
619 for_each_kmod_dep() {
620 local func=$1 kmod=$2 cmd modpapth options
621 shift 2
622 modprobe "$@" --ignore-install --show-depends $kmod 2>/dev/null | \
623 while read cmd modpath options; do
624 [[ $cmd = insmod ]] || continue
625 $func $modpath
626 done
629 # filter kernel modules to install certain modules that meet specific
630 # requirements.
631 # $1 = function to call with module name to filter.
632 # This function will be passed the full path to the module to test.
633 # The behaviour of this function can vary depending on whether $hostonly is set.
634 # If it is, we will only look at modules that are already in memory.
635 # If it is not, we will look at all kernel modules
636 # This function returns the full filenames of modules that match $1
637 filter_kernel_modules () (
638 if ! [[ $hostonly ]]; then
639 filtercmd='find "$srcmods/kernel/drivers" -name "*.ko" -o -name "*.ko.gz"'
640 else
641 filtercmd='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename -k $kernel'
643 for modname in $(eval $filtercmd); do
644 case $modname in
645 *.ko)
646 "$1" "$modname" && echo "$modname"
648 *.ko.gz)
649 gzip -dc "$modname" > $initdir/$$.ko
650 $1 $initdir/$$.ko && echo "$modname"
651 rm -f $initdir/$$.ko
653 esac
654 done
657 # install kernel modules along with all their dependencies.
658 instmods() {
659 [[ $no_kernel = yes ]] && return
660 local mod mpargs modpath modname cmd moddirname
661 while (($# > 0)); do
662 mod=${1%.ko*}
663 case $mod in
664 =*) # This introduces 2 incompatible meanings for =* arguments
665 # to instmods. We need to decide which one to keep.
666 if [[ $mod = =ata && -f $srcmods/modules.block ]] ; then
667 instmods $mpargs $(egrep 'ata|ahci' "${srcmods}/modules.block")
668 elif [ -f $srcmods/modules.${mod#=} ]; then
669 instmods $mpargs $(cat ${srcmods}/modules.${mod#=} )
670 else
671 instmods $mpargs $(find "$srcmods" -path "*/${mod#=}/*")
674 --*)
675 mod=${mod##*/}
676 mpargs+=" $mod";;
677 i2o_scsi)
678 # Must never run this diagnostic-only module
679 shift; continue;
682 mod=${mod##*/}
683 # if we are already installed, skip this module and go on
684 # to the next one.
685 [[ -f $initdir/$1 ]] && { shift; continue; }
686 # If we are building a host-specific initramfs and this
687 # module is not already loaded, move on to the next one.
688 [[ $hostonly ]] && ! grep -qe "\<${mod//-/_}\>" /proc/modules && \
689 ! echo $add_drivers | grep -qe "\<${mod}\>" && {
690 shift; continue;
693 # We use '-d' option in modprobe only if modules prefix path
694 # differs from default '/'. This allows us to use Dracut with
695 # old version of modprobe which doesn't have '-d' option.
696 moddirname=${srcmods%%/lib/modules/*}
697 [[ -n ${moddirname} ]] && moddirname="-d ${moddirname}/"
699 # ok, load the module, all its dependencies, and any firmware
700 # it may require
701 for_each_kmod_dep install_kmod_with_fw $mod \
702 --set-version $kernel ${moddirname}
704 esac
705 shift
706 done
709 # vim:ts=8:sw=4:sts=4:et