aboutsummaryrefslogtreecommitdiff
path: root/libbb/copy_file.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'busybox' into mergeRon Yorston2021-06-281-0/+2
|\
| * cp: implement -nDenys Vlasenko2021-06-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta .rodata 103681 103722 +41 packed_usage 33698 33717 +19 copy_file 1678 1696 +18 cp_main 500 492 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 78/-8) Total: 70 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2019-08-161-1/+1
|\|
| * libbb: reduce the overhead of single parameter bb_error_msg() callsJames Byrne2019-07-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower overhead call to bb_perror_msg() when only a string was being printed with no parameters. This saves space for some CPU architectures because it avoids the overhead of a call to a variadic function. However there has never been a simple version of bb_error_msg(), and since 2007 many new calls to bb_perror_msg() have been added that only take a single parameter and so could have been using bb_simple_perror_message(). This changeset introduces 'simple' versions of bb_info_msg(), bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and bb_herror_msg_and_die(), and replaces all calls that only take a single parameter, or use something like ("%s", arg), with calls to the corresponding 'simple' version. Since it is likely that single parameter calls to the variadic functions may be accidentally reintroduced in the future a new debugging config option WARN_SIMPLE_MSG has been introduced. This uses some macro magic which will cause any such calls to generate a warning, but this is turned off by default to avoid use of the unpleasant macros in normal circumstances. This is a large changeset due to the number of calls that have been replaced. The only files that contain changes other than simple substitution of function calls are libbb.h, libbb/herror_msg.c, libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c, networking/udhcp/common.h and util-linux/mdev.c additonal macros have been added for logging so that single parameter and multiple parameter logging variants exist. The amount of space saved varies considerably by architecture, and was found to be as follows (for 'defconfig' using GCC 7.4): Arm: -92 bytes MIPS: -52 bytes PPC: -1836 bytes x86_64: -938 bytes Note that for the MIPS architecture only an exception had to be made disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h) because it made these files larger on MIPS. Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: fix POSIX build (again)Ron Yorston2019-03-121-1/+3
| | | | | | | | | | Some faulty logic with ENABLE_FEATURE_EXTRA_FILE_DATA broke the POSIX build.
* | win32: stat(2) succeeds if fetching extra metadata failsRon Yorston2019-02-191-2/+3
| | | | | | | | | | | | | | | | | | Some files can't be opened to fetch additional metadata. When that happens allow stat(2) to successfully return what data it has. In a few cases where the inode number is used to determine if files are identical ignore invalid inode numbers.
* | win32: make stat(2) fetch additional metadataRon Yorston2019-02-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modify the WIN32 implementation of stat(2) to fetch inode number, device id and number of hardlinks. This requires opening a handle to the target file so it will be slower. A number of features can be enabled or start to work: - tar can detect if an archive is being stored in itself; - find can support the -inum and -links options; - ls can display inode numbers; - diff can detect attempts to compare a file with itself; - du has better support for hardlinked files; - cp can detect attempts to copy a file over itself.
* | Merge branch 'busybox' into mergeRon Yorston2018-09-101-1/+2
|\|
| * libbb: fix use-after-free in copy_fileDenys Vlasenko2018-09-031-1/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox'Ron Yorston2018-07-251-0/+19
|\|
| * cp: optional --reflink supportDenys Vlasenko2018-07-131-0/+19
| | | | | | | | | | | | | | | | function old new delta cp_main 428 512 +84 copy_file 1676 1742 +66 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2018-04-091-1/+1
|\|
| * libbb: rename bb_ask -> bb_ask_noecho, bb_ask_confirmation -> ↵Denys Vlasenko2018-04-071-1/+1
| | | | | | | | | | | | bb_ask_y_confirmation Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2017-08-221-1/+4
|\|
| * libarchive: do not extract unsafe symlinks unless $EXTRACT_UNSAFE_SYMLINKS=1Denys Vlasenko2017-08-101-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta unsafe_symlink_target - 147 +147 unzip_main 2711 2732 +21 copy_file 1657 1678 +21 tar_main 999 971 -28 data_extract_all 1038 984 -54 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 2/2 up/down: 189/-82) Total: 107 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch busybox (up to "ash: comment out free(p) just before...")Ron Yorston2016-10-191-5/+11
|\|
| * cp: fix -i for POSIX mode. Closes 9106Denys Vlasenko2016-08-131-4/+9
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cp: make verbose cp show symlink copies tooDenys Vlasenko2016-07-141-1/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2016-07-071-0/+21
|\|
| * cp: add -u/--update and --remove-destinationDenys Vlasenko2016-05-271-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on the patch by wdlkmpx@gmail.com function old new delta copy_file 1546 1644 +98 add_partition 1270 1362 +92 ask_and_unlink 95 133 +38 do_iproute 132 157 +25 decode_one_format 710 715 +5 cp_main 369 374 +5 ubirename_main 198 202 +4 read_package_field 232 230 -2 bb_make_directory 421 412 -9 packed_usage 30505 30476 -29 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 7/3 up/down: 267/-40) Total: 227 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Don't store file details in inode hash tableRon Yorston2014-11-301-6/+0
| |
* | Merge branch 'busybox' into mergeRon Yorston2014-06-301-0/+4
|\|
| * Add conditional support for -v / --verboseDenys Vlasenko2014-05-191-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With FEATURE_VERBOSE off, practically no size change. With it on: function old new delta remove_file 493 556 +63 install_main 719 765 +46 bb_make_directory 383 419 +36 rmdir_main 162 191 +29 copy_file 1516 1544 +28 mv_main 502 525 +23 cmp_main 677 693 +16 bbconfig_config_bz2 5264 5279 +15 mkdir_main 158 168 +10 install_longopts 66 76 +10 rm_main 167 175 +8 nexpr 840 846 +6 scan_tree 275 280 +5 fsck_main 1807 1811 +4 ed_main 2541 2545 +4 expand_one_var 1574 1575 +1 swap_on_off_main 420 418 -2 parse_command 1443 1440 -3 redirect 1279 1274 -5 do_load 946 918 -28 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 16/4 up/down: 304/-38) Total: 266 bytes Based on the patch by Igor Živković. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Revise mingw_stat to minimise changes from upstream BusyBoxRon Yorston2014-01-071-3/+1
| |
* | Ensure mingw_stat is called when necessaryRon Yorston2012-11-291-1/+3
| | | | | | | | | | | | In some cases a funtion pointer to the stat function is used. The preprocessor can't replace these with the mingw_stat, so make alternative arrangements in those cases.
* | Update mingw.c from latest git/compatRon Yorston2012-03-301-5/+0
| |
* | Merge commit 'da4441c44f6efccb6f7b7588404d9c6bfb7b6af8' into mergeRon Yorston2012-03-221-4/+4
|\| | | | | | | | | | | | | Conflicts: libbb/vfork_daemon_rexec.c networking/wget.c procps/ps.c
| * libbb/copy_file.c: use smallints instead of signed charsDenys Vlasenko2011-01-281-4/+4
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | copy_file: kkip inode/device checkDaniel Klessing2011-11-211-0/+6
| | | | | | | | | | Inode/Device information is not present under mingw32. Don't rely on it in copy_file.c
* | Added missing stat() tweaks for mingw portZheng, Lei2011-11-201-0/+3
| |
* | Merge branch 'origin/master' (early part)Nguyễn Thái Ngọc Duy2010-09-141-1/+1
|\|
| * *: make GNU licensing statement forms more regularDenys Vlasenko2010-08-161-1/+1
| | | | | | | | | | | | | | This change retains "or later" state! No licensing _changes_ here, only form is adjusted (article, space between "GPL" and "v2" and so on). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: copy_file: always use lstat to avoid macro conflictNguyễn Thái Ngọc Duy2010-09-101-0/+5
|/ | | | | | stat() in win32 port is actual a macro, not a function. Doing it the way it is now won't work. stat/lstat is not different in Windows anyway.
* cosmetic fixesDenys Vlasenko2010-02-061-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* cp: fix -H handlingDenys Vlasenko2010-01-151-2/+2
| | | | | | | function old new delta copy_file 1495 1518 +23 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* fix improper utimes usageDenys Vlasenko2009-11-291-4/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* some non-gnu compilers can't have non-const struct initializersDenys Vlasenko2009-11-151-2/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* use utimes() rather than obsolescent utime()Bernhard Reutner-Fischer2009-11-151-5/+3
| | | | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* *: use "can't" instead of "cannot"Denys Vlasenko2009-11-131-20/+20
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* cp: make "non-POSIX" cp a bit more consistentDenys Vlasenko2009-07-051-34/+28
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* cp: by popular demand, make it POSIX compliant (but less safe)Denys Vlasenko2009-07-051-9/+9
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: introduce and use FAST_FUNC: regparm on i386, otherwise no-onDenis Vlasenko2008-06-271-1/+1
| | | | | | | text data bss dec hex filename 808035 611 6868 815514 c719a busybox_old 804472 611 6868 811951 c63af busybox_unstripped
* copy_file: handle "cp /dev/foo file" (almost) compatibly to coreutils.Denis Vlasenko2008-03-281-8/+29
| | | | | | (almost because we do not copy mode, which is probably wasn't intended). +61 bytes.
* cp: add ENABLE_FEATURE_VERBOSE_CP_MESSAGE. Closes bug 1470Denis Vlasenko2008-02-131-1/+11
|
* cp: make it a bit closer to POSIX, but still refuse to open andDenis Vlasenko2007-09-111-5/+7
| | | | | write to dest which is a symlink.
* cp: make "cp file /dev/node" special case; explained in commentsDenis Vlasenko2007-09-111-7/+15
| | | | | | | | | | | function old new delta copy_file 1487 1538 +51 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 51/0) Total: 51 bytes text data bss dec hex filename 772502 1051 10724 784277 bf795 busybox_old 772554 1051 10724 784329 bf7c9 busybox_unstripped
* cp: fix recursion check to not waste bytes remembering names of dirsDenis Vlasenko2007-08-271-6/+5
|
* cp: detect and prevent infinite recursionDenis Vlasenko2007-08-271-17/+35
|
* make copy_file() a bit easier to understand, and smallerDenis Vlasenko2007-08-251-67/+66
| | | | | | | | | | | function old new delta copy_file 1565 1447 -118 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-118) Total: -118 bytes text data bss dec hex filename 770938 1063 10788 782789 bf1c5 busybox_old 770814 1063 10788 782665 bf149 busybox_unstripped
* cp: make POSIX-me-harder mode complain with a bit less insane messageDenis Vlasenko2007-08-241-7/+8
|