8 #define MOUNTABLE_FILE "/Acess/Conf/Mountable"
9 #define MOUNTED_FILE "/Acess/Conf/Mounted"
13 int GetMountDefs(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 case 't': sType = argv[++i]; break;
46 //TODO: Long Arguments
68 // Check if we even got a device/mountpoint
74 // If no directory was passed (we want to use the mount list)
75 // or we are not root (we need to use the mount list)
76 // Check the mount list
77 if(sDir == NULL || getuid() != 0)
79 // Check if it is defined in the mounts file
80 if(GetMountDefs(&sDevice, &sDir, &sType, &sOptions) == 0)
83 fprintf(stderr, "Unable to find '%s' in '%s'\n",
84 sDevice, MOUNTABLE_FILE
87 fprintf(stderr, "You must be root to mount devices or directories not in '%s'\n",
93 // We need to be root to mount a filesystem, so, let us be elevated!
94 setuid(0); // I hope I have the setuid bit implemented.
98 // Check that we were passed a filesystem type
100 fprintf(stderr, "Please pass a filesystem type\n");
106 fd = open(sDevice, OPENFLAG_READ);
108 printf("Device '%s' cannot be opened for reading\n", sDevice);
114 fd = open(sDir, OPENFLAG_EXEC);
116 printf("Directory '%s' does not exist\n", sDir);
121 // Replace sOptions with an empty string if it is still NULL
122 if(sOptions == NULL) sOptions = "";
125 _SysMount(sDevice, sDir, sType, sOptions);
130 void ShowUsage(char *ProgName)
132 fprintf(stderr, "Usage:\n", ProgName);
133 fprintf(stderr, " %s [-t <type>] <device> <directory>\n");
134 fprintf(stderr, "or %s <device>\n");
135 fprintf(stderr, "or %s <directory>\n");
139 * \fn int GetMountDefs(char **spDevice, char **spDir, char **spType, char **spOptions)
140 * \brief Reads the mountable definitions file and returns the corresponding entry
141 * \param spDevice Pointer to a string (pointer) determining the device (also is the input for this function)
144 int GetMountDefs(char **spDevice, char **spDir, char **spType, char **spOptions)
146 // TODO: Read the mounts file (after deciding what it will be)