Doug Zongker | 18a78e0 | 2014-07-10 07:31:46 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Tao Bao | 91a7aa4 | 2017-05-01 15:57:38 -0700 | [diff] [blame] | 17 | #include "fuse_adb_provider.h" |
| 18 | |
Doug Zongker | 18a78e0 | 2014-07-10 07:31:46 -0700 | [diff] [blame] | 19 | #include <errno.h> |
Tao Bao | 91a7aa4 | 2017-05-01 15:57:38 -0700 | [diff] [blame] | 20 | #include <stdio.h> |
Tao Bao | 91a7aa4 | 2017-05-01 15:57:38 -0700 | [diff] [blame] | 21 | #include <string.h> |
| 22 | |
Doug Zongker | 18a78e0 | 2014-07-10 07:31:46 -0700 | [diff] [blame] | 23 | #include "adb.h" |
Dan Albert | 432584f | 2015-02-24 22:48:25 -0800 | [diff] [blame] | 24 | #include "adb_io.h" |
Doug Zongker | 18a78e0 | 2014-07-10 07:31:46 -0700 | [diff] [blame] | 25 | |
xunchang | ea2912f | 2019-03-17 16:45:12 -0700 | [diff] [blame] | 26 | bool FuseAdbDataProvider::ReadBlockAlignedData(uint8_t* buffer, uint32_t fetch_size, |
| 27 | uint32_t start_block) const { |
| 28 | if (!WriteFdFmt(fd_, "%08u", start_block)) { |
Tao Bao | 91a7aa4 | 2017-05-01 15:57:38 -0700 | [diff] [blame] | 29 | fprintf(stderr, "failed to write to adb host: %s\n", strerror(errno)); |
xunchang | ea2912f | 2019-03-17 16:45:12 -0700 | [diff] [blame] | 30 | return false; |
Tao Bao | 91a7aa4 | 2017-05-01 15:57:38 -0700 | [diff] [blame] | 31 | } |
Doug Zongker | 18a78e0 | 2014-07-10 07:31:46 -0700 | [diff] [blame] | 32 | |
xunchang | ea2912f | 2019-03-17 16:45:12 -0700 | [diff] [blame] | 33 | if (!ReadFdExactly(fd_, buffer, fetch_size)) { |
Tao Bao | 91a7aa4 | 2017-05-01 15:57:38 -0700 | [diff] [blame] | 34 | fprintf(stderr, "failed to read from adb host: %s\n", strerror(errno)); |
xunchang | ea2912f | 2019-03-17 16:45:12 -0700 | [diff] [blame] | 35 | return false; |
Tao Bao | 91a7aa4 | 2017-05-01 15:57:38 -0700 | [diff] [blame] | 36 | } |
Doug Zongker | 18a78e0 | 2014-07-10 07:31:46 -0700 | [diff] [blame] | 37 | |
xunchang | ea2912f | 2019-03-17 16:45:12 -0700 | [diff] [blame] | 38 | return true; |
Doug Zongker | 18a78e0 | 2014-07-10 07:31:46 -0700 | [diff] [blame] | 39 | } |