From phk@critter.freebsd.dk  Thu Oct  4 19:01:44 2007
Return-Path: <phk@critter.freebsd.dk>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 61ED516A418
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  4 Oct 2007 19:01:44 +0000 (UTC)
	(envelope-from phk@critter.freebsd.dk)
Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222])
	by mx1.freebsd.org (Postfix) with ESMTP id 28CFC13C448
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  4 Oct 2007 19:01:43 +0000 (UTC)
	(envelope-from phk@critter.freebsd.dk)
Received: from critter.freebsd.dk (critter.freebsd.dk [192.168.48.2])
	by phk.freebsd.dk (Postfix) with ESMTP id 2F95B17104
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  4 Oct 2007 19:01:42 +0000 (UTC)
Received: from critter.freebsd.dk (localhost [127.0.0.1])
	by critter.freebsd.dk (8.14.1/8.14.1) with ESMTP id l94J1jDl001204
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 4 Oct 2007 19:01:45 GMT
	(envelope-from phk@critter.freebsd.dk)
Received: (from phk@localhost)
	by critter.freebsd.dk (8.14.1/8.14.1/Submit) id l94DPKX8002240;
	Thu, 4 Oct 2007 13:25:20 GMT
	(envelope-from phk)
Message-Id: <200710041325.l94DPKX8002240@critter.freebsd.dk>
Date: Thu, 4 Oct 2007 13:25:20 GMT
From: Poul-Henning Kamp <phk@critter.freebsd.dk>
Reply-To: Poul-Henning Kamp <phk@critter.freebsd.dk>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: lack of fsck_cd9660 prevents mounting iso images with mdconfig_md%d
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         116931
>Category:       conf
>Synopsis:       lack of fsck_cd9660 prevents mounting iso images with mdconfig_md%d (with workaround)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-fs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 04 19:10:01 GMT 2007
>Closed-Date:    
>Last-Modified:  Tue Jan  3 09:50:09 UTC 2012
>Originator:     Poul-Henning Kamp
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD critter.freebsd.dk 7.0-CURRENT FreeBSD 7.0-CURRENT #0: Wed Sep 26 15:32:58 UTC 2007 root@critter.freebsd.dk:/usr/obj/freebsd/src/sys/C5 i386


	
>Description:
	

	Trying to mount an ISO image using the mdconfig_md%d= facility in
	/etc/rc.conf does not work because we do not have a fsck_cd9660
	program.
	
>How-To-Repeat:

	Add to /etc/rc.conf
		mdconfig_md0="-t vnode -o readonly -f /some/image.iso"
	Add to /etc/fstab
		/dev/md0     /cdrom     cd9660  ro,noauto       0       0

	mkdir -p /cdrom

	sh /etc/rc.d/mdconfig2 start
		
>Fix:

	The correct fix is to know if the filesystem can be fsck'ed or not
	but a workaround is to symlink fsck_cd9660 to /usr/bin/true

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: brucec 
Responsible-Changed-When: Sat Apr 3 10:51:07 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=116931 

From: Andriy Gapon <avg@icyb.net.ua>
To: bug-followup@FreeBSD.org, phk@critter.freebsd.dk
Cc:  
Subject: Re: conf/116931: lack of fsck_cd9660 prevents mounting iso images
 with mdconfig_md%d (with workaround)
Date: Sat, 03 Apr 2010 14:08:16 +0300

 Somewhat tangential: etc/rc.d/root shouldn't attempt to re-mount root filesystem
 read-write if it's known to be strictly read-only, e.g. cd9660.
 
 -- 
 Andriy Gapon

From: Mikolaj Golub <to.my.trociny@gmail.com>
To: bug-followup@FreeBSD.org
Cc: freebsd-fs@FreeBSD.org, Poul-Henning Kamp <phk@critter.freebsd.dk>
Subject: Re: conf/116931: lack of fsck_cd9660 prevents mounting iso images with mdconfig_md%d (with workaround)
Date: Sat, 03 Apr 2010 20:05:25 +0300

 --=-=-=
 
 We could keep the list of fs types that should not be fsck'ed (like in the
 first patch below) or could check the pass number in /etc/fstab (the second
 patch).
 
 -- 
 Mikolaj Golub
 
 
 --=-=-=
 Content-Type: text/x-diff
 Content-Disposition: attachment; filename=mdconfig2.fsck_skip_fs.patch
 
 --- etc/rc.d/mdconfig2.orig	2010-04-03 18:39:43.000000000 +0300
 +++ etc/rc.d/mdconfig2	2010-04-03 19:38:07.000000000 +0300
 @@ -39,6 +39,19 @@
  start_precmd='[ -n "${_mdconfig2_list}" ]'
  required_modules="geom_md:g_md"
  
 +fsck_skip_fs="cd9660 udf"
 +
 +in_list()
 +{
 +	local _x _list _i
 +	_x=$1
 +	_list=$2
 +	for _i in ${_list}; do
 +		[ "${_x}" = "${_i}" ] && return 0
 +	done
 +	return 1
 +}
 +
  is_readonly()
  {
  	local _mp _ret
 @@ -95,10 +108,13 @@
  		for _i in `df ${_file} 2>/dev/null`; do _fs=${_i}; done
  	fi
  
 +	_fs_type=`awk -v d="${_dev}" '$1 == d {print $3; exit}' /etc/fstab`
 +
  	# Debugging help.
  	debug "${_md} config: ${_config}"
  	debug "${_md} type: ${_type}"
  	debug "${_md} dev: ${_dev}"
 +	debug "${_md} fs_type: ${_fs_type}"
  	debug "${_md} file: ${_file}"
  	debug "${_md} fs: ${_fs}"
  	debug "${_md} owner: ${_owner}"
 @@ -109,7 +125,7 @@
  
  mdconfig2_start()
  {
 -	local _md _fs _mp _mounted _dev _config _type _file _owner _perms _files _populate _fsck_cmd _i
 +	local _md _fs _mp _mounted _dev _config _type _file _owner _perms _files _populate _fsck_cmd _fs_type _i
  
  	for _md in ${_mdconfig2_list}; do
  		init_variables ${_md}
 @@ -136,8 +152,9 @@
  				echo "Creating ${_md} device failed, moving on."
  				continue
  			fi
 -			# Skip fsck for uzip devices.
 -			if [ "${_file}" != "${_file%.uzip}" ]; then
 +			# Skip fsck for uzip devices and for fs types listed in fsck_skip_fs
 +			if [ "${_file}" != "${_file%.uzip}" ] || 
 +			   in_list "${_fs_type}" "${fsck_skip_fs}"; then
  				_fsck_cmd=":"
  			elif checkyesno background_fsck; then
  				_fsck_cmd="fsck -F"
 
 --=-=-=
 Content-Type: text/x-diff
 Content-Disposition: inline; filename=mdconfig2.check_pass.patch
 
 --- etc/rc.d/mdconfig2.orig	2010-04-03 18:39:43.000000000 +0300
 +++ etc/rc.d/mdconfig2	2010-04-03 19:59:15.000000000 +0300
 @@ -136,8 +136,9 @@
  				echo "Creating ${_md} device failed, moving on."
  				continue
  			fi
 -			# Skip fsck for uzip devices.
 -			if [ "${_file}" != "${_file%.uzip}" ]; then
 +			# Skip fsck for uzip devices or that have zero pass in fstab
 +			if [ "${_file}" != "${_file%.uzip}" ] ||
 +			   `awk -v d="${_dev}" '$1 == d {exit $6}' /etc/fstab`; then
  				_fsck_cmd=":"
  			elif checkyesno background_fsck; then
  				_fsck_cmd="fsck -F"
 
 --=-=-=--

From: Garrett Cooper <yanegomi@gmail.com>
To: bug-followup@FreeBSD.org, phk@critter.freebsd.dk
Cc:  
Subject: Re: conf/116931: lack of fsck_cd9660 prevents mounting iso images
 with mdconfig_md%d (with workaround)
Date: Tue, 3 Jan 2012 01:41:28 -0800

     The attached patch looks ok. The only suggestion that I have is
 that since you're grabbing the fs field from /etc/fstab, instead of
 keeping a blacklist, I would just use command -v; example:
 
 $ command -v fsck_ufs; echo $?
 /sbin/fsck_ufs
 0
 $ command -v fsck_cd9660; echo $?
 1
 $
 
     This would reduce the number of needed special cases in the mdconfig script.
 Thanks!
 -Garrett
>Unformatted:
