Exemplo n.º 1
0
int main(int argc, char *argv[]) {
	int i = 0;
	FILE *outfile = NULL;

#ifdef LOCAL
	printf("W: using local mode!\n\n");
#endif

	system("modprobe floppy 1>/dev/null 2>&1");

	get_filesystems();
	get_swapspaces();
	get_fstab_d_dir();

	mkdir(FSTAB_DIR, 0755); /* may not yet exist */
	
	outfile = fopen(FSTAB_FILE, "w");
	if(outfile == NULL)
		return(0);

#ifdef DEBUG
	printf("---------------------------------\n");
#endif
	/* Not using FSTAB_FILE because it contain /target/ which will
	 * be confusing when read after the boot from HD. */
	fprintf(outfile, HEADER, "/etc/fstab");
	for(i=0; i<count_entries; i++) {
		int pass;

		if(!has_device(entries[i]))
			pass = 0;
		else {
			if(strcmp(entries[i]->mountpoint, "/cdrom") == 0
			   || strcmp(entries[i]->mountpoint, "/floppy") == 0
			   || strcmp(entries[i]->typ, "swap") == 0)
				pass = 0;
			else if(strcmp(entries[i]->mountpoint, "/") == 0)
				pass = 1;
			else
				pass = 2;

			mapdevfs(entries[i]);
		}
#ifdef DEBUG
		fprintf(stdout, "%s\t%s\t%s\t%s\t%d %d\n",
			entries[i]->filesystem, entries[i]->mountpoint,
			entries[i]->typ, entries[i]->options,
			0, pass);
#endif
		fprintf(outfile, "%s\t%s\t%s\t%s\t%d %d\n",
			entries[i]->filesystem, entries[i]->mountpoint,
			entries[i]->typ, entries[i]->options,
			0, pass);
	}

	fclose(outfile);

	return(EXIT_SUCCESS);
}
Exemplo n.º 2
0
/*
 * Always check @filesystems pointer!
 *
 * man mount:
 *
 * ...mount will try to read the file /etc/filesystems, or, if that does not
 * exist, /proc/filesystems. All of the filesystem  types  listed  there  will
 * be tried,  except  for  those  that  are  labeled  "nodev"  (e.g.,  devpts,
 * proc  and  nfs).  If /etc/filesystems ends in a line with a single * only,
 * mount will read /proc/filesystems after‐ wards.
 */
int mnt_get_filesystems(char ***filesystems, const char *pattern)
{
	int rc;

	if (!filesystems)
		return -EINVAL;

	*filesystems = NULL;

	rc = get_filesystems(_PATH_FILESYSTEMS, filesystems, pattern);
	if (rc != 1)
		return rc;

	rc = get_filesystems(_PATH_PROC_FILESYSTEMS, filesystems, pattern);
	if (rc == 1 && *filesystems)
		rc = 0;			/* not found /proc/filesystems */

	return rc;
}