From b9ad75fa602dd72b042b2ea08ce86da50746ab30 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Fri, 28 Mar 2008 17:49:31 +0000 Subject: copy_file: handle "cp /dev/foo file" (almost) compatibly to coreutils. (almost because we do not copy mode, which is probably wasn't intended). +61 bytes. --- include/libbb.h | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'include/libbb.h') diff --git a/include/libbb.h b/include/libbb.h index 3638b7e15..afc053efb 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -223,8 +223,27 @@ extern char *skip_non_whitespace(const char *); //TODO: supply a pointer to char[11] buffer (avoid statics)? extern const char *bb_mode_string(mode_t mode); extern int is_directory(const char *name, int followLinks, struct stat *statBuf); +enum { /* DO NOT CHANGE THESE VALUES! cp.c, mv.c, install.c depend on them. */ + FILEUTILS_PRESERVE_STATUS = 1, + FILEUTILS_DEREFERENCE = 2, + FILEUTILS_RECUR = 4, + FILEUTILS_FORCE = 8, + FILEUTILS_INTERACTIVE = 0x10, + FILEUTILS_MAKE_HARDLINK = 0x20, + FILEUTILS_MAKE_SOFTLINK = 0x40, +#if ENABLE_SELINUX + FILEUTILS_PRESERVE_SECURITY_CONTEXT = 0x80, + FILEUTILS_SET_SECURITY_CONTEXT = 0x100 +#endif +}; +#define FILEUTILS_CP_OPTSTR "pdRfils" USE_SELINUX("c") extern int remove_file(const char *path, int flags); +/* NB: without FILEUTILS_RECUR in flags, it will basically "cat" + * the source, not copy (unless "source" is a directory). + * This makes "cp /dev/null file" and "install /dev/null file" (!!!) + * work coreutils-compatibly. */ extern int copy_file(const char *source, const char *dest, int flags); + enum { ACTION_RECURSE = (1 << 0), ACTION_FOLLOWLINKS = (1 << 1), @@ -1170,21 +1189,6 @@ void *md5_end(void *resbuf, md5_ctx_t *ctx); uint32_t *crc32_filltable(uint32_t *tbl256, int endian); -enum { /* DO NOT CHANGE THESE VALUES! cp.c, mv.c, install.c depend on them. */ - FILEUTILS_PRESERVE_STATUS = 1, - FILEUTILS_DEREFERENCE = 2, - FILEUTILS_RECUR = 4, - FILEUTILS_FORCE = 8, - FILEUTILS_INTERACTIVE = 0x10, - FILEUTILS_MAKE_HARDLINK = 0x20, - FILEUTILS_MAKE_SOFTLINK = 0x40, -#if ENABLE_SELINUX - FILEUTILS_PRESERVE_SECURITY_CONTEXT = 0x80, - FILEUTILS_SET_SECURITY_CONTEXT = 0x100 -#endif -}; - -#define FILEUTILS_CP_OPTSTR "pdRfils" USE_SELINUX("c") extern const char *applet_name; /* "BusyBox vN.N.N (timestamp or extra_version)" */ extern const char bb_banner[]; -- cgit v1.2.3