[PATCH v4 1/3] env: add register_persistent_environment
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Tue Feb 19 06:58:43 EST 2013
On 10:17 Tue 19 Feb , Eric Bénard wrote:
> - heavily copied from register_persistant_environment which was
> Signed-off-by: Juergen Beisert <jbe at pengutronix.de>
>
> Signed-off-by: Eric Bénard <eric at eukrea.com>
> ---
> v4: rename function and move to envfs.h
> v3: also fix the typo in the printf
> v2: fix typo in persistent
> common/environment.c | 40 ++++++++++++++++++++++++++++++++++++++++
> include/envfs.h | 2 ++
> 2 files changed, 42 insertions(+)
>
> diff --git a/common/environment.c b/common/environment.c
> index e8d623f..78cd45c 100644
> --- a/common/environment.c
> +++ b/common/environment.c
> @@ -363,3 +363,43 @@ out:
> free(buf_free);
> return ret;
> }
> +
> +#ifdef __BAREBOX__
> +/**
> + * Try to register an environment storage on a device's partition
> + * @return 0 on success
> + *
> + * We rely on the existence of a usable storage device, already attached to
> + * our system, to get something like a persistent memory for our environment.
> + * We need to specify the partition number to use on this device.
> + * @param[in] devname Name of the device
> + * @param[in] partnr Partition number
> + * @return 0 on success, anything else in case of failure
> + */
> +
> +int envfs_register_partition(const char *devname, unsigned int partnr)
a part can be a number or a name
Best Regards,
J.
> +{
> + struct cdev *cdev;
> + char *partname;
> +
> + if (!devname)
> + return -EINVAL;
> +
> + cdev = cdev_by_name(devname);
> + if (cdev == NULL) {
> + pr_err("No %s present\n", devname);
> + return -ENODEV;
> + }
> + partname = asprintf("%s.%d", devname, partnr);
> + cdev = cdev_by_name(partname);
> + if (cdev == NULL) {
> + pr_err("No %s partition available\n", partname);
> + pr_info("Please create the partition %s to store the env\n", partname);
> + return -ENODEV;
> + }
> +
> + return devfs_add_partition(partname, 0, cdev->size,
> + DEVFS_PARTITION_FIXED, "env0");
> +}
> +EXPORT_SYMBOL(envfs_register_partition);
> +#endif
> diff --git a/include/envfs.h b/include/envfs.h
> index 2db55ed..e9372b3 100644
> --- a/include/envfs.h
> +++ b/include/envfs.h
> @@ -96,4 +96,6 @@ int envfs_save(char *filename, char *dirname);
> /* defaults to /dev/env0 */
> extern char *default_environment_path;
>
> +int envfs_register_partition(const char *devname, unsigned int partnr);
> +
> #endif /* _ENVFS_H */
> --
> 1.7.11.7
>
>
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
More information about the barebox
mailing list