Created
February 27, 2017 09:03
-
-
Save therealkenc/b82a5cc4720b559fd751296d60f799b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/.gitignore b/.gitignore | |
| index e1dd1a7..c806df6 100644 | |
| --- a/.gitignore | |
| +++ b/.gitignore | |
| @@ -51,6 +51,10 @@ tags | |
| Thumbs.db | |
| v8.log | |
| vs-chromium-project.txt | |
| +# WSL diff additions for git performance | |
| +/v8/ | |
| +/build/ | |
| +*.rej | |
| # Settings directories for eclipse | |
| /.externalToolBuilders/ | |
| /.settings/ | |
| diff --git a/base/debug/proc_maps_linux.cc b/base/debug/proc_maps_linux.cc | |
| index 0bb44b4..e776e22 100644 | |
| --- a/base/debug/proc_maps_linux.cc | |
| +++ b/base/debug/proc_maps_linux.cc | |
| @@ -151,11 +151,15 @@ bool ParseProcMaps(const std::string& input, | |
| else if (permissions[2] != '-') | |
| return false; | |
| +#if !defined(WSL_HACK) | |
| if (permissions[3] == 'p') | |
| region.permissions |= MappedMemoryRegion::PRIVATE; | |
| else if (permissions[3] != 's' && permissions[3] != 'S') // Shared memory. | |
| return false; | |
| - | |
| +#else | |
| + // WSL always sets character to '-'. Pretend it's 'p'. | |
| + region.permissions |= MappedMemoryRegion::PRIVATE; | |
| +#endif | |
| // Pushing then assigning saves us a string copy. | |
| regions.push_back(region); | |
| regions.back().path.assign(line + path_index); | |
| diff --git a/base/files/dir_reader_linux.h b/base/files/dir_reader_linux.h | |
| index 4ce0c34..c32700a 100644 | |
| --- a/base/files/dir_reader_linux.h | |
| +++ b/base/files/dir_reader_linux.h | |
| @@ -34,6 +34,7 @@ class DirReaderLinux { | |
| : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), | |
| offset_(0), | |
| size_(0) { | |
| + DLOG(ERROR) << "DirReaderLinux(): " << directory_path; | |
| memset(buf_, 0, sizeof(buf_)); | |
| } | |
| @@ -58,13 +59,26 @@ class DirReaderLinux { | |
| if (offset_ != size_) | |
| return true; | |
| + DLOG(ERROR) << "getdents64 fd " << fd_ << "buf: " << buf_ << "size: " << sizeof(buf_); | |
| const int r = syscall(__NR_getdents64, fd_, buf_, sizeof(buf_)); | |
| if (r == 0) | |
| return false; | |
| if (r == -1) { | |
| +#if !defined(WSL_HACK) | |
| DPLOG(FATAL) << "getdents64 returned an error: " << errno; | |
| +#else | |
| + DLOG(ERROR) << "getdents64 returned an error: " << errno; | |
| +#endif | |
| return false; | |
| } | |
| + | |
| + int off = 0; | |
| + while (off < r) { | |
| + linux_dirent* dirent = reinterpret_cast<linux_dirent*>(&buf_[offset_]); | |
| + DLOG(ERROR) << dirent->d_name; | |
| + off += dirent->d_reclen; | |
| + } | |
| + | |
| size_ = r; | |
| offset_ = 0; | |
| return true; | |
| @@ -89,7 +103,11 @@ class DirReaderLinux { | |
| private: | |
| const int fd_; | |
| +#if !defined(WSL_HACK) | |
| unsigned char buf_[512]; | |
| +#else | |
| + unsigned char buf_[64*1024*1024]; | |
| +#endif | |
| size_t offset_; | |
| size_t size_; | |
| diff --git a/base/files/dir_reader_posix.h b/base/files/dir_reader_posix.h | |
| index 6a32d9f..aa28db8 100644 | |
| --- a/base/files/dir_reader_posix.h | |
| +++ b/base/files/dir_reader_posix.h | |
| @@ -17,7 +17,7 @@ | |
| // seems worse than falling back to enumerating all file descriptors so we will | |
| // probably never implement this on the Mac. | |
| -#if defined(OS_LINUX) | |
| +#if defined(OS_LINUX) && !defined(WSL_HACK) | |
| #include "base/files/dir_reader_linux.h" | |
| #else | |
| #include "base/files/dir_reader_fallback.h" | |
| @@ -25,7 +25,7 @@ | |
| namespace base { | |
| -#if defined(OS_LINUX) | |
| +#if defined(OS_LINUX) && !defined(WSL_HACK) | |
| typedef DirReaderLinux DirReaderPosix; | |
| #else | |
| typedef DirReaderFallback DirReaderPosix; | |
| diff --git a/build/build_config.h b/build/build_config.h | |
| index c3d82d0..54a27d9 100644 | |
| --- a/build/build_config.h | |
| +++ b/build/build_config.h | |
| @@ -15,6 +15,8 @@ | |
| #ifndef BUILD_BUILD_CONFIG_H_ | |
| #define BUILD_BUILD_CONFIG_H_ | |
| +#define WSL_HACK 1 | |
| + | |
| // A set of macros to use for platform detection. | |
| #if defined(__native_client__) | |
| // __native_client__ must be first, so that other OS_ defines are not set. | |
| diff --git a/build/common.gypi b/build/common.gypi | |
| index f5d107d..4fdc7c0 100644 | |
| --- a/build/common.gypi | |
| +++ b/build/common.gypi | |
| @@ -735,7 +735,8 @@ | |
| # libudev usage. This currently only affects the content layer. | |
| ['OS=="linux" and embedded==0', { | |
| - 'use_udev%': 1, | |
| + # 'use_udev%': 1, | |
| + 'use_udev%': 0, | |
| }, { | |
| 'use_udev%': 0, | |
| }], | |
| diff --git a/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_linux.cc b/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_linux.cc | |
| index 60921f3..fa3b40c 100644 | |
| --- a/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_linux.cc | |
| +++ b/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_linux.cc | |
| @@ -8,12 +8,15 @@ | |
| #include "base/strings/string_number_conversions.h" | |
| #include "chrome/browser/extensions/api/image_writer_private/removable_storage_provider.h" | |
| #include "content/public/browser/browser_thread.h" | |
| +#if defined(USE_UDEV) | |
| #include "device/udev_linux/scoped_udev.h" | |
| +#endif | |
| namespace extensions { | |
| // TODO(haven): Udev code may be duplicated in the Chrome codebase. | |
| // https://code.google.com/p/chromium/issues/detail?id=284898 | |
| +#if defined(USE_UDEV) | |
| // Returns the integer contained in |attr|. Returns 0 on error. | |
| static uint64_t get_int_attr(const char* attr) { | |
| uint64_t result = 0; | |
| @@ -41,9 +44,11 @@ static int get_device_blk_size(const std::string& path) { | |
| return blk_size; | |
| } | |
| +#endif // defined(USE_UDEV) | |
| bool RemovableStorageProvider::PopulateDeviceList( | |
| scoped_refptr<StorageDeviceList> device_list) { | |
| +#if defined (USE_UDEV) | |
| device::ScopedUdevPtr udev(device::udev_new()); | |
| if (!udev) { | |
| DLOG(ERROR) << "Can't create udev"; | |
| @@ -105,7 +110,8 @@ bool RemovableStorageProvider::PopulateDeviceList( | |
| device_list->data.push_back(std::move(device_item)); | |
| } | |
| - | |
| +#endif // defined(USE_UDEV) | |
| + | |
| return true; | |
| } | |
| diff --git a/components/storage_monitor/storage_monitor.cc b/components/storage_monitor/storage_monitor.cc | |
| index 6f2b23c..d6714c3 100644 | |
| --- a/components/storage_monitor/storage_monitor.cc | |
| +++ b/components/storage_monitor/storage_monitor.cc | |
| @@ -52,7 +52,9 @@ void StorageMonitor::ReceiverImpl::MarkInitialized() { | |
| // static | |
| void StorageMonitor::Create() { | |
| delete g_storage_monitor; | |
| +#if defined(USE_UDEV) | |
| g_storage_monitor = CreateInternal(); | |
| +#endif | |
| } | |
| // static | |
| diff --git a/device/serial/serial_service_impl.cc b/device/serial/serial_service_impl.cc | |
| index 97ad57f..a8e2530 100644 | |
| --- a/device/serial/serial_service_impl.cc | |
| +++ b/device/serial/serial_service_impl.cc | |
| @@ -75,8 +75,10 @@ void SerialServiceImpl::Connect( | |
| } | |
| SerialDeviceEnumerator* SerialServiceImpl::GetDeviceEnumerator() { | |
| +#if defined(USE_UDEV) | |
| if (!device_enumerator_) | |
| device_enumerator_ = SerialDeviceEnumerator::Create(); | |
| +#endif | |
| return device_enumerator_.get(); | |
| } | |
| diff --git a/extensions/browser/api/serial/serial_api.cc b/extensions/browser/api/serial/serial_api.cc | |
| index 3f126a8..bdc1b5c 100644 | |
| --- a/extensions/browser/api/serial/serial_api.cc | |
| +++ b/extensions/browser/api/serial/serial_api.cc | |
| @@ -86,11 +86,13 @@ bool SerialGetDevicesFunction::Prepare() { | |
| void SerialGetDevicesFunction::Work() { | |
| DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| +#if defined(USE_UDEV) | |
| std::unique_ptr<device::SerialDeviceEnumerator> enumerator = | |
| device::SerialDeviceEnumerator::Create(); | |
| mojo::Array<device::serial::DeviceInfoPtr> devices = enumerator->GetDevices(); | |
| results_ = serial::GetDevices::Results::Create( | |
| devices.To<std::vector<serial::DeviceInfo>>()); | |
| +#endif | |
| } | |
| SerialConnectFunction::SerialConnectFunction() { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment