22 #include "sys/fcntl.h"
29 #define NEWLIB_PORT_AWARE
33 #define PFS_ZONE_SIZE 8192
34 #define PFS_FRAGMENT_OPT 0x00002d66
35 #define PFS_FRAGMENT 0x00000000
37 #if (PFS_FRAGMENT != 0)
43 #define _OMIT_SYSTEM_PARTITION
84 if((rv >= 3) || (rv < 0))
98 if((rv >= 1) || (rv < 0))
108 const char *partitionList[] = {
123 for(i = 0; partitionList[i] !=
NULL; i++)
153 while((rv > 0) && (count < maxEntries))
157 u32 zoneFree, zoneSize;
167 snprintf(hddFs[count].filename, 40,
"hdd0:%.34s", dirEnt.
name);
170 if((dirEnt.
name[0] ==
'_') && (dirEnt.
name[1] ==
'_'))
173 strcpy(hddFs[count].name, &dirEnt.
name[2]);
178 strcpy(hddFs[count].name, &dirEnt.
name[1]);
183 strcpy(hddFs[count].name, dirEnt.
name);
186 #ifdef _OMIT_SYSTEM_PARTITION
195 printf(
"> Filename: %s\n> Name: %s\n> Type: %d\n", hddFs[count].filename, hddFs[count].name, hddFs[count].fileSystemGroup);
213 size += (
u32)rv / 2048;
218 hddFs[count].
size = size;
233 hddFs[count].
freeSpace = zoneFree * zoneSize / 1024 / 1024;
241 printf(
"> Formatted: %d\n> Size: %d\n> Free: %d\n", hddFs[count].formatted, (
int)hddFs[count].size, (
int)hddFs[count].freeSpace);
283 hddUsed += infoDirEnt.
stat.
size / 2048;
300 int fsSizeLeft = fsSizeMB;
302 char openString[256];
315 sprintf(fsName,
"__%s", name);
318 sprintf(fsName,
"+%s", name);
321 strcpy(fsName, name);
326 sprintf(openString,
"hdd0:%s", fsName);
328 if(partFd > 0 || partFd == -
EACCES)
335 for(maxIndex = 0; maxIndex < 9; maxIndex++)
340 for(useIndex = maxIndex;
sizesMB[useIndex] > fsSizeMB; useIndex--);
342 for(partSize =
sizesMB[useIndex]; useIndex >= 0; useIndex--,partSize =
sizesMB[useIndex])
345 printf(
">>> Attempting to create main partition, size %d MB\n", partSize);
348 sprintf(openString,
"hdd0:%s,,,%s,PFS", fsName,
sizesString[useIndex]);
350 printf(
">>> openString = %s\n", openString);
360 printf(
">>> Could not create Main Partition (error %d)!\n", partFd);
370 printf(
">>> Could not create Main Partition (no space)!\n");
375 fsSizeLeft -= partSize;
377 printf(
">>> Main partition of %d MB created!\n", partSize);
384 if(fsSizeLeft < partSize)
387 printf(
">>> Adjusting sub size: %d MB to ",
sizesMB[useIndex]);
389 for(useIndex = maxIndex;
sizesMB[useIndex] > fsSizeLeft; useIndex--);
393 printf(
"%d MB\n",
sizesMB[useIndex]);
399 printf(
">>> Attempting to create sub partition of size %d MB\n",
sizesMB[useIndex]);
413 printf(
">>> Out of sizes to try. Giving up.\n");
418 printf(
">>> Subpartition alloc FAILED! Trying with size of %d MB\n", partSize);
424 else if(retVal == -
EFBIG)
429 printf(
">>> Sub creation successfull!\n");
435 printf(
">>> Unknown error while creating sub: %d\n", retVal);
439 fsSizeLeft -=
sizesMB[useIndex];
444 sprintf(openString,
"hdd0:%s", fsName);
449 printf(
">>> Failed to format new partition: %d\n", retVal);
456 return fsSizeMB - fsSizeLeft;
478 int fsSizeLeft = extraMB;
489 for(maxIndex = 0; maxIndex < 9; maxIndex++)
494 for(useIndex = maxIndex;
sizesMB[useIndex] > extraMB; useIndex--);
506 if(fsSizeLeft < partSize)
509 printf(
">>> Adjusting sub size: %d MB to ",
sizesMB[useIndex]);
511 for(useIndex = maxIndex;
sizesMB[useIndex] > fsSizeLeft; useIndex--);
515 printf(
"%d MB\n",
sizesMB[useIndex]);
521 printf(
">>> Attempting to create sub partition of size %d MB\n",
sizesMB[useIndex]);
535 printf(
">>> Out of sizes to try. Giving up.\n");
540 printf(
">>> Subpartition alloc FAILED! Trying with size of %d MB\n", partSize);
546 else if(retVal == -
EFBIG)
551 printf(
">>> Sub creation successfull!\n");
557 printf(
">>> Unknown error while creating sub: %d\n", retVal);
561 fsSizeLeft -=
sizesMB[useIndex];
568 return extraMB - fsSizeLeft;
int fileXioDread(int fd, iox_dirent_t *dirent)
int fileXioDevctl(const char *name, int cmd, void *arg, unsigned int arglen, void *buf, unsigned int buflen)
int fileXioMount(const char *mountpoint, const char *blockdev, int flag)
int fileXioRemove(const char *pathname)
int fileXioDclose(int fd)
int fileXioDopen(const char *name)
int fileXioUmount(const char *mountpoint)
int fileXioIoctl2(int fd, int command, void *arg, unsigned int arglen, void *buf, unsigned int buflen)
int fileXioOpen(const char *source, int flags,...)
int fileXioFormat(const char *dev, const char *blockdev, const void *args, int arglen)
#define HDIOC_TOTALSECTOR
int hddExpandFilesystem(t_hddFilesystem *fs, int extraMB)
int hddRemoveFilesystem(t_hddFilesystem *fs)
static int pfsFormatArg[1]
static char * sizesString[9]
int hddGetFilesystemList(t_hddFilesystem hddFs[], int maxEntries)
int hddMakeFilesystem(int fsSizeMB, char *name, int type)
void hddGetInfo(t_hddInfo *info)
static int hddStatusCurrent
static void hddUpdateInfo()
static u32 hddMaxPartitionSize
#define ATTR_SUB_PARTITION
#define FS_GROUP_APPLICATION