From patchwork Fri Nov 7 00:21:34 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 7633 X-Patchwork-Delegate: jk@ozlabs.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 384C3DE2D1 for ; Fri, 7 Nov 2008 11:23:15 +1100 (EST) X-Original-To: cbe-oss-dev@ozlabs.org Delivered-To: cbe-oss-dev@ozlabs.org Received: from SG2EHSOBE006.bigfish.com (outbound-sin.frontbridge.com [207.46.51.80]) by ozlabs.org (Postfix) with ESMTP id E7DA6DDFDB; Fri, 7 Nov 2008 11:22:27 +1100 (EST) Received: from mail117-sin-R.bigfish.com (10.3.40.3) by SG2EHSOBE006.bigfish.com (10.3.40.26) with Microsoft SMTP Server id 8.1.291.1; Fri, 7 Nov 2008 00:22:24 +0000 Received: from mail117-sin (localhost.localdomain [127.0.0.1]) by mail117-sin-R.bigfish.com (Postfix) with ESMTP id 880E612E0407; Fri, 7 Nov 2008 00:22:24 +0000 (UTC) X-BigFish: VPS7(zzzzzzz2fh6bh68o) X-Spam-TCS-SCL: 7:0 Received: by mail117-sin (MessageSwitch) id 122601733746321_7416; Fri, 7 Nov 2008 00:22:17 +0000 (UCT) Received: from mail8.fw-bc.sony.com (mail8.fw-bc.sony.com [160.33.98.75]) by mail117-sin.bigfish.com (Postfix) with ESMTP id 56B40DF8073; Fri, 7 Nov 2008 00:22:16 +0000 (UTC) Received: from mail3.sjc.in.sel.sony.com (mail3.sjc.in.sel.sony.com [43.134.1.211]) by mail8.fw-bc.sony.com (8.14.2/8.14.2) with ESMTP id mA70MEAo008028; Fri, 7 Nov 2008 00:22:14 GMT Received: from ussdixhub21.spe.sony.com (ussdixhub21.spe.sony.com [43.130.141.76]) by mail3.sjc.in.sel.sony.com (8.12.11/8.12.11) with ESMTP id mA70MEql000639; Fri, 7 Nov 2008 00:22:14 GMT Received: from USSDIXRG02.am.sony.com (43.130.140.32) by ussdixhub21.spe.sony.com (43.130.141.76) with Microsoft SMTP Server id 8.1.291.1; Thu, 6 Nov 2008 16:22:13 -0800 Received: from ussdixms03.am.sony.com ([43.130.140.23]) by USSDIXRG02.am.sony.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 6 Nov 2008 16:22:13 -0800 Received: from [192.168.1.10] ([43.135.148.226]) by ussdixms03.am.sony.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 6 Nov 2008 16:22:13 -0800 Message-ID: <49138A0E.4020700@am.sony.com> Date: Thu, 6 Nov 2008 16:21:34 -0800 From: Geoff Levand User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: jk@ozlabs.org References: <491385D1.2070704@am.sony.com> In-Reply-To: <491385D1.2070704@am.sony.com> X-Enigmail-Version: 0.95.7 X-OriginalArrivalTime: 07 Nov 2008 00:22:13.0343 (UTC) FILETIME=[E1AAFEF0:01C9406E] X-SEL-encryption-scan: scanned Cc: cbe-oss-dev@ozlabs.org Subject: [Cbe-oss-dev] [patch 9/9] petitboot: Merge shared headers into petitboot.h X-BeenThere: cbe-oss-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Discussion about Open Source Software for the Cell Broadband Engine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org From: Yuji Mano Merge the library shared headers into a single header petitboot.h. Also fixes these warnings: warning: redundant redeclaration of 'mountpoint_for_device' warning: redundant redeclaration of 'resolve_path' Signed-off-by: Yuji Mano Signed-off-by: Geoff Levand --- This change is a step to convert petitboot into a collection of applications linking to a core petitboot library. devices.c | 3 - lib/Makefile.am | 6 -- lib/kboot-parser.c | 2 lib/message.h | 30 ---------- lib/native-parser.c | 7 +- lib/parser.c | 3 - lib/parser.h | 46 --------------- lib/paths.c | 2 lib/paths.h | 53 ------------------ lib/petitboot-paths.h | 24 -------- lib/petitboot.h | 141 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/yaboot-parser.c | 9 +-- petitboot-gui.c | 2 petitboot-udev-helper.c | 4 - test/parser-test.c | 3 - 15 files changed, 156 insertions(+), 179 deletions(-) --- a/devices.c +++ b/devices.c @@ -9,9 +9,8 @@ #include #include +#include #include "petitboot-gui.h" -#include "petitboot-paths.h" -#include "message.h" #define PBOOT_DEFAULT_ICON "tux.png" --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -25,11 +25,7 @@ AM_CFLAGS = \ -Wredundant-decls \ -Winline -pkginclude_HEADERS = \ - message.h \ - parser.h \ - paths.h \ - petitboot-paths.h +include_HEADERS = petitboot.h petitboot_headers = \ params.h \ --- a/lib/kboot-parser.c +++ b/lib/kboot-parser.c @@ -10,7 +10,7 @@ #include #include -#include "parser.h" +#include "petitboot.h" #include "params.h" #define buf_size 1024 --- a/lib/message.h +++ /dev/null @@ -1,30 +0,0 @@ - -#ifndef _MESSAGE_H -#define _MESSAGE_H - -enum device_action { - DEV_ACTION_ADD_DEVICE = 0, - DEV_ACTION_ADD_OPTION = 1, - DEV_ACTION_REMOVE_DEVICE = 2, - DEV_ACTION_REMOVE_OPTION = 3 -}; - -struct device { - char *id; - char *name; - char *description; - char *icon_file; -}; - -struct boot_option { - char *id; - char *name; - char *description; - char *icon_file; - char *boot_image_file; - char *initrd_file; - char *boot_args; -}; - - -#endif /* _MESSAGE_H */ --- a/lib/native-parser.c +++ b/lib/native-parser.c @@ -1,12 +1,11 @@ -#include "parser.h" -#include "params.h" -#include "paths.h" - #include #include #include +#include "petitboot.h" +#include "params.h" + const char *conf_filename = "/boot/petitboot.conf"; static struct boot_option *cur_opt; --- a/lib/parser.c +++ b/lib/parser.c @@ -1,9 +1,8 @@ -#include #include #include -#include "parser.h" +#include "petitboot.h" extern struct parser native_parser; extern struct parser yaboot_parser; --- a/lib/parser.h +++ /dev/null @@ -1,46 +0,0 @@ - -#ifndef _PARSERS_H -#define _PARSERS_H - -#include -#include "message.h" - -struct parser { - char *name; - int priority; - int (*parse)(const char *device); - struct parser *next; -}; - -enum generic_icon_type { - ICON_TYPE_DISK, - ICON_TYPE_USB, - ICON_TYPE_OPTICAL, - ICON_TYPE_NETWORK, - ICON_TYPE_UNKNOWN -}; - -#define streq(a,b) (!strcasecmp((a),(b))) - -/* general functions provided by parsers.c */ -void iterate_parsers(const char *devpath, const char *mountpoint); - -void free_device(struct device *dev); -void free_boot_option(struct boot_option *opt); - -const char *generic_icon_file(enum generic_icon_type type); - -/* functions provided by udev-helper or the test wrapper */ -void pb_log(const char *fmt, ...); - -int mount_device(const char *dev_path); - -char *resolve_path(const char *path, const char *current_dev); -const char *mountpoint_for_device(const char *dev_path); - -enum generic_icon_type guess_device_type(void); - -int add_device(const struct device *dev); -int add_boot_option(const struct boot_option *opt); - -#endif /* _PARSERS_H */ --- a/lib/paths.c +++ b/lib/paths.c @@ -4,7 +4,7 @@ #include #include -#include "paths.h" +#include "petitboot.h" static char *mount_base; --- a/lib/paths.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef PATHS_H -#define PATHS_H - -/** - * Given a string (eg /dev/sda1, sda1 or UUID=B8E53381CA9EA0E3), parse the - * device path (eg /dev/sda1). Any device descriptions read from config files - * should be parsed into the path first. - * - * The cur_dev is provided for some remapping situations. If NULL is provided, - * no remapping will be done. - * - * Returns a newly-allocated string. - */ -char *parse_device_path(const char *dev_str, const char *current_device); - -/** - * Get the mountpoint for a device. - */ -const char *mountpoint_for_device(const char *dev); - -/** - * Resolve a path given in a config file, to a path in the local filesystem. - * Paths may be of the form: - * device:path (eg /dev/sda:/boot/vmlinux) - * - * or just a path: - * /boot/vmlinux - * - in this case, the current mountpoint is used. - * - * Returns a newly-allocated string containing a full path to the file in path - */ -char *resolve_path(const char *path, const char *current_device); - - -/** - * Set the base directory for newly-created mountpoints - */ -void set_mount_base(const char *path); - -/** - * Utility function for joining two paths. Adds a / between a and b if - * required. - * - * Returns a newly-allocated string. - */ -char *join_paths(const char *a, const char *b); - -/** - * encode a disk label (or uuid) for use in a symlink. - */ -char *encode_label(const char *label); - -#endif /* PATHS_H */ --- a/lib/petitboot-paths.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _PATHS_H -#define _PATHS_H - -#ifndef PREFIX -#define PREFIX "/usr" -#endif - -#ifndef PKG_SHARE_DIR -#define PKG_SHARE_DIR PREFIX "/share/petitboot" -#endif - -#ifndef TMP_DIR -#define TMP_DIR "/var/tmp/mnt/" -#endif - -#define PBOOT_DEVICE_SOCKET "/var/tmp/petitboot-dev" -#define MOUNT_BIN "/bin/mount" -#define UMOUNT_BIN "/bin/umount" -#define BOOT_GAMEOS_BIN "/usr/bin/ps3-boot-game-os" - -/* at present, all default artwork strings are const. */ -#define artwork_pathname(s) (PKG_SHARE_DIR "/artwork/" s) - -#endif /* _PATHS_H */ --- /dev/null +++ b/lib/petitboot.h @@ -0,0 +1,141 @@ + +#ifndef _PETITBOOT_LIB_H +#define _PETITBOOT_LIB_H + +/* default system paths */ + +#ifndef PREFIX +#define PREFIX "/usr" +#endif + +#ifndef PKG_SHARE_DIR +#define PKG_SHARE_DIR PREFIX "/share/petitboot" +#endif + +#ifndef TMP_DIR +#define TMP_DIR "/var/tmp/mnt/" +#endif + +#define PBOOT_DEVICE_SOCKET "/var/tmp/petitboot-dev" +#define MOUNT_BIN "/bin/mount" +#define UMOUNT_BIN "/bin/umount" +#define BOOT_GAMEOS_BIN "/usr/bin/ps3-boot-game-os" + +/* at present, all default artwork strings are const. */ +#define artwork_pathname(s) (PKG_SHARE_DIR "/artwork/" s) + +/* message interface */ + +enum device_action { + DEV_ACTION_ADD_DEVICE = 0, + DEV_ACTION_ADD_OPTION = 1, + DEV_ACTION_REMOVE_DEVICE = 2, + DEV_ACTION_REMOVE_OPTION = 3 +}; + +struct device { + char *id; + char *name; + char *description; + char *icon_file; +}; + +struct boot_option { + char *id; + char *name; + char *description; + char *icon_file; + char *boot_image_file; + char *initrd_file; + char *boot_args; +}; + +/* parser interface */ + +struct parser { + char *name; + int priority; + int (*parse)(const char *device); + struct parser *next; +}; + +enum generic_icon_type { + ICON_TYPE_DISK, + ICON_TYPE_USB, + ICON_TYPE_OPTICAL, + ICON_TYPE_NETWORK, + ICON_TYPE_UNKNOWN +}; + +#define streq(a,b) (!strcasecmp((a),(b))) + +/* general functions provided by parsers.c */ +void iterate_parsers(const char *devpath, const char *mountpoint); + +void free_device(struct device *dev); +void free_boot_option(struct boot_option *opt); + +const char *generic_icon_file(enum generic_icon_type type); + +/* functions provided by udev-helper or the test wrapper */ +void pb_log(const char *fmt, ...); + +int mount_device(const char *dev_path); + +enum generic_icon_type guess_device_type(void); + +int add_device(const struct device *dev); +int add_boot_option(const struct boot_option *opt); + +/* path routines */ + +/** + * Given a string (eg /dev/sda1, sda1 or UUID=B8E53381CA9EA0E3), parse the + * device path (eg /dev/sda1). Any device descriptions read from config files + * should be parsed into the path first. + * + * The cur_dev is provided for some remapping situations. If NULL is provided, + * no remapping will be done. + * + * Returns a newly-allocated string. + */ +char *parse_device_path(const char *dev_str, const char *current_device); + +/** + * Get the mountpoint for a device. + */ +const char *mountpoint_for_device(const char *dev); + +/** + * Resolve a path given in a config file, to a path in the local filesystem. + * Paths may be of the form: + * device:path (eg /dev/sda:/boot/vmlinux) + * + * or just a path: + * /boot/vmlinux + * - in this case, the current mountpoint is used. + * + * Returns a newly-allocated string containing a full path to the file in path + */ +char *resolve_path(const char *path, const char *current_device); + + +/** + * Set the base directory for newly-created mountpoints + */ +void set_mount_base(const char *path); + +/** + * Utility function for joining two paths. Adds a / between a and b if + * required. + * + * Returns a newly-allocated string. + */ +char *join_paths(const char *a, const char *b); + +/** + * encode a disk label (or uuid) for use in a symlink. + */ +char *encode_label(const char *label); + +#endif /* _PETITBOOT_LIB_H */ --- a/lib/yaboot-parser.c +++ b/lib/yaboot-parser.c @@ -1,9 +1,4 @@ -#include "parser.h" -#include "params.h" -#include "paths.h" -#include "yaboot-cfg.h" - #include #include #include @@ -14,6 +9,10 @@ #include #include +#include "petitboot.h" +#include "params.h" +#include "yaboot-cfg.h" + static struct device *dev; static char *devpath; static char *defimage; --- a/petitboot-gui.c +++ b/petitboot-gui.c @@ -21,8 +21,8 @@ #include #include +#include #include "petitboot-gui.h" -#include "petitboot-paths.h" #ifdef _USE_X11 #include --- a/petitboot-udev-helper.c +++ b/petitboot-udev-helper.c @@ -19,9 +19,7 @@ #include #include -#include "parser.h" -#include "paths.h" -#include "petitboot-paths.h" +#include /* Define below to operate without the frontend */ #undef USE_FAKE_SOCKET --- a/test/parser-test.c +++ b/test/parser-test.c @@ -6,8 +6,7 @@ #include #include -#include "parser.h" -#include "paths.h" +#include void pb_log(const char *fmt, ...) {