adb: make sure that file mode macros match linux.
am: 05a3abfef3
Change-Id: I39a6938adc8b9b1da0185d36a1891f755bf2ca38
This commit is contained in:
commit
68fd28e334
3 changed files with 20 additions and 8 deletions
|
|
@ -43,6 +43,7 @@
|
||||||
#include "adb_utils.h"
|
#include "adb_utils.h"
|
||||||
#include "file_sync_service.h"
|
#include "file_sync_service.h"
|
||||||
#include "line_printer.h"
|
#include "line_printer.h"
|
||||||
|
#include "sysdeps/stat.h"
|
||||||
|
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
|
|
@ -64,15 +65,11 @@ static void ensure_trailing_separators(std::string& local_path, std::string& rem
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool should_pull_file(mode_t mode) {
|
static bool should_pull_file(mode_t mode) {
|
||||||
return mode & (S_IFREG | S_IFBLK | S_IFCHR);
|
return S_ISREG(mode) || S_ISBLK(mode) || S_ISCHR(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool should_push_file(mode_t mode) {
|
static bool should_push_file(mode_t mode) {
|
||||||
mode_t mask = S_IFREG;
|
return S_ISREG(mode) || S_ISLNK(mode);
|
||||||
#if !defined(_WIN32)
|
|
||||||
mask |= S_IFLNK;
|
|
||||||
#endif
|
|
||||||
return mode & mask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct copyinfo {
|
struct copyinfo {
|
||||||
|
|
|
||||||
|
|
@ -180,8 +180,6 @@ static __inline__ void close_on_exec(int fd)
|
||||||
/* nothing really */
|
/* nothing really */
|
||||||
}
|
}
|
||||||
|
|
||||||
#define S_ISLNK(m) 0 /* no symlinks on Win32 */
|
|
||||||
|
|
||||||
extern int adb_unlink(const char* path);
|
extern int adb_unlink(const char* path);
|
||||||
#undef unlink
|
#undef unlink
|
||||||
#define unlink ___xxx_unlink
|
#define unlink ___xxx_unlink
|
||||||
|
|
|
||||||
|
|
@ -43,4 +43,21 @@ struct adb_stat : public stat {};
|
||||||
// Windows doesn't have lstat.
|
// Windows doesn't have lstat.
|
||||||
#define lstat adb_stat
|
#define lstat adb_stat
|
||||||
|
|
||||||
|
// mingw doesn't define S_IFLNK or S_ISLNK.
|
||||||
|
#define S_IFLNK 0120000
|
||||||
|
#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
|
||||||
|
|
||||||
|
// mingw defines S_IFBLK to a different value from bionic.
|
||||||
|
#undef S_IFBLK
|
||||||
|
#define S_IFBLK 0060000
|
||||||
|
#undef S_ISBLK
|
||||||
|
#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Make sure that host file mode values match the ones on the device.
|
||||||
|
static_assert(S_IFMT == 00170000, "");
|
||||||
|
static_assert(S_IFLNK == 0120000, "");
|
||||||
|
static_assert(S_IFREG == 0100000, "");
|
||||||
|
static_assert(S_IFBLK == 0060000, "");
|
||||||
|
static_assert(S_IFDIR == 0040000, "");
|
||||||
|
static_assert(S_IFCHR == 0020000, "");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue