forked from Mirror/GodMode9
Virtual drives: Introduce VFLAG_READONLY
This commit is contained in:
parent
99a638a084
commit
3407b3d5da
@ -22,6 +22,7 @@ bool ReadVCartDir(VirtualFile* vfile, VirtualDir* vdir) {
|
||||
GetCartName(name, cdata);
|
||||
memset(vfile, 0, sizeof(VirtualFile));
|
||||
vfile->keyslot = 0xFF; // unused
|
||||
vfile->flags = VFLAG_READONLY;
|
||||
|
||||
while (++vdir->index <= 5) {
|
||||
if ((vdir->index == 0) && (cdata->data_size < FAT_LIMIT)) { // standard full rom
|
||||
@ -45,7 +46,7 @@ bool ReadVCartDir(VirtualFile* vfile, VirtualDir* vdir) {
|
||||
} else if ((vdir->index == 5) && (cdata->cart_type & CART_CTR)) { // private header
|
||||
snprintf(vfile->name, 32, "%s-priv.bin", name);
|
||||
vfile->size = PRIV_HDR_SIZE;
|
||||
vfile->flags = VFLAG_PRIV_HDR;
|
||||
vfile->flags |= VFLAG_PRIV_HDR;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -726,7 +726,7 @@ bool OpenVGameDir(VirtualDir* vdir, VirtualFile* ventry) {
|
||||
bool ReadVGameDirLv3(VirtualFile* vfile, VirtualDir* vdir) {
|
||||
vfile->name[0] = '\0';
|
||||
BuildLv3Index(&lv3idx, romfslv3);
|
||||
vfile->flags = VFLAG_LV3;
|
||||
vfile->flags = VFLAG_LV3 | VFLAG_READONLY;
|
||||
vfile->keyslot = ((offset_ncch != (u64) -1) && NCCH_ENCRYPTED(ncch)) ?
|
||||
0x2C : 0xFF; // actual keyslot may be different
|
||||
|
||||
@ -801,7 +801,7 @@ bool ReadVGameDirNitro(VirtualFile* vfile, VirtualDir* vdir) {
|
||||
u8* fat = nitrofs + twl->fat_offset - twl->fnt_offset;
|
||||
|
||||
vfile->name[0] = '\0';
|
||||
vfile->flags = VFLAG_NITRO;
|
||||
vfile->flags = VFLAG_NITRO | VFLAG_READONLY;
|
||||
vfile->keyslot = 0;
|
||||
|
||||
// start from parent dir object
|
||||
@ -863,8 +863,9 @@ bool ReadVGameDir(VirtualFile* vfile, VirtualDir* vdir) {
|
||||
}
|
||||
|
||||
if (++vdir->index < n) {
|
||||
// copy current template to vfile
|
||||
// copy current template to vfile and set readonly flag
|
||||
memcpy(vfile, templates + vdir->index, sizeof(VirtualFile));
|
||||
vfile->flags |= VFLAG_READONLY;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,9 @@ int WriteVirtualFile(const VirtualFile* vfile, const void* buffer, u64 offset, u
|
||||
count = vfile->size - offset;
|
||||
if (bytes_written) *bytes_written = count;
|
||||
|
||||
if (vfile->flags & (VRT_SYSNAND|VRT_EMUNAND|VRT_IMGNAND)) {
|
||||
if (vfile->flags & VFLAG_READONLY) {
|
||||
return -1;
|
||||
} else if (vfile->flags & (VRT_SYSNAND|VRT_EMUNAND|VRT_IMGNAND)) {
|
||||
return WriteVNandFile(vfile, buffer, offset, count);
|
||||
} else if (vfile->flags & VRT_MEMORY) {
|
||||
return WriteVMemFile(vfile, buffer, offset, count);
|
||||
|
@ -7,26 +7,27 @@
|
||||
#define VRT_EMUNAND NAND_EMUNAND
|
||||
#define VRT_IMGNAND NAND_IMGNAND
|
||||
#define VRT_XORPAD NAND_ZERONAND
|
||||
#define VRT_MEMORY (1UL<<10)
|
||||
#define VRT_GAME (1UL<<11)
|
||||
#define VRT_TICKDB (1UL<<12)
|
||||
#define VRT_KEYDB (1UL<<13)
|
||||
#define VRT_CART (1UL<<14)
|
||||
#define VRT_MEMORY (1UL<<4)
|
||||
#define VRT_GAME (1UL<<5)
|
||||
#define VRT_TICKDB (1UL<<6)
|
||||
#define VRT_KEYDB (1UL<<7)
|
||||
#define VRT_CART (1UL<<8)
|
||||
|
||||
#define VRT_SOURCE (VRT_SYSNAND|VRT_EMUNAND|VRT_IMGNAND|VRT_XORPAD|VRT_MEMORY|VRT_GAME|VRT_TICKDB|VRT_KEYDB|VRT_CART)
|
||||
|
||||
#define VFLAG_DIR (1UL<<16)
|
||||
#define VFLAG_ROOT (1UL<<17)
|
||||
#define VFLAG_LV3 (1UL<<18)
|
||||
#define VFLAG_DIR (1UL<<10)
|
||||
#define VFLAG_ROOT (1UL<<11)
|
||||
#define VFLAG_READONLY (1UL<<12)
|
||||
#define VFLAG_LV3 (1UL<<13)
|
||||
|
||||
|
||||
#define VRT_DRIVES {'S', VRT_SYSNAND}, {'E', VRT_EMUNAND}, {'I', VRT_IMGNAND}, {'X', VRT_XORPAD }, \
|
||||
{'M', VRT_MEMORY}, {'G', VRT_GAME}, {'K', VRT_KEYDB}, {'T', VRT_TICKDB}, {'C', VRT_CART}
|
||||
|
||||
// virtual file flag (subject to change):
|
||||
// bits 0...9 : reserved for NAND virtual sources and info
|
||||
// bits 10...15: reserved for other virtual sources
|
||||
// bits 16...18: reserved for external flags
|
||||
// bits 0...3 : reserved for NAND virtual sources and info
|
||||
// bits 4...9 : reserved for other virtual sources
|
||||
// bits 10...18: reserved for external flags
|
||||
// bits 19...31: reserved for internal flags (different per source, see vgame.c)
|
||||
typedef struct {
|
||||
char name[32];
|
||||
|
@ -50,6 +50,7 @@ bool ReadVKeyDbDir(VirtualFile* vfile, VirtualDir* vdir) {
|
||||
vfile->offset = vdir->index * sizeof(AesKeyInfo);
|
||||
vfile->size = 16; // standard size of a key
|
||||
vfile->keyslot = 0xFF;
|
||||
vfile->flags = VFLAG_READONLY;
|
||||
|
||||
return true; // found
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ bool ReadVTickDbDir(VirtualFile* vfile, VirtualDir* vdir) {
|
||||
vfile->offset = tick_entry->offset;
|
||||
vfile->size = sizeof(Ticket);
|
||||
vfile->keyslot = 0xFF;
|
||||
vfile->flags = vdir->flags & ~VFLAG_DIR;
|
||||
vfile->flags = (vdir->flags | VFLAG_READONLY) & ~VFLAG_DIR;
|
||||
|
||||
return true; // found
|
||||
}
|
||||
@ -123,6 +123,7 @@ bool ReadVTickDbDir(VirtualFile* vfile, VirtualDir* vdir) {
|
||||
while (++vdir->index < n_templates) {
|
||||
// copy current template to vfile
|
||||
memcpy(vfile, templates + vdir->index, sizeof(VirtualFile));
|
||||
vfile->flags |= VFLAG_READONLY;
|
||||
return true; // found
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user