nfsd: Fix overflow causing non-working mounts on 1 TB machines
[linux/fpc-iii.git] / scripts / depmod.sh
blobe083bcae343f3e71290e433b7fd50861fd819ca4
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
4 # A depmod wrapper used by the toplevel Makefile
6 if test $# -ne 2; then
7 echo "Usage: $0 /sbin/depmod <kernelrelease>" >&2
8 exit 1
9 fi
10 DEPMOD=$1
11 KERNELRELEASE=$2
13 if ! test -r System.map ; then
14 echo "Warning: modules_install: missing 'System.map' file. Skipping depmod." >&2
15 exit 0
18 if [ -z $(command -v $DEPMOD) ]; then
19 echo "Warning: 'make modules_install' requires $DEPMOD. Please install it." >&2
20 echo "This is probably in the kmod package." >&2
21 exit 0
24 # older versions of depmod require the version string to start with three
25 # numbers, so we cheat with a symlink here
26 depmod_hack_needed=true
27 tmp_dir=$(mktemp -d ${TMPDIR:-/tmp}/depmod.XXXXXX)
28 mkdir -p "$tmp_dir/lib/modules/$KERNELRELEASE"
29 if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev/null; then
30 if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \
31 -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then
32 depmod_hack_needed=false
35 rm -rf "$tmp_dir"
36 if $depmod_hack_needed; then
37 symlink="$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE"
38 ln -s "$KERNELRELEASE" "$symlink"
39 KERNELRELEASE=99.98.$KERNELRELEASE
42 set -- -ae -F System.map
43 if test -n "$INSTALL_MOD_PATH"; then
44 set -- "$@" -b "$INSTALL_MOD_PATH"
46 "$DEPMOD" "$@" "$KERNELRELEASE"
47 ret=$?
49 if $depmod_hack_needed; then
50 rm -f "$symlink"
53 exit $ret