1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef FS_DM_MOCK_H 16 #define FS_DM_MOCK_H 17 #include "fs_dm.h" 18 #include <stdarg.h> 19 #include <stdint.h> 20 #include <stdio.h> 21 #include <stdlib.h> 22 #include <sys/stat.h> 23 #ifdef __cplusplus 24 #if __cplusplus 25 extern "C" { 26 #endif 27 #endif 28 29 // for wrapper FsDmInitDmDev; 30 int __real_FsDmInitDmDev(char *devPath, bool useSocket); 31 typedef int (*FsdminitdmdevFunc)(char *devPath, bool useSocket); 32 void UpdateFsdminitdmdevFunc(FsdminitdmdevFunc func); 33 34 // for wrapper FsDmCreateDevice; 35 int __real_FsDmCreateDevice(char **dmDevPath, const char *devName, DmVerityTarget *target); 36 typedef int (*FsdmcreatedeviceFunc)(char **dmDevPath, const char *devName, DmVerityTarget *target); 37 void UpdateFsdmcreatedeviceFunc(FsdmcreatedeviceFunc func); 38 39 // for wrapper FsDmRemoveDevice; 40 int __real_FsDmRemoveDevice(const char *devName); 41 typedef int (*FsdmremovedeviceFunc)(const char *devName); 42 void UpdateFsdmremovedeviceFunc(FsdmremovedeviceFunc func); 43 44 // for wrapper LoadDmDeviceTable; 45 int __real_LoadDmDeviceTable(int fd, const char *devName, DmVerityTarget *target, int dmType); 46 typedef int (*LoaddmdevicetableFunc)(int fd, const char *devName, DmVerityTarget *target, int dmType); 47 void UpdateLoaddmdevicetableFunc(LoaddmdevicetableFunc func); 48 49 // for wrapper DmGetDeviceName; 50 int __real_DmGetDeviceName(int fd, const char *devName, char *outDevName, const uint64_t outDevNameLen); 51 typedef int (*DmgetdevicenameFunc)(int fd, const char *devName, char *outDevName, const uint64_t outDevNameLen); 52 void UpdateDmgetdevicenameFunc(DmgetdevicenameFunc func); 53 54 // for wrapper ActiveDmDevice; 55 int __real_ActiveDmDevice(int fd, const char *devName); 56 typedef int (*ActivedmdeviceFunc)(int fd, const char *devName); 57 void UpdateActivedmdeviceFunc(ActivedmdeviceFunc func); 58 59 // for wrapper InitDmIo; 60 int __real_InitDmIo(struct dm_ioctl *io, const char *devName); 61 typedef int (*InitdmioFunc)(struct dm_ioctl *io, const char *devName); 62 void UpdateInitdmioFunc(InitdmioFunc func); 63 64 // for wrapper CreateDmDev; 65 int __real_CreateDmDev(int fd, const char *devName); 66 typedef int (*CreatedmdevFunc)(int fd, const char *devName); 67 void UpdateCreatedmdevFunc(CreatedmdevFunc func); 68 69 // for wrapper GetDmDevPath; 70 int __real_GetDmDevPath(int fd, char **dmDevPath, const char *devName); 71 typedef int (*GetdmdevpathFunc)(int fd, char **dmDevPath, const char *devName); 72 void UpdateGetdmdevpathFunc(GetdmdevpathFunc func); 73 74 // for wrapper GetDmStatusInfo; 75 bool __real_GetDmStatusInfo(const char *name, struct dm_ioctl *io); 76 typedef bool (*GetdmstatusinfoFunc)(const char *name, struct dm_ioctl *io); 77 void UpdateGetdmstatusinfoFunc(GetdmstatusinfoFunc func); 78 79 #ifdef __cplusplus 80 #if __cplusplus 81 } 82 #endif 83 #endif 84 #endif // TEST_WRAPPER_H