int AsyncFio::umount(const char *mountpoint) { int res; WaitSema(_ioSema); checkSync(); fileXioUmount(mountpoint); fileXioWaitAsync(FXIO_WAIT, &res); SignalSema(_ioSema); return res; }
/**************************************************************************** * Unmounts a hard disk partition. * ****************************************************************************/ int ClosePartition() { fileXioUmount("pfs0:"); return 0; }
/**************************************************************************** * Helper function. Not used anymore. * ****************************************************************************/ void closeShop(int handle) { fileXioClose(handle); fileXioUmount("pfs0:"); }
int hddGetFilesystemList(t_hddFilesystem hddFs[], int maxEntries) { iox_dirent_t dirEnt; int count = 0; u32 size = 0; int hddFd; int rv; if(!hddStatusCurrent) hddUpdateInfo(); hddFd = fileXioDopen("hdd0:"); if(hddFd < 0) return hddFd; rv = fileXioDread(hddFd, &dirEnt); while((rv > 0) && (count < maxEntries)) { int i; int partitionFd; u32 zoneFree, zoneSize; // We only want to know about main partitions (non-empty ones at that :P) if((dirEnt.stat.attr & ATTR_SUB_PARTITION) || (dirEnt.stat.mode == FS_TYPE_EMPTY)) { rv = fileXioDread(hddFd, &dirEnt); continue; } memset(&hddFs[count], 0, sizeof(t_hddFilesystem)); sprintf(hddFs[count].filename, "hdd0:%s", dirEnt.name); // Work out filesystem type if((dirEnt.name[0] == '_') && (dirEnt.name[1] == '_')) { hddFs[count].fileSystemGroup = FS_GROUP_SYSTEM; strcpy(hddFs[count].name, &dirEnt.name[2]); } else if(dirEnt.name[0] == FS_COMMON_PREFIX) { hddFs[count].fileSystemGroup = FS_GROUP_COMMON; strcpy(hddFs[count].name, &dirEnt.name[1]); } else { hddFs[count].fileSystemGroup = FS_GROUP_APPLICATION; strcpy(hddFs[count].name, dirEnt.name); } #ifdef _OMIT_SYSTEM_PARTITION if((hddFs[count].fileSystemGroup == FS_GROUP_SYSTEM) && strcmp(hddFs[count].name, "boot")) { rv = fileXioDread(hddFd, &dirEnt); continue; } #endif #ifdef DEBUG printf("> Filename: %s\n> Name: %s\n> Type: %d\n", hddFs[count].filename, hddFs[count].name, hddFs[count].fileSystemGroup); #endif // Calculate filesystem size partitionFd = fileXioOpen(hddFs[count].filename, O_RDONLY, 0); // If we failed to open the partition, then a password is probably set // (usually this means we have tried to access a game partition). We // dont want to return un-accessible game partitions in the filesystem list.. if(partitionFd < 0) { rv = fileXioDread(hddFd, &dirEnt); continue; } for(i = 0, size = 0; i < dirEnt.stat.private_0 + 1; i++) { rv = fileXioIoctl2(partitionFd, HDDIO_GETSIZE, &i, 4, NULL, 0); size += rv * 512 / 1024 / 1024; } fileXioClose(partitionFd); hddFs[count].size = size; // Get filesystem free space & format status hddFs[count].freeSpace = 0; hddFs[count].formatted = 0; if(dirEnt.stat.mode == FS_TYPE_PFS) { rv = fileXioMount("pfs0:", hddFs[count].filename, FIO_MT_RDONLY); if(rv == 0) { zoneFree = fileXioDevctl("pfs0:", PFSCTL_GET_ZONE_FREE, NULL, 0, NULL, 0); zoneSize = fileXioDevctl("pfs0:", PFSCTL_GET_ZONE_SIZE, NULL, 0, NULL, 0); hddFs[count].freeSpace = zoneFree * zoneSize / 1024 / 1024; hddFs[count].formatted = 1; fileXioUmount("pfs0:"); } } #ifdef DEBUG printf("> Formatted: %d\n> Size: %d\n> Free: %d\n", hddFs[count].formatted, (int)hddFs[count].size, (int)hddFs[count].freeSpace); #endif count++; rv = fileXioDread(hddFd, &dirEnt); } rv = fileXioDclose(hddFd); return count; }