FreeBSD kernel kern code
vfs_mountroot.c File Reference
#include "opt_rootdevname.h"
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/cons.h>
#include <sys/fcntl.h>
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mdioctl.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/filedesc.h>
#include <sys/reboot.h>
#include <sys/sbuf.h>
#include <sys/stat.h>
#include <sys/syscallsubr.h>
#include <sys/sysproto.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/sysent.h>
#include <sys/systm.h>
#include <sys/vnode.h>
#include <geom/geom.h>
Include dependency graph for vfs_mountroot.c:

Go to the source code of this file.

Data Structures

struct  root_hold_token
 

Macros

#define CC_WHITESPACE   -1
 
#define CC_NONWHITESPACE   -2
 
#define PE_EOF   -1
 
#define PE_EOL   -2
 
#define ERRMSGL   255
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static int parse_mount (char **)
 
static struct mntargparse_mountroot_options (struct mntarg *, const char *)
 
 MTX_SYSINIT (root_holds,&root_holds_mtx,"root_holds", MTX_DEF)
 
static LIST_HEAD (root_hold_token)
 
 TUNABLE_INT ("vfs.mountroot.timeout",&root_mount_timeout)
 
struct root_hold_tokenroot_mount_hold (const char *identifier)
 
void root_mount_rel (struct root_hold_token *h)
 
int root_mounted (void)
 
void root_mount_wait (void)
 
static void set_rootvnode (void)
 
static int vfs_mountroot_devfs (struct thread *td, struct mount **mpp)
 
static int vfs_mountroot_shuffle (struct thread *td, struct mount *mpdevfs)
 
static __inline int parse_peek (char **conf)
 
static __inline void parse_poke (char **conf, int c)
 
static __inline void parse_advance (char **conf)
 
static int parse_skipto (char **conf, int mc)
 
static int parse_token (char **conf, char **tok)
 
static void parse_dir_ask_printenv (const char *var)
 
static int parse_dir_ask (char **conf)
 
static int parse_dir_md (char **conf)
 
static int parse_dir_onfail (char **conf)
 
static int parse_dir_timeout (char **conf)
 
static int parse_directive (char **conf)
 
static int parse_mount_dev_present (const char *dev)
 
static int vfs_mountroot_parse (struct sbuf *sb, struct mount *mpdevfs)
 
static void vfs_mountroot_conf0 (struct sbuf *sb)
 
static int vfs_mountroot_readconf (struct thread *td, struct sbuf *sb)
 
static void vfs_mountroot_wait (void)
 
void vfs_mountroot (void)
 

Variables

struct vnode * rootvnode
 
char * rootdevnames [2] = {NULL, NULL}
 
struct mtx root_holds_mtx
 
static enum action root_mount_onfail = A_CONTINUE
 
static int root_mount_mddev
 
static int root_mount_complete
 
static int root_mount_timeout = 3
 

Macro Definition Documentation

#define CC_NONWHITESPACE   -2

Definition at line 368 of file vfs_mountroot.c.

Referenced by parse_skipto(), parse_token(), and vfs_mountroot_parse().

#define CC_WHITESPACE   -1

Definition at line 367 of file vfs_mountroot.c.

Referenced by parse_skipto(), and parse_token().

#define ERRMSGL   255

Definition at line 670 of file vfs_mountroot.c.

Referenced by parse_mount().

#define PE_EOF   -1

Definition at line 371 of file vfs_mountroot.c.

Referenced by parse_skipto().

#define PE_EOL   -2

Definition at line 372 of file vfs_mountroot.c.

Referenced by parse_skipto(), and vfs_mountroot_parse().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static LIST_HEAD ( root_hold_token  )
static

Definition at line 108 of file vfs_mountroot.c.

MTX_SYSINIT ( root_holds  ,
root_holds_mtx,
"root_holds"  ,
MTX_DEF   
)
static __inline void parse_advance ( char **  conf)
static

Definition at line 389 of file vfs_mountroot.c.

Referenced by parse_mount(), parse_skipto(), and vfs_mountroot_parse().

Here is the caller graph for this function:

static int parse_dir_ask ( char **  conf)
static

Definition at line 456 of file vfs_mountroot.c.

References cngets(), hz, name, parse_dir_ask_printenv(), parse_mount(), pause(), and printf().

Referenced by parse_directive().

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_dir_ask_printenv ( const char *  var)
static

Definition at line 444 of file vfs_mountroot.c.

References freeenv(), getenv(), and printf().

Referenced by parse_dir_ask().

Here is the call graph for this function:

Here is the caller graph for this function:

static int parse_dir_md ( char **  conf)
static

Definition at line 506 of file vfs_mountroot.c.

References fd, free(), kern_close(), kern_ioctl(), kern_open(), kern_stat(), malloc(), parse_token(), path, printf(), and root_mount_mddev.

Referenced by parse_directive().

Here is the call graph for this function:

Here is the caller graph for this function:

static int parse_dir_onfail ( char **  conf)
static

Definition at line 583 of file vfs_mountroot.c.

References free(), parse_token(), and printf().

Referenced by parse_directive().

Here is the call graph for this function:

Here is the caller graph for this function:

static int parse_dir_timeout ( char **  conf)
static

Definition at line 610 of file vfs_mountroot.c.

References free(), and parse_token().

Referenced by parse_directive().

Here is the call graph for this function:

Here is the caller graph for this function:

static int parse_directive ( char **  conf)
static

Definition at line 629 of file vfs_mountroot.c.

References free(), parse_dir_ask(), parse_dir_md(), parse_dir_onfail(), parse_dir_timeout(), parse_skipto(), parse_token(), and printf().

Referenced by vfs_mountroot_parse().

Here is the call graph for this function:

Here is the caller graph for this function:

static int parse_mount ( char **  conf)
static

Definition at line 672 of file vfs_mountroot.c.

References ERRMSGL, mntarg::error, free(), hz, kernel_mount(), malloc(), mount_arg(), parse_advance(), parse_mount_dev_present(), parse_mountroot_options(), parse_poke(), parse_skipto(), parse_token(), pause(), printf(), root_mount_mddev, timeout(), and vfs_byname().

Referenced by parse_dir_ask(), and vfs_mountroot_parse().

Here is the call graph for this function:

Here is the caller graph for this function:

static int parse_mount_dev_present ( const char *  dev)
static

Definition at line 657 of file vfs_mountroot.c.

References namei(), NDFREE(), and vput().

Referenced by parse_mount().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct mntarg * parse_mountroot_options ( struct mntarg ma,
const char *  options 
)
static

Definition at line 997 of file vfs_mountroot.c.

References free(), mount_arg(), and name.

Referenced by parse_mount().

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline int parse_peek ( char **  conf)
static

Definition at line 375 of file vfs_mountroot.c.

Referenced by parse_skipto(), and vfs_mountroot_parse().

Here is the caller graph for this function:

static __inline void parse_poke ( char **  conf,
int  c 
)
static

Definition at line 382 of file vfs_mountroot.c.

Referenced by parse_mount().

Here is the caller graph for this function:

static int parse_skipto ( char **  conf,
int  mc 
)
static

Definition at line 396 of file vfs_mountroot.c.

References CC_NONWHITESPACE, CC_WHITESPACE, parse_advance(), parse_peek(), PE_EOF, and PE_EOL.

Referenced by parse_directive(), parse_mount(), parse_token(), and vfs_mountroot_parse().

Here is the call graph for this function:

Here is the caller graph for this function:

static int parse_token ( char **  conf,
char **  tok 
)
static

Definition at line 425 of file vfs_mountroot.c.

References CC_NONWHITESPACE, CC_WHITESPACE, malloc(), and parse_skipto().

Referenced by parse_dir_md(), parse_dir_onfail(), parse_dir_timeout(), parse_directive(), parse_mount(), and vfs_mountroot_conf0().

Here is the call graph for this function:

Here is the caller graph for this function:

struct root_hold_token* root_mount_hold ( const char *  identifier)

Definition at line 128 of file vfs_mountroot.c.

References malloc(), root_holds_mtx, root_mounted(), and root_hold_token::who.

Here is the call graph for this function:

void root_mount_rel ( struct root_hold_token h)

Definition at line 144 of file vfs_mountroot.c.

References free(), root_holds_mtx, and wakeup().

Here is the call graph for this function:

void root_mount_wait ( void  )

Definition at line 165 of file vfs_mountroot.c.

References hz, and root_holds_mtx.

int root_mounted ( void  )

Definition at line 157 of file vfs_mountroot.c.

Referenced by root_mount_hold().

Here is the caller graph for this function:

static void set_rootvnode ( void  )
static

Definition at line 183 of file vfs_mountroot.c.

References mountlist, panic(), rootvnode, and vrele().

Referenced by vfs_mountroot_devfs(), and vfs_mountroot_shuffle().

Here is the call graph for this function:

Here is the caller graph for this function:

TUNABLE_INT ( "vfs.mountroot.timeout"  ,
root_mount_timeout 
)
void vfs_mountroot ( void  )
static void vfs_mountroot_conf0 ( struct sbuf *  sb)
static

Definition at line 820 of file vfs_mountroot.c.

References boothowto, free(), freeenv(), getenv(), parse_token(), rootdevnames, and sbuf_printf().

Referenced by vfs_mountroot().

Here is the call graph for this function:

Here is the caller graph for this function:

static int vfs_mountroot_devfs ( struct thread *  td,
struct mount **  mpp 
)
static

Definition at line 209 of file vfs_mountroot.c.

References kern_symlink(), malloc(), mountlist, mountlist_mtx, printf(), set_rootvnode(), vfs_byname(), vfs_mount_alloc(), and vfsconf.

Referenced by vfs_mountroot().

Here is the call graph for this function:

Here is the caller graph for this function:

static int vfs_mountroot_parse ( struct sbuf *  sb,
struct mount *  mpdevfs 
)
static

Definition at line 756 of file vfs_mountroot.c.

References CC_NONWHITESPACE, kern_reboot(), panic(), parse_advance(), parse_directive(), parse_mount(), parse_peek(), parse_skipto(), PE_EOL, printf(), and sbuf_data().

Referenced by vfs_mountroot().

Here is the call graph for this function:

Here is the caller graph for this function:

static int vfs_mountroot_readconf ( struct thread *  td,
struct sbuf *  sb 
)
static

Definition at line 867 of file vfs_mountroot.c.

References buf, NDFREE(), sbuf_printf(), vn_close(), vn_open(), and vn_rdwr().

Referenced by vfs_mountroot().

Here is the call graph for this function:

Here is the caller graph for this function:

static int vfs_mountroot_shuffle ( struct thread *  td,
struct mount *  mpdevfs 
)
static

Definition at line 249 of file vfs_mountroot.c.

References bootverbose, cache_purge(), cache_purgevfs(), kern_unlink(), mountlist, mountlist_mtx, namei(), NDFREE(), printf(), rootvnode, set_rootvnode(), vfs_unbusy(), vinvalbuf(), vput(), and vrele().

Referenced by vfs_mountroot().

Here is the call graph for this function:

Here is the caller graph for this function:

static void vfs_mountroot_wait ( void  )
static

Definition at line 906 of file vfs_mountroot.c.

References hz, ppsratecheck(), printf(), root_holds_mtx, and root_hold_token::who.

Referenced by vfs_mountroot().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

struct mtx root_holds_mtx
int root_mount_complete
static

Definition at line 121 of file vfs_mountroot.c.

int root_mount_mddev
static

Definition at line 120 of file vfs_mountroot.c.

Referenced by parse_dir_md(), and parse_mount().

enum action root_mount_onfail = A_CONTINUE
static

Definition at line 118 of file vfs_mountroot.c.

int root_mount_timeout = 3
static

Definition at line 124 of file vfs_mountroot.c.

char* rootdevnames[2] = {NULL, NULL}

Definition at line 98 of file vfs_mountroot.c.

Referenced by vfs_mountroot_conf0().