我调试脚本来为 Debian 8.2 安装西门子 NX 10 应用程序,并收到警告:
无法确定包含 /usr/ugs100 的文件系统,
空间计算可能不正确。
脚本的源代码:ug_安装(太大,无法在此发布)。生成此消息的代码片段,以及它调用的两个函数和其他相关函数:
Init_fs_arrays() # Initializes the File System array.
{ # RKB Thu Jan 31 22:39:57 PST 1991
# RKB Updated: Sep 28 15:26:28 PDT 1992
# RKB updtd: Jul 6 22:51 93 V10.1.1 make generic.
# RKB updtd: Mar 7 18:34 94 V103P2E streamline, rm "set --".
# RKB updtd: Mar 9 22:34 94 V103P2E rm test -s for FS_FILE, just wait f
# RKB updtd: Wed Apr 20 2005 NX4P11 Added Linux support.
# This function initializes the FS_NAME & FS_FREE
# arrays based on the contents of $FS_FILE
FS_FILE="$UGS_TMP/filesystem_info" # File name to read the results from.
$VECHO "${MSG}Initializing File System array ..."
wait $SIZE_FS_PID # in case the file is not ready, wait for the bg job.
I=0 # Initialize the index
# Linux
# cat $FS_FILE | while read NAME SPACE ; do
# Linux cant do "cat file | while read" "must use while read done < file
while read NAME SPACE ; do
FS_NAME[$I]=$NAME ; FS_FREE[$I]=${SPACE:=0} ; FS_NEEDED[$I]=0
((I+=1)) # Increment the index.
done < $FS_FILE
return 0
} # End of Init_fs_arrays
Get_fsindex() # Get the index number to supplied file system name.
{ # RKB Mon Jan 21 21:00 91
# RKB Mar 8 23:59 94 V103P2E chg to use while loop not grep -n. faster.
: ${FS_NAME[*]:?} # Required variable internal check.
: ${1:?} # Required arg internal check.
I=0 # Init the index counter
# Loop thru the FS_NAME array to get index number for filesystem in arg
while [ $I -le ${#FS_NAME[*]} ] ; do
[ $1 = "${FS_NAME[$I]}" ] && { echo $I ; return 0; }
((I+=1)) # Increment the index.
done
unset FS_INDEX ;
return 1 # Didn't find the file system.
} # End of Get_fsindex
Get_fs_info() # Returns filesystem info for the directory argument.
{
# Requires 2 global variables.
: ${DF_CMD:?cmd var must be set to use this function. }
: ${AWK_CMD:?cmd var must be set to use this function. }
# Requires 2 args; a switch and a target directory.
TARGET=$2 ; : ${TARGET:?} # Internal check
#
# If dir doesn't exist, check parent.
while [ ! -d $TARGET ] ; do
[ -f $TARGET ] && { # error if a file exists.
print "${ERR}directory name expected. file exists: $TARGET" >&2
return 1 ;
}
TARGET=`dirname $TARGET`
done
#
# Do appropriate action based on the switch. The options are:
# use -sp to get free space, -fs for real filesystem name, -mnt returns
# the mount point and -nfs returns true if the filesystem is NFS mounted,
# and false if it's not.
#
# Set machine specific number for the df field containing filesystem.
[ $MACHINE = IRIX -o $MACHINE = IRIX64 ] && N=6 || N=5
case $1 in
-fs*) $DF_CMD $TARGET | tr "\012" " " | $AWK_CMD '{print $(NF-$N)}' ;;
-mnt*) $DF_CMD $TARGET | tr "\012" " " | $AWK_CMD '{print $NF}' ;;
-nfs) $DF_CMD $TARGET | tr "\012" " " | $AWK_CMD '{print $(NF-$N)}' | grep ":/" >$NULL || return 1 ;;
-sp*) $DF_CMD $TARGET | tail -1 | $AWK_CMD '{printf("%d",$(NF-2))}' ;;
esac
return 0
} # Get_fs_info
…
SPACE_REQUIRED_KB=0
# Get the mount point for BASE_DIR.
BASE_MNT_PT=`Get_fs_info -mnt $BASE_DIR` || {
print "${WARN}Could not determine mount point for $BASE_DIR
\r\tFile System information may be incorrect.
} # Shouldn't be any problem, but just to be safe.
FS_INDEX=`Get_fsindex $BASE_MNT_PT` || {
print "${WARN}Could not determine filesystem containing $BASE_DI
\r\tspace calculations may be incorrect. "
} # Shouldn't be any problem, but just to be safe.
#
临时文件的内容/tmp/filesystem_info
:
/dev 10240
/run 1621732
/dev/shm 4031816
/run/lock 5116
/dev/mqueue 0
/dev/hugepages 0
/boot/efi 72815
/run/user/116 815520
/run/user/1000 815484
- 该
Get_fs_info
函数返回吗? - 如何理解
filesystem_info
文件的内容?