#include <stdio.h>
#define MOUNTABLE_FILE "/Acess/Conf/Mountable"
-#define MOUNTED_FILE "/Acess/Conf/Mounted"
+#define MOUNTED_FILE "/Devices/System/VFS/Mounts"
// === PROTOTYPES ===
-void ShowUsage();
- int GetMountDefs(char **spDevice, char **spDir, char **spType, char **spOptions);
+void ShowUsage(char *ProgName);
+ int GetMountDefs(char *Ident, char **spDevice, char **spDir, char **spType, char **spOptions);
// === CODE ===
/**
char *sDir = NULL;
char *sOptions = NULL;
+ // List mounted filesystems
+ // - This is cheating, isn't it?
+ if(argc == 1) {
+ // Dump the contents of /Devices/system/VFS/Mounts
+ FILE *fp = fopen("/Devices/system/VFS/Mounts", "r");
+ char buf[1024];
+ int len;
+ while( (len = fread(buf, 1024, 1, fp)) )
+ fwrite(buf, len, 1, stdout);
+ printf("\n");
+ return 0;
+ }
+
if(argc < 3) {
- ShowUsage();
+ ShowUsage(argv[0]);
return EXIT_FAILURE;
}
{
switch(arg[1])
{
+ // -t <driver> :: Filesystem driver to use
case 't': sType = argv[++i]; break;
case '-':
//TODO: Long Arguments
continue;
}
+ // Device?
if(sDevice == NULL) {
sDevice = arg;
continue;
}
+ // Directory?
if(sDir == NULL) {
sDir = arg;
continue;
if(sDir == NULL || getuid() != 0)
{
// Check if it is defined in the mounts file
- if(GetMountDefs(&sDevice, &sDir, &sType, &sOptions) == 0)
+ // - At this point sDevice could be a device name or a mount point
+ if(GetMountDefs(sDevice, &sDevice, &sDir, &sType, &sOptions) == 0)
{
if(sDir == NULL)
fprintf(stderr, "Unable to find '%s' in '%s'\n",
void ShowUsage(char *ProgName)
{
- fprintf(stderr, "Usage:\n", ProgName);
- fprintf(stderr, " %s [-t <type>] <device> <directory>\n");
- fprintf(stderr, "or %s <device>\n");
- fprintf(stderr, "or %s <directory>\n");
+ fprintf(stderr, "Usage:\n");
+ fprintf(stderr, " %s [-t <type>] <device> <directory>\n", ProgName);
+ fprintf(stderr, "or %s <device>\n", ProgName);
+ fprintf(stderr, "or %s <directory>\n", ProgName);
+ fprintf(stderr, "or %s\n", ProgName);
}
/**
- * \fn int GetMountDefs(char **spDevice, char **spDir, char **spType, char **spOptions)
+ * \fn int GetMountDefs(char *Ident, char **spDevice, char **spDir, char **spType, char **spOptions)
* \brief Reads the mountable definitions file and returns the corresponding entry
* \param spDevice Pointer to a string (pointer) determining the device (also is the input for this function)
* \note STUB
*/
-int GetMountDefs(char **spDevice, char **spDir, char **spType, char **spOptions)
+int GetMountDefs(char *Ident, char **spDevice, char **spDir, char **spType, char **spOptions)
{
// TODO: Read the mounts file (after deciding what it will be)
return 0;