8 #define MOUNTABLE_FILE "/Acess/Conf/Mountable"
9 #define MOUNTED_FILE "/Devices/System/VFS/Mounts"
13 int GetMountDefs(char *Ident, char **spDevice, char **spDir, char **spType, char **spOptions);
17 * \fn int main(int argc, char *argv[])
20 int main(int argc, char *argv[])
28 char *sOptions = NULL;
36 for( i = 1; i < argc; i++ )
44 // -t <driver> :: Filesystem driver to use
45 case 't': sType = argv[++i]; break;
47 //TODO: Long Arguments
71 // Check if we even got a device/mountpoint
77 // If no directory was passed (we want to use the mount list)
78 // or we are not root (we need to use the mount list)
79 // Check the mount list
80 if(sDir == NULL || getuid() != 0)
82 // Check if it is defined in the mounts file
83 // - At this point sDevice could be a device name or a mount point
84 if(GetMountDefs(sDevice, &sDevice, &sDir, &sType, &sOptions) == 0)
87 fprintf(stderr, "Unable to find '%s' in '%s'\n",
88 sDevice, MOUNTABLE_FILE
91 fprintf(stderr, "You must be root to mount devices or directories not in '%s'\n",
97 // We need to be root to mount a filesystem, so, let us be elevated!
98 setuid(0); // I hope I have the setuid bit implemented.
102 // Check that we were passed a filesystem type
104 fprintf(stderr, "Please pass a filesystem type\n");
110 fd = open(sDevice, OPENFLAG_READ);
112 printf("Device '%s' cannot be opened for reading\n", sDevice);
118 fd = open(sDir, OPENFLAG_EXEC);
120 printf("Directory '%s' does not exist\n", sDir);
125 // Replace sOptions with an empty string if it is still NULL
126 if(sOptions == NULL) sOptions = "";
129 _SysMount(sDevice, sDir, sType, sOptions);
134 void ShowUsage(char *ProgName)
136 fprintf(stderr, "Usage:\n", ProgName);
137 fprintf(stderr, " %s [-t <type>] <device> <directory>\n");
138 fprintf(stderr, "or %s <device>\n");
139 fprintf(stderr, "or %s <directory>\n");
143 * \fn int GetMountDefs(char *Ident, char **spDevice, char **spDir, char **spType, char **spOptions)
144 * \brief Reads the mountable definitions file and returns the corresponding entry
145 * \param spDevice Pointer to a string (pointer) determining the device (also is the input for this function)
148 int GetMountDefs(char *Ident, char **spDevice, char **spDir, char **spType, char **spOptions)
150 // TODO: Read the mounts file (after deciding what it will be)