• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) International Business Machines Corp., 2003
4# Copyright (c) Linux Test Project, 2016-2024
5# Written by Prakash Narayana (prakashn@us.ibm.com)
6# and Michael Reed (mreed10@us.ibm.com)
7#
8# Test isofs on Linux system.
9# It makes ISO9660 file system with different options and also
10# mounts ISO9660 file system with different mount options.
11
12TST_NEEDS_CMDS="mount umount"
13TST_NEEDS_TMPDIR=1
14TST_TESTFUNC=do_test
15TST_CNT=3
16TST_SETUP="setup"
17
18MAX_DEPTH=3
19MAX_DIRS=4
20
21TEST_USER='nobody'
22
23setup()
24{
25	TEST_GROUP="$(id -g -n $TEST_USER)"
26	[ "$TEST_GROUP" ] || TEST_GROUP="$TEST_USER"
27}
28
29gen_fs_tree()
30{
31	local cur_path="$1"
32	local cur_depth="$2"
33	local i new_path
34
35	[ "$cur_depth" -gt "$MAX_DEPTH" ] && return
36
37	for i in $(seq 1 $MAX_DIRS); do
38		new_path="$cur_path/subdir_$i"
39		mkdir -p "$new_path"
40		ROD_SILENT dd if=/dev/urandom of="$new_path/file" bs=1024 count=100
41		gen_fs_tree "$new_path" $((cur_depth + 1))
42	done
43}
44
45do_test()
46{
47	local mnt_point="$PWD/mnt"
48	local make_file_sys_dir="$PWD/files"
49	local mkisofs_opt mount_opt
50
51	case $1 in
52		1) MKISOFS_CMD="mkisofs"
53			HFSOPT="-hfs -D"
54			GREPOPT="mkisofs";;
55		2) MKISOFS_CMD="genisoimage"
56			HFSOPT="-hfsplus -D -hfs -D"
57			GREPOPT="genisoimage";;
58		3) MKISOFS_CMD="xorrisofs"
59			HFSOPT="-hfsplus -D"
60			GREPOPT="xorriso";;
61	esac
62
63	if ! tst_cmd_available $MKISOFS_CMD; then
64		tst_res TCONF "Missing '$MKISOFS_CMD'"
65		return
66	fi
67
68	if ! $MKISOFS_CMD 2>&1 | head -n 2 | grep -q "$GREPOPT"; then
69		tst_res TCONF "'$MKISOFS_CMD' is a symlink to another tool"
70		return
71	fi
72
73	tst_res TINFO "Testing $MKISOFS_CMD"
74
75	mkdir -p -m 777 $mnt_point
76	mkdir -p $make_file_sys_dir
77
78	mkdir -p $make_file_sys_dir
79	gen_fs_tree "$make_file_sys_dir" 1
80
81	# Make ISO9660 file system with different options.
82	# Mount the ISO9660 file system with different mount options.
83	for mkisofs_opt in \
84		" " \
85		"-J" \
86		"$HFSOPT" \
87		" -R " \
88		"-R -J" \
89		"-f -l -D -J -allow-leading-dots -R" \
90		"-allow-lowercase -allow-multidot -iso-level 3 -f -l -D -J \
91			-allow-leading-dots -R"
92	do
93		rm -f isofs.iso
94		EXPECT_PASS $MKISOFS_CMD -o isofs.iso -quiet $mkisofs_opt \
95			$make_file_sys_dir 2\> /dev/null || continue
96
97		for mount_opt in \
98			"loop" \
99			"loop,norock" \
100			"loop,nojoliet" \
101			"loop,block=512,unhide" \
102			"loop,block=1024,cruft" \
103			"loop,block=2048,nocompress" \
104			"loop,check=strict,map=off,gid=$TEST_GROUP,uid=$TEST_USER" \
105			"loop,check=strict,map=acorn,gid=$TEST_GROUP,uid=$TEST_USER" \
106			"loop,check=relaxed,map=normal" \
107			"loop,block=512,unhide,session=2"
108		do
109			EXPECT_PASS mount -t iso9660 -o $mount_opt isofs.iso $mnt_point \
110				|| continue
111
112			EXPECT_PASS ls -lR $mnt_point \> /dev/null
113			EXPECT_PASS_BRK umount $mnt_point
114
115			tst_res TPASS "mount/umount with \"$mount_opt\" options"
116		done
117	done
118}
119
120. tst_test.sh
121tst_run
122