aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-02-19 10:59:45 +0000
committerRon Yorston <rmy@pobox.com>2019-02-19 10:59:45 +0000
commit8c47a98c9166ff23c3bcbb3e1ef8430b349cf71e (patch)
treeaebfe98490659a3882dc2d391a15ea2d95c7e8b4 /libbb
parent4d47580175918882dd827183569d6a50f460f00a (diff)
downloadbusybox-w32-8c47a98c9166ff23c3bcbb3e1ef8430b349cf71e.tar.gz
busybox-w32-8c47a98c9166ff23c3bcbb3e1ef8430b349cf71e.tar.bz2
busybox-w32-8c47a98c9166ff23c3bcbb3e1ef8430b349cf71e.zip
win32: stat(2) succeeds if fetching extra metadata fails
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.
Diffstat (limited to 'libbb')
-rw-r--r--libbb/copy_file.c5
-rw-r--r--libbb/inode_hash.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/libbb/copy_file.c b/libbb/copy_file.c
index db7a00060..abe034f50 100644
--- a/libbb/copy_file.c
+++ b/libbb/copy_file.c
@@ -105,10 +105,11 @@ int FAST_FUNC copy_file(const char *source, const char *dest, int flags)
105 return -1; 105 return -1;
106 } 106 }
107 } else { 107 } else {
108#if !ENABLE_PLATFORM_MINGW32 || ENABLE_FEATURE_EXTRA_FILE_DATA 108#if ENABLE_PLATFORM_POSIX || ENABLE_FEATURE_EXTRA_FILE_DATA
109 /* MinGW does not have inode, and does not use device */
110 if (source_stat.st_dev == dest_stat.st_dev 109 if (source_stat.st_dev == dest_stat.st_dev
111 && source_stat.st_ino == dest_stat.st_ino 110 && source_stat.st_ino == dest_stat.st_ino
111 /* ignore invalid inode numbers */
112 && (ENABLE_FEATURE_EXTRA_FILE_DATA && source_stat.st_ino != 0)
112 ) { 113 ) {
113 bb_error_msg("'%s' and '%s' are the same file", source, dest); 114 bb_error_msg("'%s' and '%s' are the same file", source, dest);
114 return -1; 115 return -1;
diff --git a/libbb/inode_hash.c b/libbb/inode_hash.c
index 4142813e3..37fed9c82 100644
--- a/libbb/inode_hash.c
+++ b/libbb/inode_hash.c
@@ -61,6 +61,11 @@ void FAST_FUNC add_to_ino_dev_hashtable(const struct stat *statbuf, const char *
61 int i; 61 int i;
62 ino_dev_hashtable_bucket_t *bucket; 62 ino_dev_hashtable_bucket_t *bucket;
63 63
64#if ENABLE_FEATURE_EXTRA_FILE_DATA
65 /* ignore invalid inode numbers */
66 if (statbuf->st_ino == 0)
67 return;
68#endif
64 if (!name) 69 if (!name)
65 name = ""; 70 name = "";
66 bucket = xmalloc(sizeof(ino_dev_hashtable_bucket_t) + strlen(name)); 71 bucket = xmalloc(sizeof(ino_dev_hashtable_bucket_t) + strlen(name));