From owner-freebsd-arch@FreeBSD.ORG Fri Dec 3 21:22:57 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A968316A4CE for ; Fri, 3 Dec 2004 21:22:57 +0000 (GMT) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 039C543D55 for ; Fri, 3 Dec 2004 21:22:57 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.13.1/8.13.1) with ESMTP id iB3LMuqV026128 for ; Fri, 3 Dec 2004 22:22:56 +0100 (CET) (envelope-from phk@critter.freebsd.dk) To: arch@freebsd.org From: "Poul-Henning Kamp" Date: Fri, 03 Dec 2004 22:22:56 +0100 Message-ID: <26127.1102108976@critter.freebsd.dk> Sender: phk@critter.freebsd.dk Subject: [HEADSUP] omount/nmount migration and rootfs mounting X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Dec 2004 21:22:57 -0000 Ok, here is the big picture: All filesystems get a ->vfs_mount() which does the job. Filesystems which have a ->vfs_omount() looses it and gets a ->vfs_cmount() instead which after pulling compat args in calls the nmount() stuff. Here is my prototype for ffs: +static int +ffs_cmount(char *path, void *data, int flags, struct thread *td) +{ + struct ufs_args args; + struct iovec v[10]; + int error; + + if (data == NULL) + return (EINVAL); + error = copyin(data, &args, sizeof args); + if (error) + return (error); + + v[0].iov_base = "fstype"; + v[0].iov_len = strlen(v[0].iov_base) + 1; + v[1].iov_base = "ufs"; + v[1].iov_len = strlen(v[1].iov_base) + 1; + + v[2].iov_base = "fspath"; + v[2].iov_len = strlen(v[2].iov_base) + 1; + v[3].iov_base = path; + v[3].iov_len = strlen(v[3].iov_base) + 1; + + v[4].iov_base = "from"; + v[4].iov_len = strlen(v[4].iov_base) + 1; + v[5].iov_base = args.fspec; + v[5].iov_len = strlen(v[5].iov_base) + 1; + + v[6].iov_base = "export"; + v[6].iov_len = strlen(v[6].iov_base) + 1; + v[7].iov_base = &args.export; + v[7].iov_len = sizeof(args.export); + + v[8].iov_base = NULL; + v[8].iov_len = 0; + + error = kernel_mount(v, 8, flags); + + return (error); +} Root mounting will happen the following way: create a mountpoint. devfs->vfs_mount() on it. set rootdir for proc0 create symlink: /dev -> / Mount real root filesystem as / using normal ->vfs_mount() method. (filesystem contains no magic for this) Surgically move the devfs mount from / to /dev in the new rootfs. Keep an eye on p4:phk_bufwork, it works for ffs and nfs already. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.