示例#1
0
文件: fs.hpp 项目: GamovCoder/theCore
fs::inode_ptr petit< Block >::mount()
{
    m_block.init();
    m_block.open();

    // Pass block device bindings
    // that will be used by internal fat routines
    m_fat.disk = {
        reinterpret_cast< void * >(&m_block),
        disk_initialize,
        disk_writep,
        disk_readp
    };

    // TODO: error check!
    auto res = pf_mount(&m_fat);
    if (res == FR_OK) {
        ecl::cout << "Mounted!" << ecl::endl;
    } else {
        ecl::cout << "Mount error: " << res << ecl::endl;
    }

    auto iptr = ecl::allocate_shared< dir_inode >(m_alloc, &m_fat, m_alloc);
    iptr->set_weak(iptr);

    // TODO;
    return iptr;
}
示例#2
0
static int
set(void)
{
	char *token = currtok();
	int has_parent = 0;

	errlog(BEGIN, "set() {");
	errlog(VERBOSE, "token = '%s'",
	    (token) ? token : "<NULL>");

	if (in_specials(*token)) {
		errlog(INPUT|ERROR, "unexpected token \"%s\" found. "
		    "Version name expected", token);
		Errors++;
		errlog(END, "} /* set */");
		return (FALSE);
	}

	errlog(VERBOSE, "Begin Version: %s", token);
	*Previous = '\0';
	if (Selected) {
		if (add_parent(token, Previous, 0) == FALSE) {
			errlog(INPUT | ERROR, "unable to add a parent version "
			    "from the set file");
			Errors++;
			errlog(END, "} /* set */");
			return (FALSE);
		}
	}

	add_valid_version(token);
	(void) strncpy(LeftMostChild, token, MAXLINE);
	LeftMostChild[MAXLINE-1] = '\0';
	(void) strncpy(Previous, token, MAXLINE);
	Previous[MAXLINE-1] = '\0';

	token = nexttok();

	switch (*token) {
		case ':':
			errlog(VERBOSE, "token ':' found");
			(void) accept_token(":");
			if (set_parents() == FALSE) {
				errlog(END, "} /* set */");
				return (FALSE);
			}
			if (accept_token(";") == FALSE) {
				errlog(END, "} /* set */");
				return (FALSE);
			}
			errlog(VERBOSE, "End Version");
			break;

		case ';':
			errlog(VERBOSE, "token ';' found");
			(void) accept_token(";");
			errlog(VERBOSE, "End version ':'");
			break;

		case '[':
			(void) accept_token("[");
			if (accept_token("WEAK") == FALSE) {
				errlog(END, "} /* set */");
				return (FALSE);
			}
			if (accept_token("]") == FALSE) {
				errlog(END, "} /* set */");
				return (FALSE);
			}
			token = currtok();
			if (eq(token, ":")) {
				(void) accept_token(":");
				has_parent = 1;
			} else if (eq(token, ";")) {
				(void) accept_token(";");
			} else {
				errlog(ERROR|INPUT,
				    "Unexpected token \"%s\" found. ':'"
				    "or ';' expected.", token);
				Errors++;
				errlog(END, "} /* set */");
				return (FALSE);
			}
			errlog(VERBOSE, "WEAK version detected\n");
			if (Selected)
				set_weak(LeftMostChild, TRUE);

			if (has_parent) {
				if (set_parents() == FALSE) {
					errlog(END, "} /* set */");
					return (FALSE);
				}
				if (accept_token(";") == FALSE) {
					errlog(END, "} /* set */");
					return (FALSE);
				}
			}
			errlog(VERBOSE, "End Version");
			break;
		default:
			/* CSTYLED */
			errlog(ERROR|INPUT,
			    "Unexpected token \"%s\" found. ';' expected.",
			    token);
			Errors++;
			errlog(END, "} /* set */");
			return (FALSE);
	}

	token = currtok();
	if (eq(token, "}")) {
		(void) accept_token("}");
		errlog(VERBOSE, "End architecture");
		errlog(END, "} /* set */");
		return (FALSE);
	}

	errlog(END, "} /* set */");
	return (TRUE);
}