This file is indexed.

/lib/init/mount-functions.sh is in initscripts 2.88dsf-59.9.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
#
# Functions used by several mount* scripts in initscripts package
#
# Sourcer must source /lib/lsb/init-functions.sh

# List available fstab files, including any files in /etc/fstab.d.
# This looks ugly, but we can't use find and it's safer than globbing.
fstab_files()
{
    echo /etc/fstab
    if [ -d /etc/fstab.d ]; then
        ls -1 /etc/fstab.d | grep '\.fstab$' | sed -e 's;^;/etc/fstab.d/;'
    fi
}

# $1: directory
is_empty_dir() {
	for FILE in $1/* $1/.*
	do
		case "$FILE" in
		  "$1/.*") return 0 ;;
		  "$1/*"|"$1/."|"$1/..") continue ;;
		  *) return 1 ;;
		esac
	done
	return 0
}


selinux_enabled () {
	which selinuxenabled >/dev/null 2>&1 && selinuxenabled
}

# Read /etc/fstab, looking for:
# 1) The root filesystem, resolving LABEL=*|UUID=* entries to the
#	device node,
# 2) Swap that is on a md device or a file that may be on a md
#	device,
_read_fstab () {
	echo "fstabroot=/dev/root"
	echo "rootdev=none"
	echo "roottype=none"
	echo "rootopts=defaults"
	echo "rootmode=rw"
	echo "rootcheck=no"
	echo "swap_on_lv=no"
	echo "swap_on_file=no"

	fstab_files | while read file; do
		if [ -f "$file" ]; then
			while read DEV MTPT FSTYPE OPTS DUMP PASS JUNK; do
				case "$DEV" in
				  ""|\#*)
					continue;
					;;
				  /dev/mapper/*)
					[ "$FSTYPE" = "swap" ] && echo swap_on_lv=yes
					;;
				  /dev/*)
					;;
				  LABEL=*|UUID=*)
					if [ "$MTPT" = "/" ] && [ -x /sbin/findfs ]
					then
						DEV="$(findfs "$DEV")"
					fi
					;;
				  /*)
					[ "$FSTYPE" = "swap" ] && echo swap_on_file=yes
					;;
				  *)
					;;
				esac
				[ "$MTPT" != "/" ] && continue
				echo rootdev=\"$DEV\"
				echo fstabroot=\"$DEV\"
				echo rootopts=\"$OPTS\"
				echo roottype=\"$FSTYPE\"
				( [ "$PASS" != 0 ] && [ "$PASS" != "" ]   ) && echo rootcheck=yes
				( [ "$FSTYPE" = "nfs" ] || [ "$FSTYPE" = "nfs4" ] ) && echo rootcheck=no
				case "$OPTS" in
				  ro|ro,*|*,ro|*,ro,*)
					echo rootmode=ro
					;;
				esac
			done < "$file"
		fi
	done
}

# Read /etc/fstab, looking for:
# 1) The root filesystem, resolving LABEL=*|UUID=* entries to the
#	device node,
# 2) Swap that is on a md device or a file that may be on a md
#	device,

read_fstab () {
	eval "$(_read_fstab)"
}

# Find a specific fstab entry
# $1=mountpoint
# $2=fstype (optional)
_read_fstab_entry () {
	# Not found by default.
	echo "MNT_FSNAME="
	echo "MNT_DIR="
	echo "MNT_TYPE="
	echo "MNT_OPTS="
	echo "MNT_FREQ="
	echo "MNT_PASS="

	fstab_files | while read file; do
		if [ -f "$file" ]; then
			while read MNT_FSNAME MNT_DIR MNT_TYPE MNT_OPTS MNT_FREQ MNT_PASS MNT_JUNK; do
				case "$MNT_FSNAME" in
				  ""|\#*)
					continue;
					;;
				esac
				if [ "$MNT_DIR" = "$1" ]; then
					if [ -n "$2" ]; then
						[ "$MNT_TYPE" = "$2" ] || continue;
					fi
	                                echo "MNT_FSNAME=$MNT_FSNAME"
	                                echo "MNT_DIR=$MNT_DIR"
	                                echo "MNT_TYPE=$MNT_TYPE"
	                                echo "MNT_OPTS=$MNT_OPTS"
	                                echo "MNT_FREQ=$MNT_FREQ"
	                                echo "MNT_PASS=$MNT_PASS"
					break 2
				fi
				MNT_DIR=""
			done < "$file"
		fi
	done
}

# Find a specific fstab entry
# $1=mountpoint
# $2=fstype (optional)
# returns 0 on success, 1 on failure (not found or no fstab)
read_fstab_entry () {
	eval "$(_read_fstab_entry "$1" "$2")"

	# Not found by default.
	found=1
	if [ "$1" = "$MNT_DIR" ]; then
		found=0
	fi

	return $found
}

# Mount kernel and device file systems.
# $1: mount mode (mount, remount)
# $2: file system type
# $3: alternative file system type (or empty string if none)
# $4: mount point
# $5: mount device name
# $6... : extra mount program options
domount () {
	MOUNTMODE="$1"
	PRIFSTYPE="$2"
	ALTFSTYPE="$3"
	MTPT="$4"
	DEVNAME="$5"
	CALLER_OPTS="$6"

	KERNEL="$(uname -s)"
	# Figure out filesystem type from primary and alternative type
	FSTYPE=
	# Filesystem-specific mount options
	FS_OPTS=
	# Mount options from fstab
	FSTAB_OPTS=

	if [ "$MOUNTMODE" = remount ] ; then
		case "$KERNEL" in
			*FreeBSD)
				case "$PRIFSTYPE" in
					proc|tmpfs|sysfs)
						# can't be remounted
						return 0
					;;
				esac
			;;
		esac
	fi

	if [ "$PRIFSTYPE" = proc ]; then
		case "$KERNEL" in
			Linux)     FSTYPE=proc ;;
			GNU)       FSTYPE=proc; FS_OPTS="-ocompatible" ;;
			*FreeBSD)  FSTYPE=linprocfs ;;
			*)         FSTYPE=procfs ;;
		esac
	elif [ "$PRIFSTYPE" = bind ]; then
		case "$KERNEL" in
			Linux)     FSTYPE="$DEVNAME"; FS_OPTS="-obind" ;;
			*FreeBSD)  FSTYPE=nullfs ;;
			GNU)       FSTYPE=firmlink ;;
			*)         FSTYPE=none ;;
		esac
	elif [ "$PRIFSTYPE" = tmpfs ]; then
		# always accept tmpfs, to mount /run before /proc
		case "$KERNEL" in
			*)	FSTYPE=$PRIFSTYPE ;;
		esac
	elif grep -E -qs "$PRIFSTYPE\$" /proc/filesystems; then
		FSTYPE=$PRIFSTYPE
	elif grep -E -qs "$ALTFSTYPE\$" /proc/filesystems; then
		FSTYPE=$ALTFSTYPE
	fi

	# Filesystem not supported by kernel
	if [ ! "$FSTYPE" ]; then
		if [ "$ALTFSTYPE" ]; then
			log_warning_msg "Filesystem types '$PRIFSTYPE' and '$ALTFSTYPE' are not supported. Skipping mount."
		else
			log_warning_msg "Filesystem type '$PRIFSTYPE' is not supported. Skipping mount."
		fi
		return
	fi

	# We give file system type as device name if not specified as
	# an argument
	if [ -z "$DEVNAME" ] ; then
	    DEVNAME=$FSTYPE
	fi

	# Get the mount options from /etc/fstab
	if read_fstab_entry "$MTPT" "$FSTYPE"; then
		case "$MNT_OPTS" in
			noauto|*,noauto|noauto,*|*,noauto,*)
				return
				;;
			?*)
				FSTAB_OPTS="-o$MNT_OPTS"
				;;
		esac
	fi

	if [ ! -d "$MTPT" ]
	then
		log_warning_msg "Mount point '$MTPT' does not exist. Skipping mount."
		return
	fi

	if [ "$MOUNTMODE" = "mount_noupdate" ]; then
		MOUNTFLAGS="-n"
		MOUNTMODE=mount
	fi
	if [ "$MOUNTMODE" = "remount_noupdate" ]; then
		MOUNTFLAGS="-n"
		MOUNTMODE=remount
	fi

	case "$MOUNTMODE" in
		mount)
			if mountpoint -q "$MTPT"; then
			    # Already mounted, probably moved from the
			    # initramfs, so remount with the
			    # user-specified mount options later on.
			    :
			else
				if [ "$VERBOSE" != "no" ]; then
					is_empty_dir "$MTPT" >/dev/null 2>&1 || log_warning_msg "Files under mount point '$MTPT' will be hidden."
				fi
				mount $MOUNTFLAGS -t $FSTYPE $CALLER_OPTS $FSTAB_OPTS $FS_OPTS $DEVNAME $MTPT
				if [ "$FSTYPE" = "tmpfs" -a -x /sbin/restorecon ]; then
					/sbin/restorecon $MTPT
				fi
			fi
			;;
		remount)
			if mountpoint -q "$MTPT"; then
				# Remount with user-specified mount options
				mount $MOUNTFLAGS -oremount $CALLER_OPTS $FSTAB_OPTS $MTPT
			fi
			;;
	esac
}

#
# Preserve /var/run and /var/lock mountpoints
#
pre_mountall ()
{
    :
}

# If the device/inode are the same, a bind mount already exists or the
# transition is complete, so set up is not required.  Otherwise bind
# mount $SRC on $DEST.
bind_mount ()
{
	SRC=$1
	DEST=$2

	FSTYPE=""
	OPTS=""

	ssrc="$(/usr/bin/stat -L --format="%d %i" "$SRC" 2>/dev/null || :)"
	sdest="$(/usr/bin/stat -L --format="%d %i" "$DEST" 2>/dev/null || :)"

	case "$(uname -s)" in
		Linux)     FSTYPE=$SRC; OPTS="-orw -obind" ;;
		*FreeBSD)  FSTYPE=nullfs; OPTS="-orw" ;;
		GNU)       FSTYPE=firmlink ;;
		*)         FSTYPE=none ;;
	esac

	# Bind mount $SRC on $DEST
	if [ -n "$ssrc" ] && [ "$ssrc" != "$sdest" ]; then
		[ -d "$DEST" ] || mkdir "$DEST"
		[ -x /sbin/restorecon ] && /sbin/restorecon "$DEST"
		if mount -t $FSTYPE "$SRC" "$DEST" $OPTS ; then
			echo "Please reboot to complete migration to tmpfs-based /run" > "${DEST}/.run-transition"
			return 0
		fi
		return 1
	fi

	return 0
}

#
# Migrate a directory to /run and create compatibility symlink or bind
# mount.
#
run_migrate ()
{
	OLD=$1
	RUN=$2

	KERNEL="$(uname -s)"
	OPTS=""
	case "$KERNEL" in
		Linux)     FSTYPE=none OPTS="-orw -obind";;
		*FreeBSD)  FSTYPE=nullfs OPTS="-orw" ;;
		GNU)       FSTYPE=firmlink ;;
		*)         FSTYPE=none ;;
	esac

	# Create absolute symlink if not already present.  This is to
	# upgrade from older versions which created relative links,
	# which are not permitted in policy between top-level
	# directories.
	if [ -L "$OLD" ] && [ "$(readlink "$OLD")" != "$RUN" ]; then
		rm -f "$OLD"
		ln -fs "$RUN" "$OLD"
		[ -x /sbin/restorecon ] && /sbin/restorecon "$OLD"
	fi

	# If both directories are the same, we don't need to do
	# anything further.
	sold="$(/usr/bin/stat -L --format="%d %i" "$OLD" 2>/dev/null || :)"
	srun="$(/usr/bin/stat -L --format="%d %i" "$RUN" 2>/dev/null || :)"
	if [ -n "$sold" ] && [ "$sold" = "$srun" ]; then
		return 0
	fi

	# Try to remove if a directory.  Note this is safe because the
	# system is not yet fully up, and nothing is allowed to use
	# them yet.  If the user explicitly mounted a filesystem here,
	# it will be cleaned out, but this would happen later on when
	# bootclean runs in any case.
	if [ ! -L "$OLD" ] && [ -d "$OLD" ] ; then
		rm -fr "$OLD" 2>/dev/null || true
	fi

	# If removal failed (directory still exists), set up bind mount.
	if [ ! -L "$OLD" ] && [ -d "$OLD" ] ; then
		if [ "$OLD" != "/tmp" ]; then
			log_warning_msg "Filesystem mounted on $OLD; setting up compatibility bind mount."
			log_warning_msg "Please remove this mount from /etc/fstab; it is no longer needed, and it is preventing completion of the transition to $RUN."
		fi
		mount -t $FSTYPE "$RUN" "$OLD" $OPTS
	else
		# Create symlink if not already present.
		if [ -L "$OLD" ] && [ "$(readlink "$OLD")" != "$RUN" ]; then
			:
		else
			rm -f "$OLD"
			ln -fs "$RUN" "$OLD"
			[ -x /sbin/restorecon ] && /sbin/restorecon "$OLD"
		fi
	fi

	return 0
}

#
# Migrate /etc/mtab to a compatibility symlink
#
mtab_migrate ()
{
	# Don't symlink if /proc/mounts does not exist.
	if [ ! -r "/proc/mounts" ]; then
		return 1
	fi

	# Create symlink if not already present.
	if [ -L "/etc/mtab" ] && [ "$(readlink "/etc/mtab")" = "/proc/mounts" ]; then
		:
	else
		log_warning_msg "Creating compatibility symlink from /etc/mtab to /proc/mounts."

		rm -f "/etc/mtab" || return 1
		ln -fs "/proc/mounts" "/etc/mtab" || return 1
		[ -x /sbin/restorecon ] && /sbin/restorecon "/etc/mtab"
	fi

	return 0
}

#
# For compatibility, create /var/run and /var/lock symlinks to /run
# and /run/lock, respectively.
#
post_mountall ()
{
	# /var/run and /var/lock are now /run and /run/lock,
	# respectively.  Cope with filesystems being deliberately
	# mounted on /var/run and /var/lock.  We will create bind
	# mounts from /run and /run/lock to /var/run and /var/lock if
	# we can't remove the /var/run and /var/lock directories, or
	# else simply create symlinks.  For example, in the case that
	# the user has explicitly mounted filesystems on /var/run or
	# /var/lock, we bind mount over the top of them.  Where no
	# filesystems are mounted, we replace the directory with a
	# symlink where possible.

	# Cater for systems which have a symlink from /run to /var/run
	# for whatever reason.  Remove the symlink and replace with a
	# directory.  The migration logic will then take care of the
	# rest.  Note that it will take a second boot to fully
	# migrate; it should only ever be needed on broken systems.
	RAMSHM_ON_DEV_SHM="no"
	if read_fstab_entry "/dev/shm"; then
	    RAMSHM_ON_DEV_SHM="yes"
	fi
	if read_fstab_entry "/run/shm"; then
	    RAMSHM_ON_DEV_SHM="no"
	fi

	if [ -L /run ]; then
		if [ "$(readlink /run)" = "/var/run" ]; then
			rm -f /run
			mkdir /run
		fi
		if bind_mount /var/run /run; then
		    bind_mount /var/lock /run/lock
		    if [ yes = "$RAMSHM_ON_DEV_SHM" ]; then
			run_migrate /run/shm /dev/shm
		    else
			run_migrate /dev/shm /run/shm
		    fi
		fi
	else
	    run_migrate /var/run /run
	    run_migrate /var/lock /run/lock
	    if [ yes = "$RAMSHM_ON_DEV_SHM" ]; then
		run_migrate /run/shm /dev/shm
	    else
		run_migrate /dev/shm /run/shm
	    fi
	fi
}

# Mount /run
mount_run ()
{
	MNTMODE="$1"
	KERNEL="$(uname -s)"

	if [ "$MNTMODE" = remount ] ; then
		case "$KERNEL" in
			*FreeBSD)
				# tmpfs can't be remounted
				return 0
			;;
		esac
	fi

	# Needed to determine if root is being mounted read-only.
	read_fstab

	#
	# Get some writable area available before the root is checked
	# and remounted.  Note that /run may be handed over from the
	# initramfs.
	#

	# If /run/shm is separately mounted, /run can be safely mounted noexec.
	RUNEXEC=
	if [ yes = "$RAMSHM" ] || read_fstab_entry /run/shm tmpfs; then
	    RUNEXEC=',noexec'
	fi
	# TODO: Add -onodev once checkroot no longer creates a device node.
	domount "$MNTMODE" tmpfs shmfs /run tmpfs "-onosuid$RUNEXEC$RUN_OPT"
	[ -x /sbin/restorecon ] && /sbin/restorecon -r /run

	# Make pidfile omit directory for sendsigs
	[ -d /run/sendsigs.omit.d ] || mkdir --mode=755 /run/sendsigs.omit.d/

	# Make sure we don't get cleaned
	touch /run/.tmpfs
}

# Mount /run/lock
mount_lock ()
{
	MNTMODE="$1"
	KERNEL="$(uname -s)"

	if [ "$MNTMODE" = remount ] ; then
		case "$KERNEL" in
			*FreeBSD)
				# tmpfs can't be remounted
				return 0
			;;
		esac
	fi

	# Make lock directory as the replacement for /var/lock
	[ -d /run/lock ] || mkdir --mode=755 /run/lock
	[ -x /sbin/restorecon ] && /sbin/restorecon /run/lock

	# Now check if there's an entry in /etc/fstab.  If there is,
	# it overrides the existing RAMLOCK setting.
	if read_fstab_entry /run/lock; then
	    if [ "$MNT_TYPE" = "tmpfs" ] ; then
		RAMLOCK="yes"
	    else
		RAMLOCK="no"
	    fi
	fi

	NODEV="nodev,"
	case "$KERNEL" in
		*FreeBSD|GNU)  NODEV="" ;;
	esac

	# Mount /run/lock as tmpfs if enabled.  This prevents user DoS
	# of /run by filling /run/lock at the expense of using an
	# additional tmpfs.
	if [ yes = "$RAMLOCK" ]; then
		domount "$MNTMODE" tmpfs shmfs /run/lock tmpfs "-o${NODEV}noexec,nosuid$LOCK_OPT"
		# Make sure we don't get cleaned
		touch /run/lock/.tmpfs
	else
		chmod "$LOCK_MODE" /run/lock
	fi
}

# Mount /run/shm
mount_shm ()
{
	MNTMODE="$1"

	RAMSHM_ON_DEV_SHM="no"
	SHMDIR="/run/shm"
	if read_fstab_entry "/dev/shm"; then
		if [ "$MNTMODE" = "mount_noupdate" ]; then
			log_warning_msg "Warning: fstab entry for /dev/shm; should probably be for /run/shm unless working around a bug in the Oracle database"
		fi
		SHMDIR="/dev/shm"
		RAMSHM_ON_DEV_SHM="yes"
	fi
	if read_fstab_entry "/run/shm"; then
		if [ "$MNTMODE" = "mount_noupdate" ] && [ "$RAMSHM_ON_DEV_SHM" = "yes" ]; then
			log_warning_msg "Warning: fstab entries for both /dev/shm and /run/shm found; only /run/shm will be used"
		fi

		SHMDIR="/run/shm"
		RAMSHM_ON_DEV_SHM="no"
	fi

	if [ ! -d "$SHMDIR" ]
	then
		mkdir --mode=755 "$SHMDIR"
		[ -x /sbin/restorecon ] && /sbin/restorecon "$SHMDIR"
	fi

	# Now check if there's an entry in /etc/fstab.  If there is,
	# it overrides the existing RAMSHM setting.
	if read_fstab_entry "$SHMDIR"; then
		if [ "$MNT_TYPE" = "tmpfs" ] ; then
			RAMSHM="yes"
		else
			RAMSHM="no"
		fi
	fi

	KERNEL="$(uname -s)"
	NODEV="nodev,"
	case "$KERNEL" in
		*FreeBSD|GNU)  NODEV="" ;;
	esac

	if [ yes = "$RAMSHM" ]; then
		domount "$MNTMODE" tmpfs shmfs "$SHMDIR" tmpfs "-onosuid,${NODEV}noexec$SHM_OPT"
		# Make sure we don't get cleaned
		touch "$SHMDIR"/.tmpfs
	else
		chmod "$SHM_MODE" "$SHMDIR"
	fi

	# Migrate early, so /dev/shm is available from the start
	if [ "$MNTMODE" = mount_noupdate ] || [ "$MNTMODE" = mount ]; then
		if [ yes = "$RAMSHM_ON_DEV_SHM" ]; then
			run_migrate /run/shm /dev/shm
		else
			run_migrate /dev/shm /run/shm
		fi
	fi
}

#
# Mount /tmp
#
mount_tmp ()
{
	MNTMODE="$1"

	# If /tmp is a symlink, make sure the linked-to directory exists.
	if [ -L /tmp ] && [ ! -d /tmp ]; then
		TMPPATH="$(readlink /tmp)"
		mkdir -p --mode=755 "$TMPPATH"
		[ -x /sbin/restorecon ] && /sbin/restorecon "$TMPPATH"
	fi

	# Disable RAMTMP if there's 64MiB RAM or less.  May be
	# re-enabled by overflow or read only root, below.
	RAM_SIZE="$(ram_size)"
	if [ -n "$RAM_SIZE" ] && [ "$((RAM_SIZE <= 65536))" = "1" ]; then
		RAMTMP=no
	fi

	# If root is read only, default to mounting a tmpfs on /tmp,
	# unless one is due to be mounted from fstab.
	if [ "$RAMTMP" != "yes" ] && [ rw != "$rootmode" ]; then
		# If there's an entry in fstab for /tmp (any
		# filesystem type, not just tmpfs), then we don't need
		# a tmpfs on /tmp by default.
		if read_fstab_entry /tmp ; then
			:
		else
			log_warning_msg "Root filesystem is read-only; mounting tmpfs on /tmp"
			RAMTMP="yes"
		fi
	fi

	if [ "$RAMTMP" != "yes" ] && need_overflow_tmp; then
		# If there's an entry in fstab for /tmp (any
		# filesystem type, not just tmpfs), then we don't need
		# a tmpfs on /tmp by default.
		if read_fstab_entry /tmp ; then
			:
		else
			log_warning_msg "Root filesystem has insufficient free space; mounting tmpfs on /tmp"
			RAMTMP="yes"
		fi
	fi

	# Now check if there's an entry in /etc/fstab.  If there is,
	# it overrides all the above settings.
	if read_fstab_entry /tmp; then
	    if [ "$MNT_TYPE" = "tmpfs" ] ; then
		RAMTMP="yes"
	    else
		RAMTMP="no"
	    fi
	fi

	KERNEL="$(uname -s)"
	NODEV="nodev,"
	case "$KERNEL" in
		*FreeBSD|GNU)  NODEV="" ;;
	esac

	# Mount /tmp as tmpfs if enabled.
	if [ yes = "$RAMTMP" ]; then
		domount "$MNTMODE" tmpfs shmfs /tmp tmpfs "-o${NODEV}nosuid$TMP_OPT"
		# Make sure we don't get cleaned
		touch /tmp/.tmpfs
	else
		# When root is still read only, this will fail.
		if [ mount_noupdate != "$MNTMODE" ] && [ rw = "$rootmode" ]; then
			chmod "$TMP_MODE" /tmp
		fi
	fi
}

is_fastboot_active() {
	if [ -f /fastboot ] ; then
	    return 0
	fi
	for cmd in $(cat /proc/cmdline) ; do
	    case "$cmd" in
		fastboot)
		    return 0
		    ;;
	    esac
	done
	return 1
}