From owner-freebsd-hackers@FreeBSD.ORG Thu Apr 29 05:49:11 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0F3801065670 for ; Thu, 29 Apr 2010 05:49:11 +0000 (UTC) (envelope-from avg@freebsd.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 432C08FC14 for ; Thu, 29 Apr 2010 05:49:09 +0000 (UTC) Received: from porto.topspin.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id IAA28099 for ; Thu, 29 Apr 2010 08:49:08 +0300 (EEST) (envelope-from avg@freebsd.org) Received: from localhost.topspin.kiev.ua ([127.0.0.1]) by porto.topspin.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1O7McW-0008BQ-Ao for freebsd-hackers@FreeBSD.org; Thu, 29 Apr 2010 08:49:08 +0300 Message-ID: <4BD91DD3.90108@freebsd.org> Date: Thu, 29 Apr 2010 08:49:07 +0300 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.24 (X11/20100321) MIME-Version: 1.0 To: freebsd-hackers@freebsd.org X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [Fwd: rc.d/root: handle filesystems with r/o support only] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Apr 2010 05:49:11 -0000 There was no excitement over the proposed patch on rc@, perhaps more luck here :-) -------- Original Message -------- Subject: rc.d/root: handle filesystems with r/o support only Date: Sat, 17 Apr 2010 22:16:30 +0300 From: Andriy Gapon To: freebsd-rc@freebsd.org Could you please review the following patch? The idea is to not try to remount root R/W if root filesystem supports only R/O. For example, cd9660. This should make life easier for live CDs that use standard rc startup. Currently one has to either put a root fs entry into fstab (and thus guess root device name, e.g. cd0 vs acd0) or to specify root_rw_mount="NO" in rc.conf. This change attempts to guess that automatically. I think that things like ro_fs_list, in_list and is_readonly_fs could be shared with other rc scripts. E.g. see http://www.freebsd.org/cgi/query-pr.cgi?pr=conf/116931 P.S. sorry if the code style and structure differs from conventions. --- a/etc/rc.d/root +++ b/etc/rc.d/root @@ -13,11 +13,54 @@ name="root" start_cmd="root_start" stop_cmd=":" +ro_fs_list="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_fs() +{ + local _arg _ret + + _arg="$1" ; shift + _ret=`mount -p | while read _dev _mp _type _rest; do + [ $_mp = "$_arg" ] || continue + echo $_type + break + done` + + if [ -z "${_ret}" ]; then + warn "root filesystem not found" + return 1 + fi + if in_list "${_ret}" "${ro_fs_list}"; then + info "read-only root filesystem type: ${_ret}" + return 0 + else + info "read-write root filesystem type: ${_ret}" + return 1 + fi +} + root_start() { # root normally must be read/write, but if this is a BOOTP NFS # diskless boot it does not have to be. # + + if is_readonly_fs '/' ; then + root_rw_mount="NO" + fi + case ${root_rw_mount} in [Nn][Oo] | '') ;; -- Andriy Gapon -- Andriy Gapon