Exemple #1
0
int stat(const char *path, struct stat *sb)
{
	struct DIRENTRY dir_e;
	
	if(firstfile((char*)path, &dir_e) == NULL)
		return -1;
	
	sb->st_size = dir_e.size;
	
	if(strncmp(path, "cdrom:", 6) == 0)
		sb->st_blksize = 2048;
	else if(strncmp(path, "bu00:", 5) == 0 ||
		    strncmp(path, "bu10:", 5) == 0)
		sb->st_blksize = 128;
	else
// not a real blocksize, will be there just as a placeholder
		sb->st_blksize = 1024; 
	
	sb->st_blocks = 
		sb->st_size / sb->st_blksize; 
	
	if(sb->st_size % sb->st_blksize)
		sb->st_blocks++;
	
	return 0;
}
Exemple #2
0
static struct cbfile *findfile(const char *filename)
{
	struct cbfile *f;
	for (f = firstfile(); f; f = nextfile(f)) {
		if (strcmp(filename, f->filename) == 0)
			return f;
	}
	return NULL;
}
Exemple #3
0
static int cbfs_module_init(void)
{
	struct cbfile *f;
	int index = 0;

	header = *(void **)HEADER_ADDR;
	if (header->magic != ntohl(HEADER_MAGIC)) {
		header = NULL;
		return 0;
	}

	for (f = firstfile(); f; f = nextfile(f))
		filecount++;

	filenames = malloc(filecount * sizeof(char *));
	if (filenames == NULL)
		return 0;

	for (f = firstfile(); f; f = nextfile(f))
		filenames[index++] = strdup((const char *)f->filename);

	return 0;
}
Exemple #4
0
/* in  : cnct	コネクタ No.(0 or 1)
	 slot	スロット No.(通常 0、マルチタップ 0〜3)
   out : 0〜15	使用ファイル数
*/
int GetCardEntry(int cnct, int slot)
{
	long i = 0;
	char key[32];
	struct DIRENTRY *d;

	sprintf(key, "bu%1d%1d:*", cnct, slot);	/* cnct:コネクタ番号 */
						/* slot:スロット番号 */
	d = SLOT_DIR;
	if(firstfile(key, d) == d)	/* d:バッファポインタ */
	{
		do {
			i++;
			d++;
		} while(nextfile(d) == d);
	}

	return i;			/* 使用ファイル数 */
}
Exemple #5
0
int
main(int argc, char *argv[])
{
	char *p;
	const char *last_component;
	char *outfile = NULL;
	int pflag, ch, eflag, uflag, fflag;

	pflag = eflag = uflag = fflag = 0;
	while ((ch = getopt(argc, argv, "egpfb:s:o:u")) != -1) {
		switch (ch) {

		case 'o':
			outfile = optarg;
			break;
		case 'u':
			uflag = 1;
			break;
		case 'f':
			fflag = 1;
			break;

		case 'e':
			eflag = 1;
			if (!isatty(STDIN_FILENO))
				verbose = 1;
			break;

		case 'g':
			/*
			 * In addition to DEBUG, you probably wanted to
			 * set "options KGDB" and maybe others.  We could
			 * do that for you, but you really should just
			 * put them in the config file.
			 */
			(void)fputs(
			    "-g is obsolete (use makeoptions DEBUG=\"-g\")\n",
			    stderr);
			usage();

		case 'p':
			/*
			 * Essentially the same as makeoptions PROF="-pg",
			 * but also changes the path from ../../compile/FOO
			 * to ../../compile/FOO.PROF; i.e., compile a
			 * profiling kernel based on a typical "regular"
			 * kernel.
			 *
			 * Note that if you always want profiling, you
			 * can (and should) use a "makeoptions" line.
			 */
			pflag = 1;
			break;

		case 'b':
			builddir = optarg;
			break;

		case 's':
			srcdir = optarg;
			break;

		default:
			usage();
		}
	}

	argc -= optind;
	argv += optind;
	if (argc > 1 || (eflag && argv[0] == NULL))
		usage();

	if (eflag) {
#ifdef MAKE_BOOTSTRAP
		fprintf(stderr, "config: UKC not available in this binary\n");
		exit(1);
#else
		return (ukc(argv[0], outfile, uflag, fflag));
#endif
	}

	conffile = (argc == 1) ? argv[0] : "CONFIG";
	if (firstfile(conffile)) {
		(void)fprintf(stderr, "config: cannot read %s: %s\n",
		    conffile, strerror(errno));
		exit(2);
	}

	/*
	 * Init variables.
	 */
	minmaxusers = 1;
	maxmaxusers = 10000;
	initintern();
	initfiles();
	initsem();
	devbasetab = ht_new();
	devatab = ht_new();
	selecttab = ht_new();
	needcnttab = ht_new();
	opttab = ht_new();
	mkopttab = ht_new();
	defopttab = ht_new();
	nextopt = &options;
	nextmkopt = &mkoptions;
	nextdefopt = &defoptions;

	/*
	 * Handle profiling (must do this before we try to create any
	 * files).
	 */
	last_component = strrchr(conffile, '/');
	last_component = (last_component) ? last_component + 1 : conffile;
	if (pflag) {
		int len = strlen(last_component) + 17;
		p = emalloc(len);
		(void)snprintf(p, len, "../compile/%s.PROF", last_component);
		(void)addmkoption(intern("PROF"), "-pg");
		(void)addoption(intern("GPROF"), NULL);
	} else {
		int len = strlen(last_component) + 12;
		p = emalloc(len);
		(void)snprintf(p, len, "../compile/%s", last_component);
	}
	defbuilddir = (argc == 0) ? "." : p;

	/*
	 * Parse config file (including machine definitions).
	 */
	if (yyparse())
		stop();

	/*
	 * Fix (as in `set firmly in place') files.
	 */
	if (fixfiles())
		stop();

	/*
	 * Fix objects and libraries.
	 */
	if (fixobjects())
		stop();

	/*
	 * Perform cross-checking.
	 */
	if (maxusers == 0) {
		if (defmaxusers) {
			(void)printf("maxusers not specified; %d assumed\n",
			    defmaxusers);
			maxusers = defmaxusers;
		} else {
			(void)fprintf(stderr,
			    "config: need \"maxusers\" line\n");
			errors++;
		}
	}
	if (crosscheck() || errors)
		stop();

	/*
	 * Squeeze things down and finish cross-checks (STAR checks must
	 * run after packing).
	 */
	pack();
	if (badstar())
		stop();

	/*
	 * Ready to go.  Build all the various files.
	 */
	if (mksymlinks() || mkmakefile() || mkheaders() || mkswap() ||
	    mkioconf())
		stop();
	optiondelta();
	exit(0);
}