• 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-2021
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_SETUP=setup
15TST_TESTFUNC=do_test
16
17. tst_test.sh
18
19MAX_DEPTH=3
20MAX_DIRS=4
21
22setup()
23{
24	if tst_cmd_available mkisofs; then
25		MKISOFS_CMD="mkisofs"
26	elif tst_cmd_available genisoimage; then
27		MKISOFS_CMD="genisoimage"
28	else
29		tst_brk TCONF "please install mkisofs or genisoimage"
30	fi
31}
32
33gen_fs_tree()
34{
35	local cur_path="$1"
36	local cur_depth="$2"
37	local i new_path
38
39	[ "$cur_depth" -gt "$MAX_DEPTH" ] && return
40
41	for i in $(seq 1 $MAX_DIRS); do
42		new_path="$cur_path/subdir_$i"
43		mkdir -p "$new_path"
44		ROD_SILENT dd if=/dev/urandom of="$new_path/file" bs=1024 count=100
45		gen_fs_tree "$new_path" $((cur_depth + 1))
46	done
47}
48
49do_test()
50{
51	local mnt_point="$PWD/mnt"
52	local make_file_sys_dir="$PWD/files"
53	local mkisofs_opt mount_opt
54
55	mkdir -p -m 777 $mnt_point
56	mkdir -p $make_file_sys_dir
57
58	# Generated directories and files
59	mkdir -p $make_file_sys_dir
60	gen_fs_tree "$make_file_sys_dir" 1
61
62	# Make ISO9660 file system with different options.
63	# Mount the ISO9660 file system with different mount options.
64	for mkisofs_opt in \
65		" " \
66		"-J" \
67		"-hfs -D" \
68		" -R " \
69		"-R -J" \
70		"-f -l -D -J -allow-leading-dots -R" \
71		"-allow-lowercase -allow-multidot -iso-level 3 -f -l -D -J -allow-leading-dots -R"
72	do
73		rm -f isofs.iso
74		EXPECT_PASS $MKISOFS_CMD -o isofs.iso -quiet $mkisofs_opt $make_file_sys_dir 2\> /dev/null \
75			|| continue
76
77		for mount_opt in \
78			"loop" \
79			"loop,norock" \
80			"loop,nojoliet" \
81			"loop,block=512,unhide" \
82			"loop,block=1024,cruft" \
83			"loop,block=2048,nocompress" \
84			"loop,check=strict,map=off,gid=bin,uid=bin" \
85			"loop,check=strict,map=acorn,gid=bin,uid=bin" \
86			"loop,check=relaxed,map=normal" \
87			"loop,block=512,unhide,session=2"
88		do
89			EXPECT_PASS mount -t iso9660 -o $mount_opt isofs.iso $mnt_point \
90				|| continue
91
92			EXPECT_PASS ls -lR $mnt_point \> /dev/null
93			EXPECT_PASS_BRK umount $mnt_point
94
95			tst_res TPASS "mount/umount with \"$mount_opt\" options"
96		done
97	done
98}
99
100tst_run
101