diff options
Diffstat (limited to 'include/libbb.h')
-rw-r--r-- | include/libbb.h | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/include/libbb.h b/include/libbb.h index e80ed1e32..7a43967cb 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -469,23 +469,29 @@ enum { /* cp.c, mv.c, install.c depend on these values. CAREFUL when changing th | |||
469 | FILEUTILS_RECUR = 1 << 2, /* -R */ | 469 | FILEUTILS_RECUR = 1 << 2, /* -R */ |
470 | FILEUTILS_FORCE = 1 << 3, /* -f */ | 470 | FILEUTILS_FORCE = 1 << 3, /* -f */ |
471 | FILEUTILS_INTERACTIVE = 1 << 4, /* -i */ | 471 | FILEUTILS_INTERACTIVE = 1 << 4, /* -i */ |
472 | FILEUTILS_MAKE_HARDLINK = 1 << 5, /* -l */ | 472 | FILEUTILS_NO_OVERWRITE = 1 << 5, /* -n */ |
473 | FILEUTILS_MAKE_SOFTLINK = 1 << 6, /* -s */ | 473 | FILEUTILS_MAKE_HARDLINK = 1 << 6, /* -l */ |
474 | FILEUTILS_DEREF_SOFTLINK = 1 << 7, /* -L */ | 474 | FILEUTILS_MAKE_SOFTLINK = 1 << 7, /* -s */ |
475 | FILEUTILS_DEREFERENCE_L0 = 1 << 8, /* -H */ | 475 | FILEUTILS_DEREF_SOFTLINK = 1 << 8, /* -L */ |
476 | FILEUTILS_DEREFERENCE_L0 = 1 << 9, /* -H */ | ||
476 | /* -a = -pdR (mapped in cp.c) */ | 477 | /* -a = -pdR (mapped in cp.c) */ |
477 | /* -r = -dR (mapped in cp.c) */ | 478 | /* -r = -dR (mapped in cp.c) */ |
478 | /* -P = -d (mapped in cp.c) */ | 479 | /* -P = -d (mapped in cp.c) */ |
479 | FILEUTILS_VERBOSE = (1 << 12) * ENABLE_FEATURE_VERBOSE, /* -v */ | 480 | FILEUTILS_VERBOSE = (1 << 13) * ENABLE_FEATURE_VERBOSE, /* -v */ |
480 | FILEUTILS_UPDATE = 1 << 13, /* -u */ | 481 | FILEUTILS_UPDATE = 1 << 14, /* -u */ |
481 | FILEUTILS_NO_TARGET_DIR = 1 << 14, /* -T */ | 482 | FILEUTILS_NO_TARGET_DIR = 1 << 15, /* -T */ |
483 | FILEUTILS_TARGET_DIR = 1 << 16, /* -t DIR */ | ||
482 | #if ENABLE_SELINUX | 484 | #if ENABLE_SELINUX |
483 | FILEUTILS_PRESERVE_SECURITY_CONTEXT = 1 << 15, /* -c */ | 485 | FILEUTILS_PRESERVE_SECURITY_CONTEXT = 1 << 17, /* -c */ |
484 | #endif | 486 | #endif |
485 | FILEUTILS_RMDEST = 1 << (16 - !ENABLE_SELINUX), /* --remove-destination */ | 487 | #define FILEUTILS_CP_OPTSTR "pdRfinlsLHarPvuTt:" IF_SELINUX("c") |
486 | /* bit 17 skipped for "cp --parents" */ | 488 | /* How many bits in FILEUTILS_CP_OPTSTR? */ |
487 | FILEUTILS_REFLINK = 1 << (18 - !ENABLE_SELINUX), /* cp --reflink=auto */ | 489 | FILEUTILS_CP_OPTBITS = 18 - !ENABLE_SELINUX, |
488 | FILEUTILS_REFLINK_ALWAYS = 1 << (19 - !ENABLE_SELINUX), /* cp --reflink[=always] */ | 490 | |
491 | FILEUTILS_RMDEST = 1 << (19 - !ENABLE_SELINUX), /* cp --remove-destination */ | ||
492 | /* bit 18 skipped for "cp --parents" */ | ||
493 | FILEUTILS_REFLINK = 1 << (20 - !ENABLE_SELINUX), /* cp --reflink=auto */ | ||
494 | FILEUTILS_REFLINK_ALWAYS = 1 << (21 - !ENABLE_SELINUX), /* cp --reflink[=always] */ | ||
489 | /* | 495 | /* |
490 | * Hole. cp may have some bits set here, | 496 | * Hole. cp may have some bits set here, |
491 | * they should not affect remove_file()/copy_file() | 497 | * they should not affect remove_file()/copy_file() |
@@ -495,7 +501,7 @@ enum { /* cp.c, mv.c, install.c depend on these values. CAREFUL when changing th | |||
495 | #endif | 501 | #endif |
496 | FILEUTILS_IGNORE_CHMOD_ERR = 1 << 31, | 502 | FILEUTILS_IGNORE_CHMOD_ERR = 1 << 31, |
497 | }; | 503 | }; |
498 | #define FILEUTILS_CP_OPTSTR "pdRfilsLHarPvuT" IF_SELINUX("c") | 504 | |
499 | extern int remove_file(const char *path, int flags) FAST_FUNC; | 505 | extern int remove_file(const char *path, int flags) FAST_FUNC; |
500 | /* NB: without FILEUTILS_RECUR in flags, it will basically "cat" | 506 | /* NB: without FILEUTILS_RECUR in flags, it will basically "cat" |
501 | * the source, not copy (unless "source" is a directory). | 507 | * the source, not copy (unless "source" is a directory). |
@@ -525,6 +531,11 @@ int recursive_action(const char *fileName, unsigned flags, | |||
525 | void *userData | 531 | void *userData |
526 | ) FAST_FUNC; | 532 | ) FAST_FUNC; |
527 | 533 | ||
534 | /* Simpler version: call a function on each dirent in a directory */ | ||
535 | int iterate_on_dir(const char *dir_name, | ||
536 | int FAST_FUNC (*func)(const char *, struct dirent *, void *), | ||
537 | void *private) FAST_FUNC; | ||
538 | |||
528 | extern int device_open(const char *device, int mode) FAST_FUNC; | 539 | extern int device_open(const char *device, int mode) FAST_FUNC; |
529 | enum { GETPTY_BUFSIZE = 16 }; /* more than enough for "/dev/ttyXXX" */ | 540 | enum { GETPTY_BUFSIZE = 16 }; /* more than enough for "/dev/ttyXXX" */ |
530 | extern int xgetpty(char *line) FAST_FUNC; | 541 | extern int xgetpty(char *line) FAST_FUNC; |
@@ -1105,10 +1116,10 @@ char *smart_ulltoa5(unsigned long long ul, char buf[5], const char *scale) FAST_ | |||
1105 | /* If block_size == 0, display size without fractional part, | 1116 | /* If block_size == 0, display size without fractional part, |
1106 | * else display (size * block_size) with one decimal digit. | 1117 | * else display (size * block_size) with one decimal digit. |
1107 | * If display_unit == 0, show value no bigger than 1024 with suffix (K,M,G...), | 1118 | * If display_unit == 0, show value no bigger than 1024 with suffix (K,M,G...), |
1108 | * else divide by display_unit and do not use suffix. */ | 1119 | * else divide by display_unit and do not use suffix. |
1120 | * Returns "auto pointer" */ | ||
1109 | #define HUMAN_READABLE_MAX_WIDTH 7 /* "1024.0G" */ | 1121 | #define HUMAN_READABLE_MAX_WIDTH 7 /* "1024.0G" */ |
1110 | #define HUMAN_READABLE_MAX_WIDTH_STR "7" | 1122 | #define HUMAN_READABLE_MAX_WIDTH_STR "7" |
1111 | //TODO: provide pointer to buf (avoid statics)? | ||
1112 | const char *make_human_readable_str(unsigned long long size, | 1123 | const char *make_human_readable_str(unsigned long long size, |
1113 | unsigned long block_size, unsigned long display_unit) FAST_FUNC; | 1124 | unsigned long block_size, unsigned long display_unit) FAST_FUNC; |
1114 | /* Put a string of hex bytes ("1b2e66fe"...), return advanced pointer */ | 1125 | /* Put a string of hex bytes ("1b2e66fe"...), return advanced pointer */ |