1 /* 2 * Copyright (C) 2021 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 package com.android.virt.fs; 18 19 /** {@hide} */ 20 interface IVirtFdService { 21 /** Error when the requesting FD is unknown. */ 22 const int ERROR_UNKNOWN_FD = 1; 23 24 /** 25 * Error when I/O fails. This can happen when actual I/O error happens to the backing file, 26 * when the given offset or size are invalid, or any problems that can fail a read/write 27 * request. 28 */ 29 const int ERROR_IO = 2; 30 31 /** Maximum content size that the service allows the client to request. */ 32 const int MAX_REQUESTING_DATA = 16384; 33 34 /** 35 * Returns the content of the given file ID, from the offset, for the amount of requested size 36 * or until EOF. 37 */ readFile(int id, long offset, int size)38 byte[] readFile(int id, long offset, int size); 39 40 /** 41 * Returns the content of fs-verity compatible Merkle tree of the given file ID, from the 42 * offset, for the amount of requested size or until EOF. 43 */ readFsverityMerkleTree(int id, long offset, int size)44 byte[] readFsverityMerkleTree(int id, long offset, int size); 45 46 /** Returns the fs-verity signature of the given file ID. */ readFsveritySignature(int id)47 byte[] readFsveritySignature(int id); 48 49 /** 50 * Writes the buffer to the given file ID from the file's offset. Returns the number of bytes 51 * written. 52 */ writeFile(int id, in byte[] buf, long offset)53 int writeFile(int id, in byte[] buf, long offset); 54 55 /** Resizes the file backed by the given file ID to the new size. */ resize(int id, long size)56 void resize(int id, long size); 57 } 58