diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2016-05-09 08:49:42 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-05-09 08:49:42 +0200 |
commit | 55aca0a48c5cb68eeddf723a5bc69fc052071e61 (patch) | |
tree | 00961bee994725f5d3ee678c5630b53ecc5a02fe /include | |
parent | 216f412ede9cb78ccdfd00df89246ab1ffc9e300 (diff) | |
parent | 18f0d2221a4c781dad2a224f8ac17e7c95fd1d9c (diff) | |
download | barebox-55aca0a48c5cb68eeddf723a5bc69fc052071e61.tar.gz barebox-55aca0a48c5cb68eeddf723a5bc69fc052071e61.tar.xz |
Merge branch 'for-next/include-cleanup'
Diffstat (limited to 'include')
-rw-r--r-- | include/command.h | 1 | ||||
-rw-r--r-- | include/common.h | 29 | ||||
-rw-r--r-- | include/crc.h | 102 | ||||
-rw-r--r-- | include/dirent.h | 20 | ||||
-rw-r--r-- | include/fcntl.h | 100 | ||||
-rw-r--r-- | include/fs.h | 56 | ||||
-rw-r--r-- | include/libfile.h | 7 | ||||
-rw-r--r-- | include/mtd/utils.h | 2 | ||||
-rw-r--r-- | include/shell.h | 11 | ||||
-rw-r--r-- | include/stdio.h | 57 | ||||
-rw-r--r-- | include/sys/ioctl.h | 6 | ||||
-rw-r--r-- | include/sys/mount.h | 8 | ||||
-rw-r--r-- | include/sys/stat.h | 9 | ||||
-rw-r--r-- | include/unistd.h | 24 | ||||
-rw-r--r-- | include/w1_mac_address.h | 2 |
15 files changed, 135 insertions, 299 deletions
diff --git a/include/command.h b/include/command.h index 3aca1a9f1b..4ed5e37395 100644 --- a/include/command.h +++ b/include/command.h @@ -71,6 +71,7 @@ extern struct command __barebox_cmd_end; struct command *find_cmd(const char *cmd); int execute_command(int argc, char **argv); void barebox_cmd_usage(struct command *cmdtp); +int run_command(const char *cmd); #define COMMAND_SUCCESS 0 #define COMMAND_ERROR 1 diff --git a/include/common.h b/include/common.h index 38a6dbf933..680a0affb6 100644 --- a/include/common.h +++ b/include/common.h @@ -61,7 +61,6 @@ void __noreturn hang (void); char *size_human_readable(unsigned long long size); -int run_command(const char *cmd); int readline (const char *prompt, char *buf, int len); /* common/memsize.c */ @@ -70,12 +69,6 @@ long get_ram_size (volatile long *, long); /* $(CPU)/cpu.c */ void __noreturn poweroff(void); -/* lib_generic/crc32.c */ -uint32_t crc32(uint32_t, const void*, unsigned int); -uint32_t crc32_no_comp(uint32_t, const void*, unsigned int); -int file_crc(char *filename, ulong start, ulong size, ulong *crc, - ulong *total); - /* common/console.c */ int ctrlc (void); @@ -88,16 +81,6 @@ static inline void dump_stack(void) } #endif -#define MEMAREA_SIZE_SPECIFIED 1 - -struct memarea_info { - struct device_d *device; - unsigned long start; - unsigned long end; - unsigned long size; - unsigned long flags; -}; - int parse_area_spec(const char *str, loff_t *start, loff_t *size); /* Just like simple_strtoul(), but this one honors a K/M/G suffix */ @@ -113,17 +96,6 @@ extern int (*barebox_main)(void); void __noreturn start_barebox(void); void shutdown_barebox(void); -int run_shell(void); - -#ifdef CONFIG_SHELL_HUSH -char *shell_expand(char *str); -#else -static inline char *shell_expand(char *str) -{ - return strdup(str); -} -#endif - #define ALIGN_DOWN(x, a) ((x) & ~((typeof(x))(a) - 1)) #define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x) @@ -156,7 +128,6 @@ static inline void print_hex_dump(const char *level, const char *prefix_str, int mem_parse_options(int argc, char *argv[], char *optstr, int *mode, char **sourcefile, char **destfile, int *swab); -int open_and_lseek(const char *filename, int mode, loff_t pos); #define RW_BUF_SIZE (unsigned)4096 extern const char version_string[]; diff --git a/include/crc.h b/include/crc.h index 4290f41c57..847a0a4b64 100644 --- a/include/crc.h +++ b/include/crc.h @@ -1,100 +1,14 @@ -/* - *========================================================================== - * - * crc.h - * - * Interface for the CRC algorithms. - * - *========================================================================== - *####ECOSGPLCOPYRIGHTBEGIN#### - * ------------------------------------------- - * This file is part of eCos, the Embedded Configurable Operating System. - * Copyright (C) 2002 Andrew Lunn - * - * eCos is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 or (at your option) any later version. - * - * eCos is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with eCos; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * As a special exception, if other files instantiate templates or use macros - * or inline functions from this file, or you compile this file and link it - * with other works to produce a work based on this file, this file does not - * by itself cause the resulting work to be covered by the GNU General Public - * License. However the source code for this file must still be made available - * in accordance with section (3) of the GNU General Public License. - * - * This exception does not invalidate any other reasons why a work based on - * this file might be covered by the GNU General Public License. - * - * Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. - * at http: *sources.redhat.com/ecos/ecos-license/ - * ------------------------------------------- - *####ECOSGPLCOPYRIGHTEND#### - *========================================================================== - *#####DESCRIPTIONBEGIN#### - * - * Author(s): Andrew Lunn - * Contributors: Andrew Lunn - * Date: 2002-08-06 - * Purpose: - * Description: - * - * This code is part of eCos (tm). - * - *####DESCRIPTIONEND#### - * - *========================================================================== - */ - -#ifndef _SERVICES_CRC_CRC_H_ -#define _SERVICES_CRC_CRC_H_ +#ifndef __INCLUDE_CRC_H +#define __INCLUDE_CRC_H #include <linux/types.h> -#ifndef __externC -# ifdef __cplusplus -# define __externC extern "C" -# else -# define __externC extern -# endif -#endif - -/* Compute a CRC, using the POSIX 1003 definition */ -extern uint32_t -cyg_posix_crc32(unsigned char *s, int len); - -/* Gary S. Brown's 32 bit CRC */ - -extern uint32_t -cyg_crc32(unsigned char *s, int len); - -/* Gary S. Brown's 32 bit CRC, but accumulate the result from a */ -/* previous CRC calculation */ - -extern uint32_t -cyg_crc32_accumulate(uint32_t crc, unsigned char *s, int len); - -/* Ethernet FCS Algorithm */ - -extern uint32_t -cyg_ether_crc32(unsigned char *s, int len); - -/* Ethernet FCS algorithm, but accumulate the result from a previous */ -/* CRC calculation. */ - -extern uint32_t -cyg_ether_crc32_accumulate(uint32_t crc, unsigned char *s, int len); - /* 16 bit CRC with polynomial x^16+x^12+x^5+1 */ - extern uint16_t cyg_crc16(const unsigned char *s, int len); -#endif /* _SERVICES_CRC_CRC_H_ */ +uint32_t crc32(uint32_t, const void *, unsigned int); +uint32_t crc32_no_comp(uint32_t, const void *, unsigned int); +int file_crc(char *filename, unsigned long start, unsigned long size, + unsigned long *crc, unsigned long *total); + +#endif /* __INCLUDE_CRC_H */ diff --git a/include/dirent.h b/include/dirent.h new file mode 100644 index 0000000000..5ee4c2063e --- /dev/null +++ b/include/dirent.h @@ -0,0 +1,20 @@ +#ifndef __DIRENT_H +#define __DIRENT_H + +struct dirent { + char d_name[256]; +}; + +typedef struct dir { + struct device_d *dev; + struct fs_driver_d *fsdrv; + struct node_d *node; + struct dirent d; + void *priv; /* private data for the fs driver */ +} DIR; + +DIR *opendir(const char *pathname); +struct dirent *readdir(DIR *dir); +int closedir(DIR *dir); + +#endif /* __DIRENT_H */ diff --git a/include/fcntl.h b/include/fcntl.h index 12f370a418..98020bdfb1 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -1,5 +1,5 @@ -#ifndef _ASM_GENERIC_FCNTL_H -#define _ASM_GENERIC_FCNTL_H +#ifndef __FCNTL_H +#define __FCNTL_H #include <linux/types.h> @@ -24,97 +24,7 @@ #define O_RWSIZE_4 004000000 #define O_RWSIZE_8 010000000 -#define F_DUPFD 0 /* dup */ -#define F_GETFD 1 /* get close_on_exec */ -#define F_SETFD 2 /* set/clear close_on_exec */ -#define F_GETFL 3 /* get file->f_flags */ -#define F_SETFL 4 /* set file->f_flags */ -#ifndef F_GETLK -#define F_GETLK 5 -#define F_SETLK 6 -#define F_SETLKW 7 -#endif -#ifndef F_SETOWN -#define F_SETOWN 8 /* for sockets. */ -#define F_GETOWN 9 /* for sockets. */ -#endif -#ifndef F_SETSIG -#define F_SETSIG 10 /* for sockets. */ -#define F_GETSIG 11 /* for sockets. */ -#endif +int open(const char *pathname, int flags, ...); +int creat(const char *pathname, mode_t mode); -/* for F_[GET|SET]FL */ -#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ - -/* for posix fcntl() and lockf() */ -#ifndef F_RDLCK -#define F_RDLCK 0 -#define F_WRLCK 1 -#define F_UNLCK 2 -#endif - -/* for old implementation of bsd flock () */ -#ifndef F_EXLCK -#define F_EXLCK 4 /* or 3 */ -#define F_SHLCK 8 /* or 4 */ -#endif - -/* for leases */ -#ifndef F_INPROGRESS -#define F_INPROGRESS 16 -#endif - -/* operations for bsd flock(), also used by the kernel implementation */ -#define LOCK_SH 1 /* shared lock */ -#define LOCK_EX 2 /* exclusive lock */ -#define LOCK_NB 4 /* or'd with one of the above to prevent - blocking */ -#define LOCK_UN 8 /* remove lock */ - -#define LOCK_MAND 32 /* This is a mandatory flock ... */ -#define LOCK_READ 64 /* which allows concurrent read operations */ -#define LOCK_WRITE 128 /* which allows concurrent write operations */ -#define LOCK_RW 192 /* which allows concurrent read & write ops */ - -#define F_LINUX_SPECIFIC_BASE 1024 - -#ifndef HAVE_ARCH_STRUCT_FLOCK -#ifndef __ARCH_FLOCK_PAD -#define __ARCH_FLOCK_PAD -#endif - -struct flock { - short l_type; - short l_whence; - off_t l_start; - off_t l_len; - pid_t l_pid; - __ARCH_FLOCK_PAD -}; -#endif - -#ifndef CONFIG_64BIT - -#ifndef F_GETLK64 -#define F_GETLK64 12 /* using 'struct flock64' */ -#define F_SETLK64 13 -#define F_SETLKW64 14 -#endif - -#ifndef HAVE_ARCH_STRUCT_FLOCK64 -#ifndef __ARCH_FLOCK64_PAD -#define __ARCH_FLOCK64_PAD -#endif - -struct flock64 { - short l_type; - short l_whence; - loff_t l_start; - loff_t l_len; - pid_t l_pid; - __ARCH_FLOCK64_PAD -}; -#endif -#endif /* !CONFIG_64BIT */ - -#endif /* _ASM_GENERIC_FCNTL_H */ +#endif /* __FCNTL_H */ diff --git a/include/fs.h b/include/fs.h index 943ba55439..6a592893a9 100644 --- a/include/fs.h +++ b/include/fs.h @@ -1,6 +1,12 @@ #ifndef __FS_H #define __FS_H +#include <unistd.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <dirent.h> +#include <sys/mount.h> +#include <sys/stat.h> #include <driver.h> #include <filetype.h> #include <linux/fs.h> @@ -11,18 +17,6 @@ struct partition; struct node_d; struct stat; -struct dirent { - char d_name[256]; -}; - -typedef struct dir { - struct device_d *dev; - struct fs_driver_d *fsdrv; - struct node_d *node; - struct dirent d; - void *priv; /* private data for the fs driver */ -} DIR; - typedef struct filep { struct fs_device_d *fsdev; /* The device this FILE belongs to */ char *path; @@ -107,43 +101,7 @@ struct fs_device_d { #define drv_to_fs_driver(d) container_of(d, struct fs_driver_d, drv) -/* - * standard posix file functions - */ -int open(const char *pathname, int flags, ...); -int creat(const char *pathname, mode_t mode); -int unlink(const char *pathname); -int close(int fd); int flush(int fd); -int lstat(const char *filename, struct stat *s); -int stat(const char *filename, struct stat *s); -int fstat(int fd, struct stat *s); -ssize_t read(int fd, void *buf, size_t count); -ssize_t pread(int fd, void *buf, size_t count, loff_t offset); -int ioctl(int fd, int request, void *buf); -ssize_t write(int fd, const void *buf, size_t count); -ssize_t pwrite(int fd, const void *buf, size_t count, loff_t offset); - -loff_t lseek(int fildes, loff_t offset, int whence); -int mkdir (const char *pathname, mode_t mode); - -/* Create a directory and its parents */ -int make_directory(const char *pathname); -int rmdir (const char *pathname); - -const char *getcwd(void); -int chdir(const char *pathname); - -DIR *opendir(const char *pathname); -struct dirent *readdir(DIR *dir); -int closedir(DIR *dir); - -int symlink(const char *pathname, const char *newpath); -int readlink(const char *path, char *buf, size_t bufsiz); - -int mount (const char *device, const char *fsname, const char *path, - const char *fsoptions); -int umount(const char *pathname); int umount_by_cdev(struct cdev *cdev); /* not-so-standard functions */ @@ -183,8 +141,6 @@ void automount_remove(const char *_path); int automount_add(const char *path, const char *cmd); void automount_print(void); -int unlink_recursive(const char *path, char **failedpath); - int fsdev_open_cdev(struct fs_device_d *fsdev); const char *cdev_get_mount_path(struct cdev *cdev); const char *cdev_mount_default(struct cdev *cdev, const char *fsoptions); diff --git a/include/libfile.h b/include/libfile.h index d5b914a47a..de4f42dbd1 100644 --- a/include/libfile.h +++ b/include/libfile.h @@ -19,4 +19,11 @@ int copy_recursive(const char *src, const char *dst); int compare_file(const char *f1, const char *f2); +int open_and_lseek(const char *filename, int mode, loff_t pos); + +/* Create a directory and its parents */ +int make_directory(const char *pathname); + +int unlink_recursive(const char *path, char **failedpath); + #endif /* __LIBFILE_H */ diff --git a/include/mtd/utils.h b/include/mtd/utils.h index fca64abd9d..58f89df90c 100644 --- a/include/mtd/utils.h +++ b/include/mtd/utils.h @@ -41,7 +41,7 @@ #define sys_errmsg errmsg #define warnmsg(fmt, ...) do { \ - fprintf(stderr, "%s: warning!: " fmt "\n", PROGRAM_NAME, ##__VA_ARGS__); \ + eprintf("%s: warning!: " fmt "\n", PROGRAM_NAME, ##__VA_ARGS__); \ } while(0) #endif /* INCLUDE_MTD_UTILS_H */ diff --git a/include/shell.h b/include/shell.h index b98cac3dc5..65dad0e1d1 100644 --- a/include/shell.h +++ b/include/shell.h @@ -9,4 +9,15 @@ int shell_get_last_return_code(void); +int run_shell(void); + +#ifdef CONFIG_SHELL_HUSH +char *shell_expand(char *str); +#else +static inline char *shell_expand(char *str) +{ + return strdup(str); +} +#endif + #endif /* __SHELL_H__ */ diff --git a/include/stdio.h b/include/stdio.h index d0817bd071..7b2a42b817 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -9,28 +9,30 @@ */ /* serial stuff */ -void serial_printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2))); - -int sprintf(char *buf, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3))); -int snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4))); -int scnprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4))); -int vsprintf(char *buf, const char *fmt, va_list args); -char *asprintf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2))); -char *vasprintf(const char *fmt, va_list ap); -int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); -int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); +void serial_printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2))); + +int sprintf(char *buf, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3))); +int snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4))); +int scnprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4))); +int vsprintf(char *buf, const char *fmt, va_list args); +char *basprintf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2))); +int asprintf(char **strp, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3))); +char *bvasprintf(const char *fmt, va_list ap); +int vasprintf(char **strp, const char *fmt, va_list ap); +int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); +int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); #ifndef CONFIG_CONSOLE_NONE /* stdin */ -int tstc(void); +int tstc(void); /* stdout */ -void console_putc(unsigned int ch, const char c); -int getc(void); -int console_puts(unsigned int ch, const char *s); -void console_flush(void); +void console_putc(unsigned int ch, const char c); +int getchar(void); +int console_puts(unsigned int ch, const char *s); +void console_flush(void); -int vprintf(const char *fmt, va_list args); +int vprintf(const char *fmt, va_list args); #else static inline int tstc(void) { @@ -42,7 +44,7 @@ static inline int console_puts(unsigned int ch, const char *str) return 0; } -static inline int getc(void) +static inline int getchar(void) { return -EINVAL; } @@ -87,23 +89,20 @@ static inline void putchar(char c) console_putc(CONSOLE_STDOUT, c); } -/* stderr */ -#define eputc(c) console_putc(CONSOLE_STDERR, c) -#define eputs(s) console_puts(CONSOLE_STDERR, s) -#define eprintf(fmt,args...) fprintf(stderr,fmt ,##args) - /* * FILE based functions */ -#define stdin 0 -#define stdout 1 -#define stderr 2 +/* stderr */ +#define eprintf(fmt,args...) dprintf(STDERR_FILENO, fmt ,##args) + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 #define MAX_FILES 128 -int fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3))); -int fputs(int file, const char *s); -int fputc(int file, const char c); -int fgetc(int file); +int dprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3))); +int dputs(int file, const char *s); +int dputc(int file, const char c); #endif /* __STDIO_H */ diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h new file mode 100644 index 0000000000..6d6d3f5c00 --- /dev/null +++ b/include/sys/ioctl.h @@ -0,0 +1,6 @@ +#ifndef __SYS_IOCTL_H +#define __SYS_IOCTL_H + +int ioctl(int fd, int request, void *buf); + +#endif /* __SYS_IOCTL_H */ diff --git a/include/sys/mount.h b/include/sys/mount.h new file mode 100644 index 0000000000..978f3406e8 --- /dev/null +++ b/include/sys/mount.h @@ -0,0 +1,8 @@ +#ifndef __SYS_MOUNT_H +#define __SYS_MOUNT_H + +int mount(const char *device, const char *fsname, const char *path, + const char *fsoptions); +int umount(const char *pathname); + +#endif /* __SYS_MOUNT_H */ diff --git a/include/sys/stat.h b/include/sys/stat.h new file mode 100644 index 0000000000..037e5f136d --- /dev/null +++ b/include/sys/stat.h @@ -0,0 +1,9 @@ +#ifndef __STAT_H +#define __STAT_H + +#include <linux/types.h> +#include <linux/stat.h> + +int mkdir (const char *pathname, mode_t mode); + +#endif /* __STAT_H */ diff --git a/include/unistd.h b/include/unistd.h new file mode 100644 index 0000000000..31f430a5b6 --- /dev/null +++ b/include/unistd.h @@ -0,0 +1,24 @@ +#ifndef __UNISTD_H +#define __UNISTD_H + +#include <linux/types.h> + +struct stat; + +int unlink(const char *pathname); +int close(int fd); +int lstat(const char *filename, struct stat *s); +int stat(const char *filename, struct stat *s); +int fstat(int fd, struct stat *s); +ssize_t read(int fd, void *buf, size_t count); +ssize_t pread(int fd, void *buf, size_t count, loff_t offset); +ssize_t write(int fd, const void *buf, size_t count); +ssize_t pwrite(int fd, const void *buf, size_t count, loff_t offset); +loff_t lseek(int fildes, loff_t offset, int whence); +int rmdir (const char *pathname); +int symlink(const char *pathname, const char *newpath); +int readlink(const char *path, char *buf, size_t bufsiz); +int chdir(const char *pathname); +const char *getcwd(void); + +#endif /* __UNISTD_H */ diff --git a/include/w1_mac_address.h b/include/w1_mac_address.h index 89dd914095..cd4be765f7 100644 --- a/include/w1_mac_address.h +++ b/include/w1_mac_address.h @@ -33,7 +33,7 @@ static inline int w1_local_mac_address_register(int ethid, char * oui, char *w1_ addr[i] = oui[i]; } - tmp = asprintf("%s.id", w1_dev); + tmp = basprintf("%s.id", w1_dev); if (!tmp) return -ENOMEM; |