From owner-freebsd-rc@FreeBSD.ORG Sat Apr 17 19:28:42 2010 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2F6F0106566C for ; Sat, 17 Apr 2010 19:28:42 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 5F6A88FC08 for ; Sat, 17 Apr 2010 19:28:40 +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 WAA20163 for ; Sat, 17 Apr 2010 22:16:31 +0300 (EEST) (envelope-from avg@icyb.net.ua) Received: from localhost.topspin.kiev.ua ([127.0.0.1]) by porto.topspin.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1O3DVH-000EWf-63 for freebsd-rc@freebsd.org; Sat, 17 Apr 2010 22:16:31 +0300 Message-ID: <4BCA090E.1040403@icyb.net.ua> Date: Sat, 17 Apr 2010 22:16:30 +0300 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.24 (X11/20100321) MIME-Version: 1.0 To: freebsd-rc@freebsd.org X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: rc.d/root: handle filesystems with r/o support only X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Apr 2010 19:28:42 -0000 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