Re: [PATCH] Syscalls: reboot: Add options to the reboot syscall to remount filesystems ro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 3, 2011 at 3:31 PM, Ken Sumrall <ksumrall@xxxxxxxxxxx> wrote:
> Add 4 new commands to the reboot system call, that do the same thing as the
> RESTART, HALT, POWER_OFF, and RESTART2 commands, but also remount writable
> filesystems as read-only just before doing what the command normally does.
> Now that Android is using EXT4, and since we don't have a standard init
> setup to unmount filesystems before rebooting, this allows the system to
> reboot with clean filesystems, and also improves boot time as the journal
> does not need to be replayed when mounting the filesystem.
>
> Signed-off-by: Ken Sumrall <ksumrall@xxxxxxxxxxx>
> ---
> Âfs/super.c       |  Â9 +++++++++
> Âinclude/linux/fs.h   |  Â1 +
> Âinclude/linux/reboot.h | Â Â4 ++++
> Âkernel/sys.c      |  12 ++++++++++++
> Â4 files changed, 26 insertions(+), 0 deletions(-)
>
> diff --git a/fs/super.c b/fs/super.c
> index 8819e3a..3f39a16 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -638,6 +638,15 @@ void emergency_remount(void)
> Â Â Â Â}
> Â}
>
> +void emergency_remount_synchronous(void)
> +{
> + Â Â Â struct work_struct *work;
> +
> + Â Â Â work = kmalloc(sizeof(*work), GFP_ATOMIC);
> + Â Â Â if (work)
> + Â Â Â Â Â Â Â do_emergency_remount(work);

work is not needed here? just call do_mergency_remount()

> +}
> +
> Â/*
> Â* Unnamed block devices are dummy devices used by virtual
> Â* filesystems which don't use real block-devices. Â-- jrs
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 63d069b..e48ef0d 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2110,6 +2110,7 @@ extern int generic_write_sync(struct file *file, loff_t pos, loff_t count);
> Âextern void sync_supers(void);
> Âextern void emergency_sync(void);
> Âextern void emergency_remount(void);
> +extern void emergency_remount_synchronous(void);
> Â#ifdef CONFIG_BLOCK
> Âextern sector_t bmap(struct inode *, sector_t);
> Â#endif
> diff --git a/include/linux/reboot.h b/include/linux/reboot.h
> index 3005d5a..24b185d 100644
> --- a/include/linux/reboot.h
> +++ b/include/linux/reboot.h
> @@ -26,11 +26,15 @@
> Â*/
>
> Â#define    ÂLINUX_REBOOT_CMD_RESTART    Â0x01234567
> +#define    ÂLINUX_REBOOT_CMD_RMNT_RESTART  0x12345670
> Â#define    ÂLINUX_REBOOT_CMD_HALT      0xCDEF0123
> +#define    ÂLINUX_REBOOT_CMD_RMNT_HALT   Â0xDEF0123C
> Â#define    ÂLINUX_REBOOT_CMD_CAD_ON     0x89ABCDEF
> Â#define    ÂLINUX_REBOOT_CMD_CAD_OFF    Â0x00000000
> Â#define    ÂLINUX_REBOOT_CMD_POWER_OFF   Â0x4321FEDC
> +#define    ÂLINUX_REBOOT_CMD_RMNT_POWER_OFF 0x321FEDC4
> Â#define    ÂLINUX_REBOOT_CMD_RESTART2    0xA1B2C3D4
> +#define    ÂLINUX_REBOOT_CMD_RMNT_RESTART2 Â0x1B2C3D4A
> Â#define    ÂLINUX_REBOOT_CMD_SW_SUSPEND   0xD000FCE2
> Â#define    ÂLINUX_REBOOT_CMD_KEXEC     Â0x45584543
>
> diff --git a/kernel/sys.c b/kernel/sys.c
> index 7f5a0cd..3f474e6 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -392,6 +392,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
> Â Â Â Âmutex_lock(&reboot_mutex);
> Â Â Â Âswitch (cmd) {
> Â Â Â Âcase LINUX_REBOOT_CMD_RESTART:
> + Â Â Â case LINUX_REBOOT_CMD_RMNT_RESTART:
> + Â Â Â Â Â Â Â if (cmd == LINUX_REBOOT_CMD_RMNT_RESTART)
> + Â Â Â Â Â Â Â Â Â Â Â emergency_remount_synchronous();
> Â Â Â Â Â Â Â Âkernel_restart(NULL);
> Â Â Â Â Â Â Â Âbreak;
>
> @@ -404,22 +407,31 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
> Â Â Â Â Â Â Â Âbreak;
>
> Â Â Â Âcase LINUX_REBOOT_CMD_HALT:
> + Â Â Â case LINUX_REBOOT_CMD_RMNT_HALT:
> + Â Â Â Â Â Â Â if (cmd == LINUX_REBOOT_CMD_RMNT_HALT)
> + Â Â Â Â Â Â Â Â Â Â Â emergency_remount_synchronous();
> Â Â Â Â Â Â Â Âkernel_halt();
> Â Â Â Â Â Â Â Âdo_exit(0);
> Â Â Â Â Â Â Â Âpanic("cannot halt");
>
> Â Â Â Âcase LINUX_REBOOT_CMD_POWER_OFF:
> + Â Â Â case LINUX_REBOOT_CMD_RMNT_POWER_OFF:
> + Â Â Â Â Â Â Â if (cmd == LINUX_REBOOT_CMD_RMNT_POWER_OFF)
> + Â Â Â Â Â Â Â Â Â Â Â emergency_remount_synchronous();
> Â Â Â Â Â Â Â Âkernel_power_off();
> Â Â Â Â Â Â Â Âdo_exit(0);
> Â Â Â Â Â Â Â Âbreak;
>
> Â Â Â Âcase LINUX_REBOOT_CMD_RESTART2:
> + Â Â Â case LINUX_REBOOT_CMD_RMNT_RESTART2:
> Â Â Â Â Â Â Â Âif (strncpy_from_user(&buffer[0], arg, sizeof(buffer) - 1) < 0) {
> Â Â Â Â Â Â Â Â Â Â Â Âret = -EFAULT;
> Â Â Â Â Â Â Â Â Â Â Â Âbreak;
> Â Â Â Â Â Â Â Â}
> Â Â Â Â Â Â Â Âbuffer[sizeof(buffer) - 1] = '\0';
>
> + Â Â Â Â Â Â Â if (cmd == LINUX_REBOOT_CMD_RMNT_RESTART2)
> + Â Â Â Â Â Â Â Â Â Â Â emergency_remount_synchronous();
> Â Â Â Â Â Â Â Âkernel_restart(buffer);
> Â Â Â Â Â Â Â Âbreak;
>
> --
> 1.7.3.1
>
>



-- 
Regards
dave
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux