diff --git a/ctru-sys/src/services/fs.rs b/ctru-sys/src/services/fs.rs index 0608bb9..421bbcb 100644 --- a/ctru-sys/src/services/fs.rs +++ b/ctru-sys/src/services/fs.rs @@ -1,44 +1,45 @@ -// TODO: Determine if anonymous enums are properly represented (they probably aren't) +/* automatically generated by rust-bindgen */ + +#![allow(dead_code, + non_camel_case_types, + non_upper_case_globals, + non_snake_case)] use ::{Handle, Result}; -use ::libc::c_void; -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed1 { - FS_OPEN_READ = 1, - FS_OPEN_WRITE = 2, - FS_OPEN_CREATE = 4, -} +pub const FS_OPEN_READ: u32 = 1; +pub const FS_OPEN_WRITE: u32 = 2; +pub const FS_OPEN_CREATE: u32 = 4; -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed2 { - FS_WRITE_FLUSH = 1, - FS_WRITE_UPDATE_TIME = 256, -} +pub const FS_WRITE_FLUSH: u32 = 1; +pub const FS_WRITE_UPDATE_TIME: u32 = 256; -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed3 { - FS_ATTRIBUTE_DIRECTORY = 1, - FS_ATTRIBUTE_HIDDEN = 256, - FS_ATTRIBUTE_ARCHIVE = 65536, - FS_ATTRIBUTE_READ_ONLY = 16777216, -} +pub const FS_ATTRIBUTE_DIRECTORY: u32 = 1; +pub const FS_ATTRIBUTE_HIDDEN: u32 = 256; +pub const FS_ATTRIBUTE_ARCHIVE: u32 = 65536; +pub const FS_ATTRIBUTE_READ_ONLY: u32 = 16777216; -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed4 { +#[derive(Copy, Clone)] +#[repr(u32)] +#[derive(Debug)] +pub enum FS_MediaType { MEDIATYPE_NAND = 0, MEDIATYPE_SD = 1, MEDIATYPE_GAME_CARD = 2, } - -pub type FS_MediaType = Enum_Unnamed4; -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed5 { +#[derive(Copy, Clone)] +#[repr(u32)] +#[derive(Debug)] +pub enum FS_SystemMediaType { + SYSTEM_MEDIATYPE_CTR_NAND = 0, + SYSTEM_MEDIATYPE_TWL_NAND = 1, + SYSTEM_MEDIATYPE_SD = 2, + SYSTEM_MEDIATYPE_TWL_PHOTO = 3, +} +#[derive(Copy, Clone)] +#[repr(u32)] +#[derive(Debug)] +pub enum FS_ArchiveID { ARCHIVE_ROMFS = 3, ARCHIVE_SAVEDATA = 4, ARCHIVE_EXTDATA = 6, @@ -57,33 +58,31 @@ pub enum Enum_Unnamed5 { ARCHIVE_SAVEDATA_AND_CONTENT2 = 591751054, ARCHIVE_NAND_CTR_FS = 1450741931, ARCHIVE_TWL_PHOTO = 1450741932, + ARCHIVE_TWL_SOUND = 1450741933, ARCHIVE_NAND_TWL_FS = 1450741934, ARCHIVE_NAND_W_FS = 1450741935, ARCHIVE_GAMECARD_SAVEDATA = 1450741937, ARCHIVE_USER_SAVEDATA = 1450741938, ARCHIVE_DEMO_SAVEDATA = 1450741940, } -pub type FS_ArchiveID = Enum_Unnamed5; - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed6 { +#[derive(Copy, Clone)] +#[repr(u32)] +#[derive(Debug)] +pub enum FS_PathType { PATH_INVALID = 0, PATH_EMPTY = 1, PATH_BINARY = 2, PATH_ASCII = 3, PATH_UTF16 = 4, } -pub type FS_PathType = Enum_Unnamed6; - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed7 { SECUREVALUE_SLOT_SD = 4096, } -pub type FS_SecureValueSlot = Enum_Unnamed7; - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed8 { +#[derive(Copy, Clone)] +#[repr(u32)] +#[derive(Debug)] +pub enum FS_SecureValueSlot { SECUREVALUE_SLOT_SD = 4096, } +#[derive(Copy, Clone)] +#[repr(u32)] +#[derive(Debug)] +pub enum FS_CardSpiBaudRate { BAUDRATE_512KHZ = 0, BAUDRATE_1MHZ = 1, BAUDRATE_2MHZ = 2, @@ -91,64 +90,51 @@ pub enum Enum_Unnamed8 { BAUDRATE_8MHZ = 4, BAUDRATE_16MHZ = 5, } -pub type FS_CardSpiBaudRate = Enum_Unnamed8; - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed9 { - BUSMODE_1BIT = 0, - BUSMODE_4BIT = 1, -} -pub type FS_CardSpiBusMode = Enum_Unnamed9; - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed10 { +#[derive(Copy, Clone)] +#[repr(u32)] +#[derive(Debug)] +pub enum FS_CardSpiBusMode { BUSMODE_1BIT = 0, BUSMODE_4BIT = 1, } +#[derive(Copy, Clone)] +#[repr(u32)] +#[derive(Debug)] +pub enum FS_SpecialContentType { SPECIALCONTENT_UPDATE = 1, SPECIALCONTENT_MANUAL = 2, SPECIALCONTENT_DLP_CHILD = 3, } -pub type FS_SpecialContentType = Enum_Unnamed10; - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed11 { CARD_CTR = 0, CARD_TWL = 1, } -pub type FS_CardType = Enum_Unnamed11; - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed12 { FS_ACTION_UNKNOWN = 0, } -pub type FS_Action = Enum_Unnamed12; - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed13 { +#[derive(Copy, Clone)] +#[repr(u32)] +#[derive(Debug)] +pub enum FS_CardType { CARD_CTR = 0, CARD_TWL = 1, } +#[derive(Copy, Clone)] +#[repr(u32)] +#[derive(Debug)] +pub enum FS_Action { FS_ACTION_UNKNOWN = 0, } +#[derive(Copy, Clone)] +#[repr(u32)] +#[derive(Debug)] +pub enum FS_ArchiveAction { ARCHIVE_ACTION_COMMIT_SAVE_DATA = 0, ARCHIVE_ACTION_GET_TIMESTAMP = 1, } -pub type FS_ArchiveAction = Enum_Unnamed13; - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed14 { +#[derive(Copy, Clone)] +#[repr(u32)] +#[derive(Debug)] +pub enum FS_SecureSaveAction { SECURESAVE_ACTION_DELETE = 0, SECURESAVE_ACTION_FORMAT = 1, } -pub type FS_SecureSaveAction = Enum_Unnamed14; - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed15 { FILE_ACTION_UNKNOWN = 0, } -pub type FS_FileAction = Enum_Unnamed15; - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum Enum_Unnamed16 { DIRECTORY_ACTION_UNKNOWN = 0, } -pub type FS_DirectoryAction = Enum_Unnamed16; - +#[derive(Copy, Clone)] +#[repr(u32)] +#[derive(Debug)] +pub enum FS_FileAction { FILE_ACTION_UNKNOWN = 0, } +#[derive(Copy, Clone)] +#[repr(u32)] +#[derive(Debug)] +pub enum FS_DirectoryAction { DIRECTORY_ACTION_UNKNOWN = 0, } #[repr(C)] #[derive(Copy)] -pub struct Struct_Unnamed17 { +pub struct FS_DirectoryEntry { pub name: [u16; 262usize], pub shortName: [u8; 10usize], pub shortExt: [u8; 4usize], @@ -157,169 +143,175 @@ pub struct Struct_Unnamed17 { pub attributes: u32, pub fileSize: u64, } -impl ::core::clone::Clone for Struct_Unnamed17 { +impl ::core::clone::Clone for FS_DirectoryEntry { fn clone(&self) -> Self { *self } } -impl ::core::default::Default for Struct_Unnamed17 { +impl ::core::default::Default for FS_DirectoryEntry { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } -pub type FS_DirectoryEntry = Struct_Unnamed17; - #[repr(C)] -#[derive(Copy)] -pub struct Struct_Unnamed18 { +#[derive(Copy, Clone)] +#[derive(Debug)] +pub struct FS_ArchiveResource { pub sectorSize: u32, pub clusterSize: u32, pub totalClusters: u32, pub freeClusters: u32, } -impl ::core::clone::Clone for Struct_Unnamed18 { - fn clone(&self) -> Self { *self } -} -impl ::core::default::Default for Struct_Unnamed18 { +impl ::core::default::Default for FS_ArchiveResource { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } -pub type FS_ArchiveResource = Struct_Unnamed18; - #[repr(C)] -#[derive(Copy)] -pub struct Struct_Unnamed19 { +#[derive(Copy, Clone)] +#[derive(Debug)] +pub struct FS_ProgramInfo { pub programId: u64, pub _bindgen_bitfield_1_: FS_MediaType, pub padding: [u8; 7usize], } -impl ::core::clone::Clone for Struct_Unnamed19 { - fn clone(&self) -> Self { *self } -} -impl ::core::default::Default for Struct_Unnamed19 { +impl ::core::default::Default for FS_ProgramInfo { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } -pub type FS_ProgramInfo = Struct_Unnamed19; - #[repr(C)] -#[derive(Copy)] -pub struct Struct_Unnamed20 { +#[derive(Copy, Clone)] +#[derive(Debug)] +pub struct FS_ProductInfo { pub productCode: [u8; 16usize], pub companyCode: [u8; 2usize], pub remasterVersion: u16, } -impl ::core::clone::Clone for Struct_Unnamed20 { - fn clone(&self) -> Self { *self } -} -impl ::core::default::Default for Struct_Unnamed20 { +impl ::core::default::Default for FS_ProductInfo { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } -pub type FS_ProductInfo = Struct_Unnamed20; - #[repr(C)] #[derive(Copy)] -pub struct Struct_Unnamed21 { +pub struct FS_IntegrityVerificationSeed { pub aesCbcMac: [u8; 16usize], pub movableSed: [u8; 288usize], } -impl ::core::clone::Clone for Struct_Unnamed21 { +impl ::core::clone::Clone for FS_IntegrityVerificationSeed { fn clone(&self) -> Self { *self } } -impl ::core::default::Default for Struct_Unnamed21 { +impl ::core::default::Default for FS_IntegrityVerificationSeed { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } -pub type FS_IntegrityVerificationSeed = Struct_Unnamed21; - #[repr(C, packed)] -#[derive(Copy)] -pub struct Struct_Unnamed22 { +#[derive(Copy, Clone)] +#[derive(Debug)] +pub struct FS_ExtSaveDataInfo { pub _bindgen_bitfield_1_: FS_MediaType, pub unknown: u8, pub reserved1: u16, pub saveId: u64, pub reserved2: u32, } -impl ::core::clone::Clone for Struct_Unnamed22 { - fn clone(&self) -> Self { *self } -} -impl ::core::default::Default for Struct_Unnamed22 { +impl ::core::default::Default for FS_ExtSaveDataInfo { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } -pub type FS_ExtSaveDataInfo = Struct_Unnamed22; - #[repr(C)] -#[derive(Copy)] -pub struct Struct_Unnamed23 { +#[derive(Copy, Clone)] +#[derive(Debug)] +pub struct FS_SystemSaveDataInfo { pub _bindgen_bitfield_1_: FS_MediaType, pub unknown: u8, pub reserved: u16, pub saveId: u32, } -impl ::core::clone::Clone for Struct_Unnamed23 { - fn clone(&self) -> Self { *self } -} -impl ::core::default::Default for Struct_Unnamed23 { +impl ::core::default::Default for FS_SystemSaveDataInfo { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } -pub type FS_SystemSaveDataInfo = Struct_Unnamed23; - #[repr(C)] -#[derive(Copy)] -pub struct Struct_Unnamed24 { +#[derive(Copy, Clone)] +#[derive(Debug)] +pub struct FS_DeviceMoveContext { pub ivs: [u8; 16usize], pub encryptParameter: [u8; 16usize], } -impl ::core::clone::Clone for Struct_Unnamed24 { - fn clone(&self) -> Self { *self } -} -impl ::core::default::Default for Struct_Unnamed24 { +impl ::core::default::Default for FS_DeviceMoveContext { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } -pub type FS_DeviceMoveContext = Struct_Unnamed24; - #[repr(C)] -#[derive(Copy)] -pub struct Struct_Unnamed25 { - pub _type: FS_PathType, +#[derive(Copy, Clone)] +#[derive(Debug)] +pub struct FS_Path { + pub type_: FS_PathType, pub size: u32, - pub data: *const c_void, + pub data: *const ::libc::c_void, } -impl ::core::clone::Clone for Struct_Unnamed25 { - fn clone(&self) -> Self { *self } -} -impl ::core::default::Default for Struct_Unnamed25 { +impl ::core::default::Default for FS_Path { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } -pub type FS_Path = Struct_Unnamed25; - +pub type FS_Archive = u64; #[repr(C)] -#[derive(Copy)] -pub struct Struct_Unnamed26 { - pub id: u32, - pub lowPath: FS_Path, - pub handle: u64, +#[derive(Copy, Clone)] +#[derive(Debug)] +pub struct romfs_header { + pub headerSize: u32, + pub dirHashTableOff: u32, + pub dirHashTableSize: u32, + pub dirTableOff: u32, + pub dirTableSize: u32, + pub fileHashTableOff: u32, + pub fileHashTableSize: u32, + pub fileTableOff: u32, + pub fileTableSize: u32, + pub fileDataOff: u32, +} +impl ::core::default::Default for romfs_header { + fn default() -> Self { unsafe { ::core::mem::zeroed() } } } -impl ::core::clone::Clone for Struct_Unnamed26 { - fn clone(&self) -> Self { *self } +#[repr(C)] +#[derive(Copy, Clone)] +#[derive(Debug)] +pub struct romfs_dir { + pub parent: u32, + pub sibling: u32, + pub childDir: u32, + pub childFile: u32, + pub nextHash: u32, + pub nameLen: u32, + pub name: [u16; 0usize], +} +impl ::core::default::Default for romfs_dir { + fn default() -> Self { unsafe { ::core::mem::zeroed() } } } -impl ::core::default::Default for Struct_Unnamed26 { +#[repr(C)] +#[derive(Copy, Clone)] +#[derive(Debug)] +pub struct romfs_file { + pub parent: u32, + pub sibling: u32, + pub dataOff: u64, + pub dataSize: u64, + pub nextHash: u32, + pub nameLen: u32, + pub name: [u16; 0usize], +} +impl ::core::default::Default for romfs_file { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } -pub type FS_Archive = Struct_Unnamed26; +pub enum romfs_mount { } extern "C" { pub fn fsInit() -> Result; pub fn fsExit(); - pub fn fsUseSession(session: Handle, sdmc: u8); + pub fn fsUseSession(session: Handle); pub fn fsEndUseSession(); - pub fn fsMakePath(_type: FS_PathType, path: *const c_void) + pub fn fsExemptFromSession(archive: FS_Archive); + pub fn fsUnexemptFromSession(archive: FS_Archive); + pub fn fsMakePath(type_: FS_PathType, path: *const ::libc::c_void) -> FS_Path; pub fn fsGetSessionHandle() -> *mut Handle; - pub fn FSUSER_Control(action: FS_Action, - input: *mut c_void, inputSize: u32, - output: *mut c_void, + pub fn FSUSER_Control(action: FS_Action, input: *mut ::libc::c_void, + inputSize: u32, output: *mut ::libc::c_void, outputSize: u32) -> Result; pub fn FSUSER_Initialize(session: Handle) -> Result; pub fn FSUSER_OpenFile(out: *mut Handle, archive: FS_Archive, path: FS_Path, openFlags: u32, attributes: u32) -> Result; - pub fn FSUSER_OpenFileDirectly(out: *mut Handle, archive: FS_Archive, - path: FS_Path, openFlags: u32, - attributes: u32) -> Result; + pub fn FSUSER_OpenFileDirectly(out: *mut Handle, archiveId: FS_ArchiveID, + archivePath: FS_Path, filePath: FS_Path, + openFlags: u32, attributes: u32) + -> Result; pub fn FSUSER_DeleteFile(archive: FS_Archive, path: FS_Path) -> Result; pub fn FSUSER_RenameFile(srcArchive: FS_Archive, srcPath: FS_Path, dstArchive: FS_Archive, dstPath: FS_Path) @@ -337,17 +329,17 @@ extern "C" { -> Result; pub fn FSUSER_OpenDirectory(out: *mut Handle, archive: FS_Archive, path: FS_Path) -> Result; - pub fn FSUSER_OpenArchive(archive: *mut FS_Archive) -> Result; + pub fn FSUSER_OpenArchive(archive: *mut FS_Archive, id: FS_ArchiveID, + path: FS_Path) -> Result; pub fn FSUSER_ControlArchive(archive: FS_Archive, action: FS_ArchiveAction, - input: *mut c_void, - inputSize: u32, - output: *mut c_void, + input: *mut ::libc::c_void, inputSize: u32, + output: *mut ::libc::c_void, outputSize: u32) -> Result; - pub fn FSUSER_CloseArchive(archive: *mut FS_Archive) -> Result; + pub fn FSUSER_CloseArchive(archive: FS_Archive) -> Result; pub fn FSUSER_GetFreeBytes(freeBytes: *mut u64, archive: FS_Archive) -> Result; - pub fn FSUSER_GetCardType(_type: *mut FS_CardType) -> Result; + pub fn FSUSER_GetCardType(type_: *mut FS_CardType) -> Result; pub fn FSUSER_GetSdmcArchiveResource(archiveResource: *mut FS_ArchiveResource) -> Result; @@ -401,12 +393,13 @@ extern "C" { pub fn FSUSER_GetSpecialContentIndex(index: *mut u16, mediaType: FS_MediaType, programId: u64, - _type: FS_SpecialContentType) + type_: FS_SpecialContentType) -> Result; pub fn FSUSER_GetLegacyRomHeader(mediaType: FS_MediaType, programId: u64, header: *mut u8) -> Result; - pub fn FSUSER_GetLegacyBannerData(mediaType: FS_MediaType, programId: u64, - banner: *mut u8) -> Result; + pub fn FSUSER_GetLegacyBannerData(mediaType: FS_MediaType, + programId: u64, banner: *mut u8) + -> Result; pub fn FSUSER_CheckAuthorityToAccessExtSaveData(access: *mut u8, mediaType: FS_MediaType, saveId: u64, @@ -425,11 +418,12 @@ extern "C" { archiveId: FS_ArchiveID, path: FS_Path) -> Result; pub fn FSUSER_GetLegacyRomHeader2(headerSize: u32, - mediaType: FS_MediaType, programId: u64, - header: *mut u8) -> Result; + mediaType: FS_MediaType, + programId: u64, header: *mut u8) + -> Result; pub fn FSUSER_GetSdmcCtrRootPath(out: *mut u8, length: u32) -> Result; pub fn FSUSER_GetArchiveResource(archiveResource: *mut FS_ArchiveResource, - mediaType: FS_MediaType) -> Result; + mediaType: FS_SystemMediaType) -> Result; pub fn FSUSER_ExportIntegrityVerificationSeed(seed: *mut FS_IntegrityVerificationSeed) -> Result; @@ -482,13 +476,14 @@ extern "C" { emulateEndurance: u8) -> Result; pub fn FSUSER_SwitchCleanupInvalidSaveData(enable: u8) -> Result; pub fn FSUSER_EnumerateSystemSaveData(idsWritten: *mut u32, - idsSize: u32, ids: *mut u64) + idsSize: u32, ids: *mut u32) -> Result; pub fn FSUSER_InitializeWithSdkVersion(session: Handle, version: u32) -> Result; pub fn FSUSER_SetPriority(priority: u32) -> Result; pub fn FSUSER_GetPriority(priority: *mut u32) -> Result; - pub fn FSUSER_SetSaveDataSecureValue(value: u64, slot: FS_SecureValueSlot, + pub fn FSUSER_SetSaveDataSecureValue(value: u64, + slot: FS_SecureValueSlot, titleUniqueId: u32, titleVariation: u8) -> Result; pub fn FSUSER_GetSaveDataSecureValue(exists: *mut u8, value: *mut u64, @@ -496,22 +491,21 @@ extern "C" { titleUniqueId: u32, titleVariation: u8) -> Result; pub fn FSUSER_ControlSecureSave(action: FS_SecureSaveAction, - input: *mut c_void, + input: *mut ::libc::c_void, inputSize: u32, - output: *mut c_void, + output: *mut ::libc::c_void, outputSize: u32) -> Result; pub fn FSUSER_GetMediaType(mediaType: *mut FS_MediaType) -> Result; pub fn FSFILE_Control(handle: Handle, action: FS_FileAction, - input: *mut c_void, inputSize: u32, - output: *mut c_void, - outputSize: u32) -> Result; + input: *mut ::libc::c_void, inputSize: u32, + output: *mut ::libc::c_void, outputSize: u32) + -> Result; pub fn FSFILE_OpenSubFile(handle: Handle, subFile: *mut Handle, offset: u64, size: u64) -> Result; pub fn FSFILE_Read(handle: Handle, bytesRead: *mut u32, offset: u64, - buffer: *mut c_void, size: u32) - -> Result; + buffer: *mut ::libc::c_void, size: u32) -> Result; pub fn FSFILE_Write(handle: Handle, bytesWritten: *mut u32, offset: u64, - buffer: *const c_void, size: u32, + buffer: *const ::libc::c_void, size: u32, flags: u32) -> Result; pub fn FSFILE_GetSize(handle: Handle, size: *mut u64) -> Result; pub fn FSFILE_SetSize(handle: Handle, size: u64) -> Result; @@ -525,13 +519,18 @@ extern "C" { pub fn FSFILE_OpenLinkFile(handle: Handle, linkFile: *mut Handle) -> Result; pub fn FSDIR_Control(handle: Handle, action: FS_DirectoryAction, - input: *mut c_void, inputSize: u32, - output: *mut c_void, - outputSize: u32) -> Result; + input: *mut ::libc::c_void, inputSize: u32, + output: *mut ::libc::c_void, outputSize: u32) + -> Result; pub fn FSDIR_Read(handle: Handle, entriesRead: *mut u32, entryCount: u32, entries: *mut FS_DirectoryEntry) -> Result; pub fn FSDIR_Close(handle: Handle) -> Result; pub fn FSDIR_SetPriority(handle: Handle, priority: u32) -> Result; pub fn FSDIR_GetPriority(handle: Handle, priority: *mut u32) -> Result; + pub fn romfsMount(mount: *mut *mut romfs_mount) -> Result; + pub fn romfsMountFromFile(file: Handle, offset: u32, + mount: *mut *mut romfs_mount) -> Result; + pub fn romfsBind(mount: *mut romfs_mount) -> Result; + pub fn romfsUnmount(mount: *mut romfs_mount) -> Result; }