disk/part: Only build hostfs special handling when CONFIG_SANDBOX is set
Subsystems (2)
PATCH v2 1/5 disk/part: Only build hostfs special handling when CONFIG_SANDBOX is set
This is not necessary / useful when not building with CONFIG_SANDBOX and with the addition of ubifs support to the generic fs commands it actually gets in the way, since both operate on a fake / NULL blkdev.
---
Changes in v2:
-New patch in v2 of the patch-set
--- disk/part.c | 2 ++ 1 file changed, 2 insertions(+)
disk/part.c +2 -0
@@ -511,6 +511,7 @@ int get_device_and_partition(const char *ifname, const char *dev_part_str,int part;disk_partition_t tmpinfo; +#ifdef CONFIG_SANDBOX /* * Special-case a pseudo block device "hostfs", to allow access to the * host's own filesystem.
@@ -529,6 +530,7 @@ int get_device_and_partition(const char *ifname, const char *dev_part_str,return 0 ; } +#endif /* If no dev_part_str, use bootdevice environment variable */ if (!dev_part_str || !strlen(dev_part_str) ||
Signature · 1 line
2.4.3
PATCH v2 2/5 ubifs: Modify ubifs u-boot wrapper function prototypes for generic fs use
Modify the ubifs u-boot wrapper function prototypes for generic fs use, and give them their own header file.
This is a preparation patch for adding ubifs support to the generic fs code from fs/fs.c.
---
Changes in v2:
-No changes in v2
--- common/cmd_ubifs.c | 12 ++------- fs/ubifs/ubifs.c | 70 ++++++++++++++++++++++++++++++++++++++++----------- fs/ubifs/ubifs.h | 6 +---- include/ubifs_uboot.h | 28 +++++++++++++++++++++ 4 files changed, 87 insertions(+), 29 deletions(-) create mode 100644 include/ubifs_uboot.h
common/cmd_ubifs.c +2 -10
@@ -15,8 +15,7 @@#include <common.h> #include <config.h> #include <command.h> - -#include "../fs/ubifs/ubifs.h" +#include <ubifs_uboot.h> static int ubifs_initialized;static int ubifs_mounted;
@@ -54,14 +53,7 @@ int ubifs_is_mounted(void)void cmd_ubifs_umount (void ) { - -if (ubifs_sb) { -printf ("Unmounting UBIFS volume %s!\n" , - ((struct ubifs_info *)(ubifs_sb->s_fs_info))->vi.name); -ubifs_umount (ubifs_sb->s_fs_info); - } - - ubifs_sb =NULL ; +uboot_ubifs_umount (); ubifs_mounted =0 ; ubifs_initialized =0 ; }
fs/ubifs/ubifs.c +56 -14
122 lines not on this page · raw message
fs/ubifs/ubifs.h +1 -5
@@ -34,6 +34,7 @@#include <asm/atomic.h> #include <asm-generic/atomic-long.h> #include <ubi_uboot.h> +#include <ubifs_uboot.h> #include <linux/ctype.h> #include <linux/time.h>
@@ -2379,11 +2380,6 @@ int ubifs_decompress(const void *buf, int len, void *out, int *out_len,#include "key.h" #ifdef __UBOOT__ -/* these are used in cmd_ubifs.c */ -int ubifs_init (void ); -int uboot_ubifs_mount (char *vol_name);void ubifs_umount (struct ubifs_info *c); -int ubifs_ls (char *dir_name); -int ubifs_load (char *filename,u32 addr,u32 size);#endif #endif /* !__UBIFS_H__ */
include/ubifs_uboot.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* UBIFS u-boot wrapper functions header +* +* Copyright (C) 2006-2008 Nokia Corporation +* +* (C) Copyright 2008-2009 +* Stefan Roese, DENX Software Engineering, sr at denx.de. +* +* SPDX-License-Identifier: GPL-2.0+ +* +* Authors: Artem Bityutskiy (???????? ?????) +* Adrian Hunter +*/ + +#ifndef __UBIFS_UBOOT_H__ +#define __UBIFS_UBOOT_H__ + +int ubifs_init (void ); +int uboot_ubifs_mount (char *vol_name); +void uboot_ubifs_umount (void ); +int ubifs_is_mounted (void ); +int ubifs_load (char *filename,u32 addr,u32 size); + +int ubifs_ls (const char *dir_name); +int ubifs_read (const char *filename,void *buf,loff_t offset, +loff_t size,loff_t *actread); + +#endif /* __UBIFS_UBOOT_H__ */
Signature · 1 line
2.4.3
PATCH v2 2/5 ubifs: Modify ubifs u-boot wrapper function prototypes for generic fs use
Quoted 8 lines · Hans de Goede
Modify the ubifs u-boot wrapper function prototypes for generic fs use, and give them their own header file.
This is a preparation patch for adding ubifs support to the generic fs code from
fs/fs.c.Signed-off-by Hans de Goede <[email protected]>Reviewed-by Heiko Schocher <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151024/d1c821ac/attachment.sig>
PATCH v2 3/5 ubifs: Add functions for generic fs use
In reply to Hans de GoedeImplement the necessary functions for implementing generic fs support for ubifs.
---
Changes in v2:
-Use debug rather then printf in ubifs_set_blk_dev() to avoid false
positive error messages when using generic fs commands
--- fs/ubifs/ubifs.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/ubifs_uboot.h | 4 ++++ 2 files changed, 69 insertions(+)
fs/ubifs/ubifs.c +65 -0
@@ -570,6 +570,25 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)return 0 ; } +int ubifs_set_blk_dev (block_dev_desc_t *rbdd,disk_partition_t *info) +{ +if (rbdd) { +debug ("UBIFS cannot be used with normal block devices\n" ); +return -1 ; + } + +/* +* Should never happen since get_device_and_partition() already checks +* this, but better safe then sorry. +*/ +if (!ubifs_is_mounted ()) { +debug ("UBIFS not mounted, use ubifsmount to mount volume first!\n" ); +return -1 ; + } + +return 0 ; +} +int ubifs_ls (const char *filename) {struct ubifs_info *c = ubifs_sb->s_fs_info;
@@ -618,6 +637,48 @@ out:return ret; } +int ubifs_exists (const char *filename) +{ +struct ubifs_info *c = ubifs_sb->s_fs_info; +unsigned long inum; + + c->ubi =ubi_open_volume (c->vi.ubi_num, c->vi.vol_id,UBI_READONLY ); + inum =ubifs_findfile (ubifs_sb, (char *)filename); +ubi_close_volume (c->ubi); + +return inum !=0 ; +} + +int ubifs_size (const char *filename,loff_t *size) +{ +struct ubifs_info *c = ubifs_sb->s_fs_info; +unsigned long inum; +struct inode *inode; +int err =0 ; + + c->ubi =ubi_open_volume (c->vi.ubi_num, c->vi.vol_id,UBI_READONLY ); + + inum =ubifs_findfile (ubifs_sb, (char *)filename); +if (!inum) { + err =-1 ; + goto out; + } + + inode =ubifs_iget (ubifs_sb, inum); +if (IS_ERR (inode)) { +printf ("%s: Error reading inode %ld!\n" , __func__, inum); + err =PTR_ERR (inode); + goto out; + } + + *size = inode->i_size; + +ubifs_iput (inode); +out: +ubi_close_volume (c->ubi); +return err; +} +/* * ubifsload... */
@@ -875,6 +936,10 @@ out:return err; } +void ubifs_close (void ) +{ +} +/* Compat wrappers for common/cmd_ubifs.c */ int ubifs_load (char *filename,u32 addr,u32 size) {
include/ubifs_uboot.h +4 -0
@@ -21,8 +21,12 @@ void uboot_ubifs_umount(void);int ubifs_is_mounted (void );int ubifs_load (char *filename,u32 addr,u32 size); +int ubifs_set_blk_dev (block_dev_desc_t *rbdd,disk_partition_t *info);int ubifs_ls (const char *dir_name); +int ubifs_exists (const char *filename); +int ubifs_size (const char *filename,loff_t *size);int ubifs_read (const char *filename,void *buf,loff_t offset,loff_t size,loff_t *actread); +void ubifs_close (void );#endif /* __UBIFS_UBOOT_H__ */
Signature · 1 line
2.4.3
PATCH v2 3/5 ubifs: Add functions for generic fs use
Quoted 5 lines · Hans de Goede
Implement the necessary functions for implementing generic fs support for ubifs.
Signed-off-by Hans de Goede <[email protected]>Reviewed-by Heiko Schocher <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151024/50a0ca34/attachment.sig>
PATCH v2 4/5 ubifs: Add generic fs support
In reply to Hans de GoedeAdd generic fs support, so that commands like ls, load and test -e can be used on ubifs.
---
Changes in v2:
-Do not allow building in both hostfs and ubifs support as both use NULL
as magic blkdev
--- disk/part.c | 27 +++++++++++++++++++++++++++ fs/fs.c | 16 ++++++++++++++++ include/fs.h | 1 + 3 files changed, 44 insertions(+)
disk/part.c +27 -0
@@ -10,6 +10,7 @@#include <ide.h> #include <malloc.h> #include <part.h> +#include <ubifs_uboot.h> #undef PART_DEBUG
@@ -511,6 +512,10 @@ int get_device_and_partition(const char *ifname, const char *dev_part_str,int part;disk_partition_t tmpinfo; +#if definedCONFIG_SANDBOX && definedCONFIG_CMD_UBIFS +#error Only one of CONFIG_SANDBOX and CONFIG_CMD_UBIFS may be selected +#endif +#ifdef CONFIG_SANDBOX /* * Special-case a pseudo block device "hostfs", to allow access to the
@@ -532,6 +537,28 @@ int get_device_and_partition(const char *ifname, const char *dev_part_str, }#endif +#ifdef CONFIG_CMD_UBIFS +/* +* Special-case ubi, ubi goes through a mtd, rathen then through +* a regular block device. +*/ +if (0 ==strcmp (ifname,"ubi" )) { +if (!ubifs_is_mounted ()) { +printf ("UBIFS not mounted, use ubifsmount to mount volume first!\n" ); +return -1 ; + } + + *dev_desc =NULL ; +memset (info,0 ,sizeof (*info)); +strcpy ((char *)info->type,BOOT_PART_TYPE ); +strcpy ((char *)info->name,"UBI" ); +#ifdef CONFIG_PARTITION_UUIDS + info->uuid[0 ] =0 ; +#endif +return 0 ; + } +#endif +/* If no dev_part_str, use bootdevice environment variable */ if (!dev_part_str || !strlen (dev_part_str) || !strcmp (dev_part_str,"-" ))
fs/fs.c +16 -0
@@ -23,6 +23,7 @@#include <fat.h> #include <fs.h> #include <sandboxfs.h> +#include <ubifs_uboot.h> #include <asm/io.h> #include <div64.h> #include <linux/math64.h>
@@ -157,6 +158,21 @@ static struct fstype_info fstypes[] = { .uuid = fs_uuid_unsupported, },#endif +#ifdef CONFIG_CMD_UBIFS + { + .fstype = FS_TYPE_UBIFS, + .name = "ubifs", + .null_dev_desc_ok = true, + .probe = ubifs_set_blk_dev, + .close = ubifs_close, + .ls = ubifs_ls, + .exists = ubifs_exists, + .size = ubifs_size, + .read = ubifs_read, + .write = fs_write_unsupported, + .uuid = fs_uuid_unsupported, + }, +#endif { .fstype = FS_TYPE_ANY, .name = "unsupported",
include/fs.h +1 -0
@@ -22,6 +22,7 @@#define FS_TYPE_FAT 1#define FS_TYPE_EXT 2#define FS_TYPE_SANDBOX 3 +#define FS_TYPE_UBIFS 4/* * Tell the fs layer which block device an partition to use for future
Signature · 1 line
2.4.3
PATCH v2 4/5 ubifs: Add generic fs support
Quoted 5 lines · Hans de Goede
Add generic fs support, so that commands like ls, load and test -e can be used on ubifs.
Signed-off-by Hans de Goede <[email protected]>Reviewed-by Heiko Schocher <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151024/12eaf608/attachment.sig>
PATCH v2 5/5 distro_bootcmd: Add support for booting from ubifs
In reply to Hans de GoedeFrom: Roy Spliet <[email protected]>
Under the assumptions of having a UBI volume called boot, containing a ubifs filesystem.
---
Changes in v2:
-Added Stephen's ack
--- include/config_distro_bootcmd.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
include/config_distro_bootcmd.h +19 -0
@@ -72,6 +72,24 @@ BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC#endif +#ifdef CONFIG_CMD_UBIFS +#define BOOTENV_SHARED_UBIFS \ + "ubifs_boot=" \ + "if ubi part UBI && ubifsmount ubi${devnum}:boot; then " \ + "setenv devtype ubi; " \ + "setenv bootpart 0; " \ + "run scan_dev_for_boot; " \ + "fi\0" +#define BOOTENV_DEV_UBIFS BOOTENV_DEV_BLKDEV +#define BOOTENV_DEV_NAME_UBIFS BOOTENV_DEV_NAME_BLKDEV +#else +#define BOOTENV_SHARED_UBIFS +#define BOOTENV_DEV_UBIFS \ + BOOT_TARGET_DEVICES_references_UBIFS_without_CONFIG_CMD_UBIFS +#define BOOTENV_DEV_NAME_UBIFS \ + BOOT_TARGET_DEVICES_references_UBIFS_without_CONFIG_CMD_UBIFS +#endif +#ifdef CONFIG_CMD_SATA #define BOOTENV_SHARED_SATA BOOTENV_SHARED_BLKDEV(sata)#define BOOTENV_DEV_SATA BOOTENV_DEV_BLKDEV
@@ -185,6 +203,7 @@BOOTENV_SHARED_SATA \ BOOTENV_SHARED_SCSI \BOOTENV_SHARED_IDE \ + BOOTENV_SHARED_UBIFS \"boot_prefixes=/ /boot/\0" \"boot_scripts=boot.scr.uimg boot.scr\0" \"boot_script_dhcp=boot.scr.uimg\0" \
Signature · 1 line
2.4.3
PATCH v2 5/5 distro_bootcmd: Add support for booting from ubifs
Quoted 8 lines · Hans de Goede
From: Roy Spliet <[email protected]>
Under the assumptions of having a UBI volume called boot, containing a ubifs filesystem.
Signed-off-by Roy Spliet <[email protected]>Signed-off-by Hans de Goede <[email protected]>Acked-by Stephen Warren <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151024/3b9e5379/attachment.sig>
PATCH v2 1/5 disk/part: Only build hostfs special handling when CONFIG_SANDBOX is set
In reply to Hans de GoedeQuoted 3 lines · Hans de Goede
This is not necessary / useful when not building with
CONFIG_SANDBOXand with the addition of ubifs support to the generic fs commands it actually gets in the way, since both operate on a fake / NULL blkdev.
PATCH v2 1/5 disk/part: Only build hostfs special handling when CONFIG_SANDBOX is set
In reply to Hans de GoedeQuoted 6 lines · Hans de Goede
This is not necessary / useful when not building with
CONFIG_SANDBOXand with the addition of ubifs support to the generic fs commands it actually gets in the way, since both operate on a fake / NULL blkdev.Signed-off-by Hans de Goede <[email protected]>Acked-by Stephen Warren <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151024/0efbf693/attachment.sig>