fastboot: Introduce connect / disconnect for network-connected devices
Use introduced FileLock and network-connected devices storage entities
to introduce fastboot connect / disconnect commands
Test: everything works like discussed here go/fastboot-connect-disconnect on windows/linux
Bug: 267507450
Bug: 267506875
Change-Id: I2d6495ad567a3ddadd471a89b82d78c8c36a3d52
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
diff --git a/fastboot/filesystem.cpp b/fastboot/filesystem.cpp
index a58ba00..94fde8e 100644
--- a/fastboot/filesystem.cpp
+++ b/fastboot/filesystem.cpp
@@ -38,15 +38,15 @@
#ifdef _WIN32
HANDLE handle = reinterpret_cast<HANDLE>(_get_osfhandle(fd));
OVERLAPPED overlapped = {};
- const BOOL locked = LockFileEx(handle, LOCKFILE_EXCLUSIVE_LOCK, 0,
- MAXDWORD, MAXDWORD, &overlapped);
+ const BOOL locked =
+ LockFileEx(handle, LOCKFILE_EXCLUSIVE_LOCK, 0, MAXDWORD, MAXDWORD, &overlapped);
return locked ? 0 : -1;
#else
return flock(fd, LOCK_EX);
#endif
}
-}
+} // namespace
// inspired by adb implementation:
// cs.android.com/android/platform/superproject/+/master:packages/modules/adb/adb_utils.cpp;l=275
@@ -90,9 +90,9 @@
bool EnsureDirectoryExists(const std::string& directory_path) {
const int result =
#ifdef _WIN32
- _mkdir(directory_path.c_str());
+ _mkdir(directory_path.c_str());
#else
- mkdir(directory_path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+ mkdir(directory_path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
#endif
return result == 0 || errno == EEXIST;