• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 #include "fuse_adb_provider.h"
18 
19 #include <errno.h>
20 #include <stdio.h>
21 #include <string.h>
22 
23 #include "adb.h"
24 #include "adb_io.h"
25 
ReadBlockAlignedData(uint8_t * buffer,uint32_t fetch_size,uint32_t start_block) const26 bool FuseAdbDataProvider::ReadBlockAlignedData(uint8_t* buffer, uint32_t fetch_size,
27                                                uint32_t start_block) const {
28   if (!WriteFdFmt(fd_, "%08u", start_block)) {
29     fprintf(stderr, "failed to write to adb host: %s\n", strerror(errno));
30     return false;
31   }
32 
33   if (!ReadFdExactly(fd_, buffer, fetch_size)) {
34     fprintf(stderr, "failed to read from adb host: %s\n", strerror(errno));
35     return false;
36   }
37 
38   return true;
39 }
40