コード例 #1
0
ファイル: namei.c プロジェクト: DCteam/lustre
/*
 * Expanded form of the path-walk routine, with the common arguments, builds
 * the nameidata bundle and calls path-walk.
 */
int
_sysio_namei(struct pnode *parent,
	     const char *path,
	     unsigned flags,
	     struct intent *intnt,
	     struct pnode **pnop)
{
	struct nameidata nameidata;
	int	err;

	ND_INIT(&nameidata, flags, STRIP_PREFIX(path), _sysio_root, intnt);
	err = _sysio_path_walk(parent, &nameidata);
	if (!err)
		*pnop = nameidata.nd_pno;
	return err;
}
コード例 #2
0
ファイル: error.c プロジェクト: markzh2015/aboutusb
void _usb_log_v(enum USB_LOG_LEVEL level,
                const char* app_name,
                const char* function,
                const char* format,
                va_list args)
{

    char local_buffer[LOGBUF_SIZE];
    int totalCount, count;
    const char* prefix;
    const char* func;
    char* buffer;
    int masked_level;
	int app_prefix_func_end;
#ifndef LOG_STYLE_SHORT
	const char** skip_list = NULL;
#endif

	masked_level = GetLogLevel(level);

    if (__usb_log_level < masked_level && masked_level != LOG_ERROR) return;
    buffer = local_buffer;
    totalCount = 0;
    count = 0;
    prefix = log_level_string[masked_level];
	func = function;
	app_prefix_func_end = 0;

    if (masked_level > LOG_LEVEL_MAX) masked_level = LOG_LEVEL_MAX;

    if ((level & LOG_RAW) == LOG_RAW)
    {
        count = _vsnprintf(buffer, LOGBUF_SIZE-1, format, args);
        if (count > 0)
        {
            buffer += count;
            totalCount += count;
        }
    }
    else
    {
#ifdef LOG_STYLE_SHORT
        if ((prefix) && strlen(prefix))
        {
		    count = _snprintf(buffer, (LOGBUF_SIZE-1), "%s: ",  prefix);
        }
        else
        {
		    count = 0;
        }
		func = "";
#else
		func = function;

		if (func)
		{
			// strip some prefixes to shorten function names
			skip_list=skipped_function_prefix;
			while(*skip_list && ((func)) && func[0])
			{
				func = STRIP_PREFIX(func,skip_list[0]);
				skip_list++;
			}
		}

		if(!func) func="none";

        // print app name, level string and short function name
        if ((prefix) && strlen(prefix))
        {
            count = _snprintf(buffer, (LOGBUF_SIZE-1), "%s:%s [%s] ", app_name, prefix, func);
        }
        else
        {
            count = _snprintf(buffer, (LOGBUF_SIZE-1), "%s:[%s] ", app_name, func);
        }
#endif

        if (count >= 0)
        {
			app_prefix_func_end = count;
            buffer += count;
            totalCount += count;
            count = _vsnprintf(buffer, (LOGBUF_SIZE-1) - totalCount, format, args);
            if (count > 0)
            {
                buffer += count;
                totalCount += count;
            }
        }
    }

	if (count < 0)
        totalCount = LOGBUF_SIZE - 1;

    // make sure its null terminated
    local_buffer[totalCount] = 0;

#if (!IS_DRIVER)
    if (masked_level == LOG_ERROR)
    {
        // if this is an error message then store it
        strncpy(usb_error_str, local_buffer, totalCount);
        usb_error_str[totalCount] = '\0';
        usb_error_type = USB_ERROR_TYPE_STRING;
    }
#endif

	if (user_log_hander)
	{
		if (user_log_hander(level, app_name, prefix, func, app_prefix_func_end, local_buffer, totalCount))
			return;
	}
	if (__usb_log_level >= masked_level)
	{
		usb_log_def_handler(level, app_name, prefix, func, app_prefix_func_end, local_buffer, totalCount);
	}
}