mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* bootspec work
@ 2013-11-04 14:04 Sascha Hauer
  2013-11-04 14:04 ` [PATCH 01/11] kernel-install: Add missing error messages Sascha Hauer
                   ` (10 more replies)
  0 siblings, 11 replies; 15+ messages in thread
From: Sascha Hauer @ 2013-11-04 14:04 UTC (permalink / raw)
  To: barebox

The bootloader spec defines a single /boot per device. This is very
good for the general purpose distribution usecase. This extension
is mostly useful for embedded systems (for which barebox was written).
On embdedded systems we often have images which contain both a kernel
and a rootfilesystem. These images are sometimes written to a device
multiple times for redundancy reasons. With this series no longer a
single /boot is required, but instead bootspec entries can be on
every partition of a device. So now we can not only 'boot emmc0', but
also 'boot emmc0.1' for booting a partition on am emmc device.
Also now a path containing bootspec entries can be given which will
be useful for NFS boot for example.

Sascha

----------------------------------------------------------------
Sascha Hauer (11):
      kernel-install: Add missing error messages
      blspec: Push device_detect into blspec_scan_device
      blspec: rename _hwdevice functions to _devicename
      blspec: Allow to boot partitions
      blspec: Let scan functions return the number of entries found
      fs: Add function to get cdev by mountpath
      blspec: make cdev optional
      boot: Print boot entries in the order they are
      boot command: make more flexible
      blspec: Make error message more clear
      boot command: Add timeout support for menu

 commands/boot.c          | 351 ++++++++++++++++++++++++++++-------------------
 common/blspec.c          | 104 +++++++++-----
 fs/fs.c                  |  13 ++
 include/blspec.h         |   7 +-
 include/fs.h             |   2 +
 scripts/kernel-install.c |  12 +-
 6 files changed, 307 insertions(+), 182 deletions(-)

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 01/11] kernel-install: Add missing error messages
  2013-11-04 14:04 bootspec work Sascha Hauer
@ 2013-11-04 14:04 ` Sascha Hauer
  2013-11-04 14:04 ` [PATCH 02/11] blspec: Push device_detect into blspec_scan_device Sascha Hauer
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2013-11-04 14:04 UTC (permalink / raw)
  To: barebox

In some cases kernel-install can fail without printing anything. Add
error messages for these cases.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 scripts/kernel-install.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/scripts/kernel-install.c b/scripts/kernel-install.c
index 6086357..459b45d 100644
--- a/scripts/kernel-install.c
+++ b/scripts/kernel-install.c
@@ -533,6 +533,7 @@ static char *mount_path(char *in_path, int *newmount)
 			*newmount = 1;
 			return out_path;
 		}
+		fprintf(stderr, "cannot mount %s\n", in_path);
 		return NULL;
 	case MOUNT_MOUNT:
 		out_path = mount_path_mount(in_path);
@@ -540,6 +541,7 @@ static char *mount_path(char *in_path, int *newmount)
 			*newmount = 1;
 			return out_path;
 		}
+		fprintf(stderr, "cannot mount %s\n", in_path);
 		return NULL;
 	}
 
@@ -789,12 +791,18 @@ static int do_add_kernel(void)
 	}
 
 	ret = make_directory(conf_dir);
-	if (ret)
+	if (ret) {
+		fprintf(stderr, "failed to create directory %s: %s\n",
+				conf_dir, strerror(errno));
 		return ret;
+	}
 
 	ret = make_directory(host_images_dir);
-	if (ret)
+	if (ret) {
+		fprintf(stderr, "failed to create directory %s: %s\n",
+				host_images_dir, strerror(errno));
 		return ret;
+	}
 
 	fd = open(conf_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
 	if (fd < 0) {
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 02/11] blspec: Push device_detect into blspec_scan_device
  2013-11-04 14:04 bootspec work Sascha Hauer
  2013-11-04 14:04 ` [PATCH 01/11] kernel-install: Add missing error messages Sascha Hauer
@ 2013-11-04 14:04 ` Sascha Hauer
  2013-11-04 14:04 ` [PATCH 03/11] blspec: rename _hwdevice functions to _devicename Sascha Hauer
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2013-11-04 14:04 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/blspec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/blspec.c b/common/blspec.c
index a564602..dd8ec4b 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -317,6 +317,8 @@ int blspec_scan_device(struct blspec *blspec, struct device_d *dev)
 
 	pr_debug("%s: %s\n", __func__, dev_name(dev));
 
+	device_detect(dev);
+
 	list_for_each_entry(cdev, &dev->cdevs, devices_list) {
 		/*
 		 * If the OS is installed on a disk with MBR disk label, and a
@@ -374,8 +376,6 @@ int blspec_scan_hwdevice(struct blspec *blspec, const char *devname)
 	if (!dev)
 		return -ENODEV;
 
-	device_detect(dev);
-
 	blspec_scan_device(blspec, dev);
 
 	return 0;
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 03/11] blspec: rename _hwdevice functions to _devicename
  2013-11-04 14:04 bootspec work Sascha Hauer
  2013-11-04 14:04 ` [PATCH 01/11] kernel-install: Add missing error messages Sascha Hauer
  2013-11-04 14:04 ` [PATCH 02/11] blspec: Push device_detect into blspec_scan_device Sascha Hauer
@ 2013-11-04 14:04 ` Sascha Hauer
  2013-11-04 14:04 ` [PATCH 04/11] blspec: Allow to boot partitions Sascha Hauer
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2013-11-04 14:04 UTC (permalink / raw)
  To: barebox

Since it's not necessarily the hardware device this seems to
be a more appropriate name.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/boot.c  |  2 +-
 common/blspec.c  | 10 +++++-----
 include/blspec.h |  4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/commands/boot.c b/commands/boot.c
index 8105889..f2d9836 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -219,7 +219,7 @@ static int boot(const char *name)
 			goto out;
 		}
 
-		ret = blspec_boot_hwdevice(name, verbose, dryrun);
+		ret = blspec_boot_devicename(name, verbose, dryrun);
 		pr_err("%s: %s\n", name, strerror(-ret));
 		goto out;
 	}
diff --git a/common/blspec.c b/common/blspec.c
index dd8ec4b..8ae09a2 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -361,12 +361,12 @@ int blspec_scan_device(struct blspec *blspec, struct device_d *dev)
 }
 
 /*
- * blspec_scan_hwdevice - scan a hardware device for child cdevs
+ * blspec_scan_devicename - scan a hardware device for child cdevs
  *
  * Given a name of a hardware device this functions scans over all child
  * cdevs looking for blspec entries.
  */
-int blspec_scan_hwdevice(struct blspec *blspec, const char *devname)
+int blspec_scan_devicename(struct blspec *blspec, const char *devname)
 {
 	struct device_d *dev;
 
@@ -488,10 +488,10 @@ struct blspec_entry *blspec_entry_default(struct blspec *l)
 }
 
 /*
- * blspec_boot_hwdevice - scan hardware device for blspec entries and
+ * blspec_boot_devicename - scan hardware device for blspec entries and
  *                        start the best one.
  */
-int blspec_boot_hwdevice(const char *devname, int verbose, int dryrun)
+int blspec_boot_devicename(const char *devname, int verbose, int dryrun)
 {
 	struct blspec *blspec;
 	struct blspec_entry *e;
@@ -499,7 +499,7 @@ int blspec_boot_hwdevice(const char *devname, int verbose, int dryrun)
 
 	blspec = blspec_alloc();
 
-	ret = blspec_scan_hwdevice(blspec, devname);
+	ret = blspec_scan_devicename(blspec, devname);
 	if (ret)
 		return ret;
 
diff --git a/include/blspec.h b/include/blspec.h
index aa836e6..a7b189a 100644
--- a/include/blspec.h
+++ b/include/blspec.h
@@ -31,12 +31,12 @@ int blspec_entry_save(struct blspec_entry *entry, const char *path);
 
 int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun);
 
-int blspec_boot_hwdevice(const char *devname, int verbose, int dryrun);
+int blspec_boot_devicename(const char *devname, int verbose, int dryrun);
 
 void blspec_scan_devices(struct blspec *blspec);
 
 struct blspec_entry *blspec_entry_default(struct blspec *l);
-int blspec_scan_hwdevice(struct blspec *blspec, const char *devname);
+int blspec_scan_devicename(struct blspec *blspec, const char *devname);
 
 #define blspec_for_each_entry(blspec, entry) \
 	list_for_each_entry(entry, &blspec->entries, list)
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 04/11] blspec: Allow to boot partitions
  2013-11-04 14:04 bootspec work Sascha Hauer
                   ` (2 preceding siblings ...)
  2013-11-04 14:04 ` [PATCH 03/11] blspec: rename _hwdevice functions to _devicename Sascha Hauer
@ 2013-11-04 14:04 ` Sascha Hauer
  2013-11-04 14:04 ` [PATCH 05/11] blspec: Let scan functions return the number of entries found Sascha Hauer
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2013-11-04 14:04 UTC (permalink / raw)
  To: barebox

Instead of only allowing complete devices we now also allow single
partitions to look for bootloader spec entries.

Normally the bootloader spec defines a way to find a partition containing /boot
on a device.  On embedded systems it's often useful instead to have only a
single partition image which contains both the kernel and the root filesystems.
This partition image may be written to the device multiple times. With this
patch they can be booted with 'boot emmc0.<partno>'

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/blspec.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/common/blspec.c b/common/blspec.c
index 8ae09a2..bf833da 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -369,9 +369,26 @@ int blspec_scan_device(struct blspec *blspec, struct device_d *dev)
 int blspec_scan_devicename(struct blspec *blspec, const char *devname)
 {
 	struct device_d *dev;
+	struct cdev *cdev;
+	const char *colon;
 
 	pr_debug("%s: %s\n", __func__, devname);
 
+	colon = strchr(devname, '.');
+	if (colon) {
+		char *name = xstrdup(devname);
+		*strchr(name, '.') = 0;
+		device_detect_by_name(name);
+		free(name);
+	}
+
+	cdev = cdev_by_name(devname);
+	if (cdev) {
+		int ret = blspec_scan_cdev(blspec, cdev);
+		if (!ret)
+			return 0;
+	}
+
 	dev = get_device_by_name(devname);
 	if (!dev)
 		return -ENODEV;
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 05/11] blspec: Let scan functions return the number of entries found
  2013-11-04 14:04 bootspec work Sascha Hauer
                   ` (3 preceding siblings ...)
  2013-11-04 14:04 ` [PATCH 04/11] blspec: Allow to boot partitions Sascha Hauer
@ 2013-11-04 14:04 ` Sascha Hauer
  2013-11-04 14:04 ` [PATCH 06/11] fs: Add function to get cdev by mountpath Sascha Hauer
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2013-11-04 14:04 UTC (permalink / raw)
  To: barebox

So that callers can detect whether entries are found or not.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/blspec.c  | 53 +++++++++++++++++++++++++++++++++--------------------
 include/blspec.h |  2 +-
 2 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/common/blspec.c b/common/blspec.c
index bf833da..20af235 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -207,7 +207,7 @@ static int blspec_scan_directory(struct blspec *blspec, const char *root,
 			continue;
 		}
 
-		found = 1;
+		found++;
 
 		entry->rootpath = xstrdup(root);
 		entry->configpath = configname;
@@ -232,7 +232,7 @@ static int blspec_scan_directory(struct blspec *blspec, const char *root,
 		entry->me.type = MENU_ENTRY_NORMAL;
 	}
 
-	ret = found ? 0 : -ENOENT;
+	ret = found;
 
 	closedir(dir);
 err_out:
@@ -249,8 +249,8 @@ err_out:
  * Given a cdev this function mounts the filesystem and collects all blspec
  * entries found under /blspec/entries/.
  *
- * returns 0 if at least one entry could be successfully loaded, negative
- * error value otherwise.
+ * returns the number of entries found or a negative error code if some unexpected
+ * error occured.
  */
 static int blspec_scan_cdev(struct blspec *blspec, struct cdev *cdev)
 {
@@ -286,11 +286,14 @@ static int blspec_scan_cdev(struct blspec *blspec, struct cdev *cdev)
  * blspec_scan_devices - scan all devices for child cdevs
  *
  * Iterate over all devices and collect child their cdevs.
+ * Returns the number of entries found or a negative error code if some unexpected
+ * error occured.
  */
-void blspec_scan_devices(struct blspec *blspec)
+int blspec_scan_devices(struct blspec *blspec)
 {
 	struct device_d *dev;
 	struct block_device *bdev;
+	int ret, found = 0;
 
 	for_each_device(dev)
 		device_detect(dev);
@@ -298,9 +301,14 @@ void blspec_scan_devices(struct blspec *blspec)
 	for_each_block_device(bdev) {
 		struct cdev *cdev = &bdev->cdev;
 
-		list_for_each_entry(cdev, &bdev->dev->cdevs, devices_list)
-			blspec_scan_cdev(blspec, cdev);
+		list_for_each_entry(cdev, &bdev->dev->cdevs, devices_list) {
+			ret = blspec_scan_cdev(blspec, cdev);
+			if (ret > 0)
+				found += ret;
+		}
 	}
+
+	return found;
 }
 
 /*
@@ -308,12 +316,14 @@ void blspec_scan_devices(struct blspec *blspec)
  *
  * Given a device this functions scans over all child cdevs looking
  * for blspec entries.
+ * Returns the number of entries found or a negative error code if some unexpected
+ * error occured.
  */
 int blspec_scan_device(struct blspec *blspec, struct device_d *dev)
 {
 	struct device_d *child;
 	struct cdev *cdev;
-	int ret;
+	int ret, found = 0;
 
 	pr_debug("%s: %s\n", __func__, dev_name(dev));
 
@@ -326,8 +336,11 @@ int blspec_scan_device(struct blspec *blspec, struct device_d *dev)
 		 * should be used as $BOOT
 		 */
 		if (cdev->dos_partition_type == 0xea) {
-			blspec_scan_cdev(blspec, cdev);
-			return 0;
+			ret = blspec_scan_cdev(blspec, cdev);
+			if (ret == 0)
+				ret = -ENOENT;
+
+			return ret;
 		}
 
 		/*
@@ -343,8 +356,8 @@ int blspec_scan_device(struct blspec *blspec, struct device_d *dev)
 	/* Try child devices */
 	device_for_each_child(dev, child) {
 		ret = blspec_scan_device(blspec, child);
-		if (!ret)
-			return 0;
+		if (ret > 0)
+			return ret;
 	}
 
 	/*
@@ -353,11 +366,11 @@ int blspec_scan_device(struct blspec *blspec, struct device_d *dev)
 	 */
 	list_for_each_entry(cdev, &dev->cdevs, devices_list) {
 		ret = blspec_scan_cdev(blspec, cdev);
-		if (!ret)
-			return 0;
+		if (ret > 0)
+			found += ret;
 	}
 
-	return -ENODEV;
+	return found;
 }
 
 /*
@@ -365,6 +378,8 @@ int blspec_scan_device(struct blspec *blspec, struct device_d *dev)
  *
  * Given a name of a hardware device this functions scans over all child
  * cdevs looking for blspec entries.
+ * Returns the number of entries found or a negative error code if some unexpected
+ * error occured.
  */
 int blspec_scan_devicename(struct blspec *blspec, const char *devname)
 {
@@ -385,17 +400,15 @@ int blspec_scan_devicename(struct blspec *blspec, const char *devname)
 	cdev = cdev_by_name(devname);
 	if (cdev) {
 		int ret = blspec_scan_cdev(blspec, cdev);
-		if (!ret)
-			return 0;
+		if (ret > 0)
+			return ret;
 	}
 
 	dev = get_device_by_name(devname);
 	if (!dev)
 		return -ENODEV;
 
-	blspec_scan_device(blspec, dev);
-
-	return 0;
+	return blspec_scan_device(blspec, dev);
 }
 
 /*
diff --git a/include/blspec.h b/include/blspec.h
index a7b189a..7b483d3 100644
--- a/include/blspec.h
+++ b/include/blspec.h
@@ -33,7 +33,7 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun);
 
 int blspec_boot_devicename(const char *devname, int verbose, int dryrun);
 
-void blspec_scan_devices(struct blspec *blspec);
+int blspec_scan_devices(struct blspec *blspec);
 
 struct blspec_entry *blspec_entry_default(struct blspec *l);
 int blspec_scan_devicename(struct blspec *blspec, const char *devname);
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 06/11] fs: Add function to get cdev by mountpath
  2013-11-04 14:04 bootspec work Sascha Hauer
                   ` (4 preceding siblings ...)
  2013-11-04 14:04 ` [PATCH 05/11] blspec: Let scan functions return the number of entries found Sascha Hauer
@ 2013-11-04 14:04 ` Sascha Hauer
  2013-11-04 14:04 ` [PATCH 07/11] blspec: make cdev optional Sascha Hauer
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2013-11-04 14:04 UTC (permalink / raw)
  To: barebox

This is useful to know for the bootloader spec implementation.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/fs.c      | 13 +++++++++++++
 include/fs.h |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/fs/fs.c b/fs/fs.c
index 7d558e9..4563a81 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -283,6 +283,19 @@ static struct fs_device_d *get_fsdevice_by_path(const char *path)
 	return fs_dev_root;
 }
 
+/*
+ * get_cdev_by_mountpath - return the cdev the given path
+ *                         is mounted on
+ */
+struct cdev *get_cdev_by_mountpath(const char *path)
+{
+	struct fs_device_d *fsdev;
+
+	fsdev = get_fsdevice_by_path(path);
+
+	return fsdev->cdev;
+}
+
 char *get_mounted_path(const char *path)
 {
 	struct fs_device_d *fdev;
diff --git a/include/fs.h b/include/fs.h
index 99f1689..856e00a 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -184,6 +184,8 @@ char *normalise_link(const char *pathname, const char* symlink);
 
 char *get_mounted_path(const char *path);
 
+struct cdev *get_cdev_by_mountpath(const char *path);
+
 /* Register a new filesystem driver */
 int register_fs_driver(struct fs_driver_d *fsdrv);
 
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 07/11] blspec: make cdev optional
  2013-11-04 14:04 bootspec work Sascha Hauer
                   ` (5 preceding siblings ...)
  2013-11-04 14:04 ` [PATCH 06/11] fs: Add function to get cdev by mountpath Sascha Hauer
@ 2013-11-04 14:04 ` Sascha Hauer
  2013-11-04 22:21   ` Alexander Aring
  2013-11-04 14:04 ` [PATCH 08/11] boot: Print boot entries in the order they are Sascha Hauer
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 15+ messages in thread
From: Sascha Hauer @ 2013-11-04 14:04 UTC (permalink / raw)
  To: barebox

the cdev for a given directory can be determined by get_cdev_by_mountpath().
Use this function and remove the cdev argument from blspec_scan_directory().
Also, export the function to make code possible which boots the bootloader
spec entries found in directories.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/blspec.c  | 22 +++++++++++++---------
 include/blspec.h |  1 +
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/common/blspec.c b/common/blspec.c
index 20af235..cfefd26 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -138,8 +138,7 @@ static int blspec_have_entry(struct blspec *blspec, const char *path)
  * returns 0 if at least one entry could be successfully loaded, negative
  * error value otherwise.
  */
-static int blspec_scan_directory(struct blspec *blspec, const char *root,
-		struct cdev *cdev)
+int blspec_scan_directory(struct blspec *blspec, const char *root)
 {
 	struct blspec_entry *entry;
 	DIR *dir;
@@ -211,7 +210,7 @@ static int blspec_scan_directory(struct blspec *blspec, const char *root,
 
 		entry->rootpath = xstrdup(root);
 		entry->configpath = configname;
-		entry->cdev = cdev;
+		entry->cdev = get_cdev_by_mountpath(root);
 
 		name = asprintf("%s/%s", dirname, d->d_name);
 		if (entry_default && !strcmp(name, entry_default))
@@ -220,12 +219,17 @@ static int blspec_scan_directory(struct blspec *blspec, const char *root,
 			entry->boot_once = true;
 		free(name);
 
-		devname = xstrdup(dev_name(entry->cdev->dev));
-		if (entry->cdev->dev->parent)
-			hwdevname = xstrdup(dev_name(entry->cdev->dev->parent));
+		if (entry->cdev) {
+			devname = xstrdup(dev_name(entry->cdev->dev));
+			if (entry->cdev->dev->parent)
+				hwdevname = xstrdup(dev_name(entry->cdev->dev->parent));
+		}
 
-		entry->me.display = asprintf("%-20s %-20s  %s", devname, hwdevname,
+		entry->me.display = asprintf("%-20s %-20s  %s",
+				devname ? devname : "",
+				hwdevname ? hwdevname : "",
 				blspec_entry_var_get(entry, "title"));
+
 		free(devname);
 		free(hwdevname);
 
@@ -277,7 +281,7 @@ static int blspec_scan_cdev(struct blspec *blspec, struct cdev *cdev)
 	if (IS_ERR(rootpath))
 		return PTR_ERR(rootpath);
 
-	ret = blspec_scan_directory(blspec, rootpath, cdev);
+	ret = blspec_scan_directory(blspec, rootpath);
 
 	return ret;
 }
@@ -461,7 +465,7 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
 	globalvar_add_simple("linux.bootargs.blspec", options);
 
 	pr_info("booting %s from %s\n", blspec_entry_var_get(entry, "title"),
-			dev_name(entry->cdev->dev));
+			entry->cdev ? dev_name(entry->cdev->dev) : "none");
 
 	if (entry->boot_once) {
 		char *s = asprintf("%s/once", abspath);
diff --git a/include/blspec.h b/include/blspec.h
index 7b483d3..66d2e84 100644
--- a/include/blspec.h
+++ b/include/blspec.h
@@ -37,6 +37,7 @@ int blspec_scan_devices(struct blspec *blspec);
 
 struct blspec_entry *blspec_entry_default(struct blspec *l);
 int blspec_scan_devicename(struct blspec *blspec, const char *devname);
+int blspec_scan_directory(struct blspec *blspec, const char *root);
 
 #define blspec_for_each_entry(blspec, entry) \
 	list_for_each_entry(entry, &blspec->entries, list)
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 08/11] boot: Print boot entries in the order they are
  2013-11-04 14:04 bootspec work Sascha Hauer
                   ` (6 preceding siblings ...)
  2013-11-04 14:04 ` [PATCH 07/11] blspec: make cdev optional Sascha Hauer
@ 2013-11-04 14:04 ` Sascha Hauer
  2013-11-04 14:04 ` [PATCH 09/11] boot command: make more flexible Sascha Hauer
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2013-11-04 14:04 UTC (permalink / raw)
  To: barebox

Instead of first printing the traditional entries and the bootloader
spec entries afterwards.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/boot.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/commands/boot.c b/commands/boot.c
index f2d9836..2162365 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -132,25 +132,15 @@ static void bootsources_list(void)
 
 	blspec = bootentries_collect();
 
-	printf("\nBootscripts:\n\n");
-	printf("%-40s   %-20s\n", "name", "title");
-	printf("%-40s   %-20s\n", "----", "-----");
+	printf("%-20s %-20s  %s\n", "device", "hwdevice", "title");
+	printf("%-20s %-20s  %s\n", "------", "--------", "-----");
 
 	blspec_for_each_entry(blspec, entry) {
 		if (entry->scriptpath)
 			printf("%-40s   %s\n", basename(entry->scriptpath), entry->me.display);
-	}
-
-	if (!IS_ENABLED(CONFIG_BLSPEC))
-		return;
-
-	printf("\nBootloader spec entries:\n\n");
-	printf("%-20s %-20s  %s\n", "device", "hwdevice", "title");
-	printf("%-20s %-20s  %s\n", "------", "--------", "-----");
-
-	blspec_for_each_entry(blspec, entry)
-		if (!entry->scriptpath)
+		else
 			printf("%s\n", entry->me.display);
+	}
 
 	blspec_free(blspec);
 }
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 09/11] boot command: make more flexible
  2013-11-04 14:04 bootspec work Sascha Hauer
                   ` (7 preceding siblings ...)
  2013-11-04 14:04 ` [PATCH 08/11] boot: Print boot entries in the order they are Sascha Hauer
@ 2013-11-04 14:04 ` Sascha Hauer
  2013-11-04 14:04 ` [PATCH 10/11] blspec: Make error message more clear Sascha Hauer
  2013-11-04 14:04 ` [PATCH 11/11] boot command: Add timeout support for menu Sascha Hauer
  10 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2013-11-04 14:04 UTC (permalink / raw)
  To: barebox

With this we can do 'boot <name>' where name is one of:

 - a filename under /env/boot/
 - a full path to a boot script
 - a device name
 - a partition name under /dev/
 - a full path to a directory which
   - contains boot scripts, or
   - contains a loader/entries/ directory containing bootspec entries

Multiple names can be given, they are tried in order. So any mixture
between bootspec entries and bootscripts can be given. bootspec entries
can now also be given as a path to a directory containing bootspec entries.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/boot.c | 321 ++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 194 insertions(+), 127 deletions(-)

diff --git a/commands/boot.c b/commands/boot.c
index 2162365..1bec406 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -28,25 +28,68 @@
 
 #include <linux/stat.h>
 
-static int boot_script(char *path);
-
 static int verbose;
 static int dryrun;
 
-static void bootsource_action(struct menu *m, struct menu_entry *me)
+/*
+ * Start a single boot script. 'path' is a full path to a boot script.
+ */
+static int boot_script(char *path)
+{
+	int ret;
+	struct bootm_data data = {
+		.os_address = UIMAGE_SOME_ADDRESS,
+		.initrd_address = UIMAGE_SOME_ADDRESS,
+	};
+
+	globalvar_set_match("linux.bootargs.dyn.", "");
+	globalvar_set_match("bootm.", "");
+
+	ret = run_command(path, 0);
+	if (ret) {
+		printf("Running %s failed\n", path);
+		goto out;
+	}
+
+	data.initrd_address = UIMAGE_INVALID_ADDRESS;
+	data.os_address = UIMAGE_SOME_ADDRESS;
+	data.oftree_file = getenv_nonempty("global.bootm.oftree");
+	data.os_file = getenv_nonempty("global.bootm.image");
+	getenv_ul("global.bootm.image.loadaddr", &data.os_address);
+	getenv_ul("global.bootm.initrd.loadaddr", &data.initrd_address);
+	data.initrd_file = getenv_nonempty("global.bootm.initrd");
+	data.verbose = verbose;
+	data.dryrun = dryrun;
+
+	ret = bootm_boot(&data);
+	if (ret)
+		pr_err("Booting %s failed: %s\n", basename(path), strerror(-ret));
+out:
+	return ret;
+}
+
+static int boot_entry(struct blspec_entry *be)
 {
-	struct blspec_entry *be = container_of(me, struct blspec_entry, me);
 	int ret;
 
 	if (be->scriptpath) {
 		ret = boot_script(be->scriptpath);
 	} else {
 		if (IS_ENABLED(CONFIG_BLSPEC))
-			ret = blspec_boot(be, 0, 0);
+			ret = blspec_boot(be, verbose, dryrun);
 		else
 			ret = -ENOSYS;
 	}
 
+	return ret;
+}
+
+static void bootsource_action(struct menu *m, struct menu_entry *me)
+{
+	struct blspec_entry *be = container_of(me, struct blspec_entry, me);
+	int ret;
+
+	ret = boot_entry(be);
 	if (ret)
 		printf("Booting failed with: %s\n", strerror(-ret));
 
@@ -55,46 +98,140 @@ static void bootsource_action(struct menu *m, struct menu_entry *me)
 	read_key();
 }
 
-static int bootsources_menu_env_entries(struct blspec *blspec)
+/*
+ * bootscript_create_entry - create a boot entry from a script name
+ */
+static int bootscript_create_entry(struct blspec *blspec, const char *name)
+{
+	struct blspec_entry *be;
+
+	be = blspec_entry_alloc(blspec);
+	be->me.type = MENU_ENTRY_NORMAL;
+	be->scriptpath = xstrdup(name);
+	be->me.display = xstrdup(basename(be->scriptpath));
+
+	return 0;
+}
+
+/*
+ * bootscript_scan_path - create boot entries from a path
+ *
+ * path can either be a full path to a bootscript or a full path to a diretory
+ * containing bootscripts.
+ */
+static int bootscript_scan_path(struct blspec *blspec, const char *path)
 {
-	const char *path = "/env/boot";
+	struct stat s;
 	DIR *dir;
 	struct dirent *d;
-	struct blspec_entry *be;
+	int ret;
+	int found = 0;
+
+	ret = stat(path, &s);
+	if (ret)
+		return ret;
+
+	if (!S_ISDIR(s.st_mode)) {
+		ret = bootscript_create_entry(blspec, path);
+		if (ret)
+			return ret;
+		return 1;
+	}
 
 	dir = opendir(path);
 	if (!dir)
 		return -errno;
 
 	while ((d = readdir(dir))) {
+		char *bootscript_path;
 
 		if (*d->d_name == '.')
 			continue;
 
-		be = blspec_entry_alloc(blspec);
-		be->me.type = MENU_ENTRY_NORMAL;
-		be->scriptpath = asprintf("/env/boot/%s", d->d_name);
-		be->me.display = xstrdup(d->d_name);
+		bootscript_path = asprintf("%s/%s", path, d->d_name);
+		bootscript_create_entry(blspec, bootscript_path);
+		found++;
+		free(bootscript_path);
 	}
 
+	ret = found;
+
 	closedir(dir);
 
-	return 0;
+	return ret;
+}
+
+/*
+ * bootentry_parse_one - create boot entries from a name
+ *
+ * name can be:
+ * - a name of a boot script under /env/boot
+ * - a full path of a boot script
+ * - a device name
+ * - a cdev name
+ * - a full path of a directory containing bootloader spec entries
+ * - a full path of a directory containing bootscripts
+ *
+ * Returns the number of entries found or a negative error code.
+ */
+static int bootentry_parse_one(struct blspec *blspec, const char *name)
+{
+	int found = 0, ret;
+
+	if (IS_ENABLED(CONFIG_BLSPEC)) {
+		ret = blspec_scan_devicename(blspec, name);
+		if (ret > 0)
+			found += ret;
+		ret = blspec_scan_directory(blspec, name);
+		if (ret > 0)
+			found += ret;
+	}
+
+	if (!found) {
+		char *path;
+
+		if (*name != '/')
+			path = asprintf("/env/boot/%s", name);
+		else
+			path = xstrdup(name);
+
+		ret = bootscript_scan_path(blspec, path);
+		if (ret > 0)
+			found += ret;
+
+		free(path);
+	}
+
+	return found;
 }
 
-static struct blspec *bootentries_collect(void)
+/*
+ * bootentries_collect - collect bootentries from an array of names
+ */
+static struct blspec *bootentries_collect(char *entries[], int num_entries)
 {
 	struct blspec *blspec;
+	int i;
 
 	blspec = blspec_alloc();
 	blspec->menu->display = asprintf("boot");
-	bootsources_menu_env_entries(blspec);
-	if (IS_ENABLED(CONFIG_BLSPEC))
+
+	if (!num_entries)
+		bootscript_scan_path(blspec, "/env/boot");
+
+	if (IS_ENABLED(CONFIG_BLSPEC) && !num_entries)
 		blspec_scan_devices(blspec);
+
+	for (i = 0; i < num_entries; i++)
+		bootentry_parse_one(blspec, entries[i]);
+
 	return blspec;
 }
 
-static void bootsources_menu(void)
+/*
+ * bootsources_menu - show a menu from an array of names
+ */
+static void bootsources_menu(char *entries[], int num_entries)
 {
 	struct blspec *blspec = NULL;
 	struct blspec_entry *entry;
@@ -105,7 +242,7 @@ static void bootsources_menu(void)
 		return;
 	}
 
-	blspec = bootentries_collect();
+	blspec = bootentries_collect(entries, num_entries);
 
 	blspec_for_each_entry(blspec, entry) {
 		entry->me.action = bootsource_action;
@@ -125,12 +262,15 @@ static void bootsources_menu(void)
 	blspec_free(blspec);
 }
 
-static void bootsources_list(void)
+/*
+ * bootsources_list - list boot entries from an array of names
+ */
+static void bootsources_list(char *entries[], int num_entries)
 {
 	struct blspec *blspec;
 	struct blspec_entry *entry;
 
-	blspec = bootentries_collect();
+	blspec = bootentries_collect(entries, num_entries);
 
 	printf("%-20s %-20s  %s\n", "device", "hwdevice", "title");
 	printf("%-20s %-20s  %s\n", "------", "--------", "-----");
@@ -146,118 +286,41 @@ static void bootsources_list(void)
 }
 
 /*
- * Start a single boot script. 'path' is a full path to a boot script.
- */
-static int boot_script(char *path)
-{
-	int ret;
-	struct bootm_data data = {
-		.os_address = UIMAGE_SOME_ADDRESS,
-		.initrd_address = UIMAGE_SOME_ADDRESS,
-	};
-
-	printf("booting %s...\n", basename(path));
-
-	globalvar_set_match("linux.bootargs.dyn.", "");
-	globalvar_set_match("bootm.", "");
-
-	ret = run_command(path, 0);
-	if (ret) {
-		printf("Running %s failed\n", path);
-		goto out;
-	}
-
-	data.initrd_address = UIMAGE_INVALID_ADDRESS;
-	data.os_address = UIMAGE_SOME_ADDRESS;
-	data.oftree_file = getenv_nonempty("global.bootm.oftree");
-	data.os_file = getenv_nonempty("global.bootm.image");
-	getenv_ul("global.bootm.image.loadaddr", &data.os_address);
-	getenv_ul("global.bootm.initrd.loadaddr", &data.initrd_address);
-	data.initrd_file = getenv_nonempty("global.bootm.initrd");
-	data.verbose = verbose;
-	data.dryrun = dryrun;
-
-	ret = bootm_boot(&data);
-	if (ret)
-		pr_err("Booting %s failed: %s\n", basename(path), strerror(-ret));
-out:
-	return ret;
-}
-
-/*
- * boot a script. 'name' can either be a filename under /env/boot/,
- * a full path to a boot script or a path to a directory. This function
- * returns a negative error on failure, or 0 on a successful dryrun boot.
+ * boot a script or a bootspec entry. 'name' can be:
+ * - a filename under /env/boot/
+ * - a full path to a boot script
+ * - a device name
+ * - a partition name under /dev/
+ * - a full path to a directory which
+ *   - contains boot scripts, or
+ *   - contains a loader/entries/ directory containing bootspec entries
+ *
+ * Returns a negative error on failure, or 0 on a successful dryrun boot.
  */
 static int boot(const char *name)
 {
-	char *path;
-	DIR *dir;
-	struct dirent *d;
-	struct stat s;
-	int ret;
-
-	if (*name == '/')
-		path = xstrdup(name);
-	else
-		path = asprintf("/env/boot/%s", name);
-
-	ret = stat(path, &s);
-	if (ret) {
-		if (!IS_ENABLED(CONFIG_BLSPEC)) {
-			pr_err("%s: %s\n", path, strerror(-ret));
-			goto out;
-		}
-
-		ret = blspec_boot_devicename(name, verbose, dryrun);
-		pr_err("%s: %s\n", name, strerror(-ret));
-		goto out;
-	}
+	struct blspec *blspec;
+	struct blspec_entry *entry;
+	int ret = -ENOENT;
 
-	if (S_ISREG(s.st_mode)) {
-		ret = boot_script(path);
-		goto out;
-	}
+	blspec = blspec_alloc();
+	ret = bootentry_parse_one(blspec, name);
+	if (ret < 0)
+		return ret;
 
-	dir = opendir(path);
-	if (!dir) {
-		ret = -errno;
-		printf("cannot open %s: %s\n", path, strerror(-errno));
-		goto out;
+	if (!ret) {
+		printf("Nothing bootable found on %s\n", name);
+		return -ENOENT;
 	}
 
-	while ((d = readdir(dir))) {
-		char *file;
-		struct stat s;
-
-		if (*d->d_name == '.')
-			continue;
-
-		file = asprintf("%s/%s", path, d->d_name);
-
-		ret = stat(file, &s);
-		if (ret) {
-			free(file);
-			continue;
-		}
-
-		if (!S_ISREG(s.st_mode)) {
-			free(file);
-			continue;
-		}
-
-		ret = boot_script(file);
-
-                free(file);
-
+	blspec_for_each_entry(blspec, entry) {
+		printf("booting %s\n", entry->me.display);
+		ret = boot_entry(entry);
 		if (!ret)
 			break;
+		printf("booting %s failed: %s\n", entry->me.display, strerror(-ret));
 	}
 
-	closedir(dir);
-out:
-	free(path);
-
 	return ret;
 }
 
@@ -288,12 +351,12 @@ static int do_boot(int argc, char *argv[])
 	}
 
 	if (do_list) {
-		bootsources_list();
+		bootsources_list(&argv[optind], argc - optind);
 		return 0;
 	}
 
 	if (do_menu) {
-		bootsources_menu();
+		bootsources_menu(&argv[optind], argc - optind);
 		return 0;
 	}
 
@@ -337,10 +400,14 @@ BAREBOX_CMD_HELP_START(boot)
 BAREBOX_CMD_HELP_USAGE("boot [OPTIONS] [BOOTSRC...]\n")
 BAREBOX_CMD_HELP_SHORT("Boot an operating system.\n")
 BAREBOX_CMD_HELP_SHORT("[BOOTSRC...] can be:\n")
-BAREBOX_CMD_HELP_SHORT("- a filename from /env/boot/\n")
-BAREBOX_CMD_HELP_SHORT("- a full path to a file\n")
-BAREBOX_CMD_HELP_SHORT("- a path to a directory. All files in this directory are treated\n")
-BAREBOX_CMD_HELP_SHORT("  as boot scripts.\n")
+BAREBOX_CMD_HELP_SHORT("- a filename under /env/boot/\n")
+BAREBOX_CMD_HELP_SHORT("- a full path to a boot script\n")
+BAREBOX_CMD_HELP_SHORT("- a device name\n")
+BAREBOX_CMD_HELP_SHORT("- a partition name under /dev/\n")
+BAREBOX_CMD_HELP_SHORT("- a full path to a directory which\n")
+BAREBOX_CMD_HELP_SHORT("   - contains boot scripts, or\n")
+BAREBOX_CMD_HELP_SHORT("   - contains a loader/entries/ directory containing bootspec entries\n")
+BAREBOX_CMD_HELP_SHORT("\n")
 BAREBOX_CMD_HELP_SHORT("Multiple bootsources may be given which are probed in order until\n")
 BAREBOX_CMD_HELP_SHORT("one succeeds.\n")
 BAREBOX_CMD_HELP_SHORT("\nOptions:\n")
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 10/11] blspec: Make error message more clear
  2013-11-04 14:04 bootspec work Sascha Hauer
                   ` (8 preceding siblings ...)
  2013-11-04 14:04 ` [PATCH 09/11] boot command: make more flexible Sascha Hauer
@ 2013-11-04 14:04 ` Sascha Hauer
  2013-11-04 14:04 ` [PATCH 11/11] boot command: Add timeout support for menu Sascha Hauer
  10 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2013-11-04 14:04 UTC (permalink / raw)
  To: barebox

"Nothing found on" is a bit unspecific. Make clear that no
bootspec entry is found.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/blspec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/blspec.c b/common/blspec.c
index cfefd26..ec45f0b 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -539,7 +539,7 @@ int blspec_boot_devicename(const char *devname, int verbose, int dryrun)
 
 	e = blspec_entry_default(blspec);
 	if (!e) {
-		printf("Nothing found on %s\n", devname);
+		printf("No bootspec entry found on %s\n", devname);
 		ret = -ENOENT;
 		goto out;
 	}
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 11/11] boot command: Add timeout support for menu
  2013-11-04 14:04 bootspec work Sascha Hauer
                   ` (9 preceding siblings ...)
  2013-11-04 14:04 ` [PATCH 10/11] blspec: Make error message more clear Sascha Hauer
@ 2013-11-04 14:04 ` Sascha Hauer
  10 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2013-11-04 14:04 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/boot.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/commands/boot.c b/commands/boot.c
index 1bec406..91766e0 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -21,6 +21,7 @@
 #include <blspec.h>
 #include <libgen.h>
 #include <malloc.h>
+#include <clock.h>
 #include <boot.h>
 #include <menu.h>
 #include <fs.h>
@@ -30,6 +31,7 @@
 
 static int verbose;
 static int dryrun;
+static int timeout;
 
 /*
  * Start a single boot script. 'path' is a full path to a boot script.
@@ -255,6 +257,9 @@ static void bootsources_menu(char *entries[], int num_entries)
 	back_entry->non_re_ent = 1;
 	menu_add_entry(blspec->menu, back_entry);
 
+	if (timeout >= 0)
+		blspec->menu->auto_select = timeout;
+
 	menu_show(blspec->menu);
 
 	free(back_entry);
@@ -332,8 +337,9 @@ static int do_boot(int argc, char *argv[])
 
 	verbose = 0;
 	dryrun = 0;
+	timeout = -1;
 
-	while ((opt = getopt(argc, argv, "vldm")) > 0) {
+	while ((opt = getopt(argc, argv, "vldmt:")) > 0) {
 		switch (opt) {
 		case 'v':
 			verbose++;
@@ -347,6 +353,9 @@ static int do_boot(int argc, char *argv[])
 		case 'm':
 			do_menu = 1;
 			break;
+		case 't':
+			timeout = simple_strtoul(optarg, NULL, 0);
+			break;
 		}
 	}
 
@@ -415,6 +424,7 @@ BAREBOX_CMD_HELP_OPT  ("-v","Increase verbosity\n")
 BAREBOX_CMD_HELP_OPT  ("-d","Dryrun. See what happens but do no actually boot\n")
 BAREBOX_CMD_HELP_OPT  ("-l","List available boot sources\n")
 BAREBOX_CMD_HELP_OPT  ("-m","Show a menu with boot options\n")
+BAREBOX_CMD_HELP_OPT  ("-t <timeout>","specify timeout for the menu\n")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(boot)
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 07/11] blspec: make cdev optional
  2013-11-04 14:04 ` [PATCH 07/11] blspec: make cdev optional Sascha Hauer
@ 2013-11-04 22:21   ` Alexander Aring
  2013-11-05  7:39     ` Sascha Hauer
  0 siblings, 1 reply; 15+ messages in thread
From: Alexander Aring @ 2013-11-04 22:21 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi Sascha,

On Mon, Nov 04, 2013 at 03:04:26PM +0100, Sascha Hauer wrote:
....
>  
> -		entry->me.display = asprintf("%-20s %-20s  %s", devname, hwdevname,
> +		entry->me.display = asprintf("%-20s %-20s  %s",
> +				devname ? devname : "",
> +				hwdevname ? hwdevname : "",
>  				blspec_entry_var_get(entry, "title"));
> +
>  		free(devname);
>  		free(hwdevname);
>  
> @@ -277,7 +281,7 @@ static int blspec_scan_cdev(struct blspec *blspec, struct cdev *cdev)
>  	if (IS_ERR(rootpath))
>  		return PTR_ERR(rootpath);
>  
> -	ret = blspec_scan_directory(blspec, rootpath, cdev);
> +	ret = blspec_scan_directory(blspec, rootpath);
>  
>  	return ret;
unnecessary assign of ret here, but it's not important...

- Alex

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 07/11] blspec: make cdev optional
  2013-11-04 22:21   ` Alexander Aring
@ 2013-11-05  7:39     ` Sascha Hauer
  2013-11-05  8:22       ` Alexander Aring
  0 siblings, 1 reply; 15+ messages in thread
From: Sascha Hauer @ 2013-11-05  7:39 UTC (permalink / raw)
  To: Alexander Aring; +Cc: barebox

On Mon, Nov 04, 2013 at 11:21:42PM +0100, Alexander Aring wrote:
> Hi Sascha,
> 
> On Mon, Nov 04, 2013 at 03:04:26PM +0100, Sascha Hauer wrote:
> ....
> >  
> > -		entry->me.display = asprintf("%-20s %-20s  %s", devname, hwdevname,
> > +		entry->me.display = asprintf("%-20s %-20s  %s",
> > +				devname ? devname : "",
> > +				hwdevname ? hwdevname : "",
> >  				blspec_entry_var_get(entry, "title"));
> > +
> >  		free(devname);
> >  		free(hwdevname);
> >  
> > @@ -277,7 +281,7 @@ static int blspec_scan_cdev(struct blspec *blspec, struct cdev *cdev)
> >  	if (IS_ERR(rootpath))
> >  		return PTR_ERR(rootpath);
> >  
> > -	ret = blspec_scan_directory(blspec, rootpath, cdev);
> > +	ret = blspec_scan_directory(blspec, rootpath);
> >  
> >  	return ret;
> unnecessary assign of ret here, but it's not important...

Changed anyway.

Thanks
 Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 07/11] blspec: make cdev optional
  2013-11-05  7:39     ` Sascha Hauer
@ 2013-11-05  8:22       ` Alexander Aring
  0 siblings, 0 replies; 15+ messages in thread
From: Alexander Aring @ 2013-11-05  8:22 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Tue, Nov 05, 2013 at 08:39:08AM +0100, Sascha Hauer wrote:
> On Mon, Nov 04, 2013 at 11:21:42PM +0100, Alexander Aring wrote:
> > Hi Sascha,
> > 
> > On Mon, Nov 04, 2013 at 03:04:26PM +0100, Sascha Hauer wrote:
> > ....
> > >  
> > > -		entry->me.display = asprintf("%-20s %-20s  %s", devname, hwdevname,
> > > +		entry->me.display = asprintf("%-20s %-20s  %s",
> > > +				devname ? devname : "",
> > > +				hwdevname ? hwdevname : "",
> > >  				blspec_entry_var_get(entry, "title"));
> > > +
> > >  		free(devname);
> > >  		free(hwdevname);
> > >  
> > > @@ -277,7 +281,7 @@ static int blspec_scan_cdev(struct blspec *blspec, struct cdev *cdev)
> > >  	if (IS_ERR(rootpath))
> > >  		return PTR_ERR(rootpath);
> > >  
> > > -	ret = blspec_scan_directory(blspec, rootpath, cdev);
> > > +	ret = blspec_scan_directory(blspec, rootpath);
> > >  
> > >  	return ret;
> > unnecessary assign of ret here, but it's not important...
> 
> Changed anyway.
> 
oh neat, Thanks.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-11-05  8:22 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-04 14:04 bootspec work Sascha Hauer
2013-11-04 14:04 ` [PATCH 01/11] kernel-install: Add missing error messages Sascha Hauer
2013-11-04 14:04 ` [PATCH 02/11] blspec: Push device_detect into blspec_scan_device Sascha Hauer
2013-11-04 14:04 ` [PATCH 03/11] blspec: rename _hwdevice functions to _devicename Sascha Hauer
2013-11-04 14:04 ` [PATCH 04/11] blspec: Allow to boot partitions Sascha Hauer
2013-11-04 14:04 ` [PATCH 05/11] blspec: Let scan functions return the number of entries found Sascha Hauer
2013-11-04 14:04 ` [PATCH 06/11] fs: Add function to get cdev by mountpath Sascha Hauer
2013-11-04 14:04 ` [PATCH 07/11] blspec: make cdev optional Sascha Hauer
2013-11-04 22:21   ` Alexander Aring
2013-11-05  7:39     ` Sascha Hauer
2013-11-05  8:22       ` Alexander Aring
2013-11-04 14:04 ` [PATCH 08/11] boot: Print boot entries in the order they are Sascha Hauer
2013-11-04 14:04 ` [PATCH 09/11] boot command: make more flexible Sascha Hauer
2013-11-04 14:04 ` [PATCH 10/11] blspec: Make error message more clear Sascha Hauer
2013-11-04 14:04 ` [PATCH 11/11] boot command: Add timeout support for menu Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox