• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ LOG_BUF函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中LOG_BUF函数的典型用法代码示例。如果您正苦于以下问题:C++ LOG_BUF函数的具体用法?C++ LOG_BUF怎么用?C++ LOG_BUF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了LOG_BUF函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: __call_console_drivers

/*
 * Call the console drivers on a range of log_buf
 */
static void __call_console_drivers(unsigned start, unsigned end)
{
	struct console *con;

	for_each_console(con) {
		if (exclusive_console && con != exclusive_console)
			continue;
		if ((con->flags & CON_ENABLED) && con->write &&
				(cpu_online(smp_processor_id()) ||
				(con->flags & CON_ANYTIME)))
			con->write(con, &LOG_BUF(start), end - start);
	}
}
开发者ID:AmesianX,项目名称:telechips-linux,代码行数:16,代码来源:printk.c


示例2: emit_log_char

static void emit_log_char(char c)
{
	LOG_BUF(log_end) = c;
	log_end++;
	if (log_end - log_start > log_buf_len)
		log_start = log_end - log_buf_len;
	if (log_end - con_start > log_buf_len)
		con_start = log_end - log_buf_len;
	if (logged_chars < log_buf_len)
		logged_chars++;

	emit_sec_log_char(c);
}
开发者ID:morristech,项目名称:exyroid-sgs2-gb,代码行数:13,代码来源:printk.c


示例3: emit_log_char

static void emit_log_char(char c)
{
	LOG_BUF(log_end) = c;
	log_end++;
	if (log_end - log_start > log_buf_len)
		log_start = log_end - log_buf_len;
	if (log_end - con_start > log_buf_len)
		con_start = log_end - log_buf_len;
	if (logged_chars < log_buf_len)
		logged_chars++;
#ifdef CONFIG_DUMP_PREV_OOPS_MSG
        copy_char_to_oopsbuf(c);
#endif
}
开发者ID:Antares84,项目名称:asuswrt-merlin,代码行数:14,代码来源:printk.c


示例4: BufferData

PureOmxBufferData::PureOmxBufferData(const PureOmxPlatformLayer& aPlatformLayer,
                                     const OMX_PARAM_PORTDEFINITIONTYPE& aPortDef)
  : BufferData(nullptr)
  , mPlatformLayer(aPlatformLayer)
  , mPortDef(aPortDef)
{
  LOG_BUF("");

  if (ShouldUseEGLImage()) {
    // TODO
    LOG_BUF("OMX_UseEGLImage() seems available but using it isn't implemented yet.");
  }

  OMX_ERRORTYPE err;
  err = OMX_AllocateBuffer(mPlatformLayer.GetComponent(),
                           &mBuffer,
                           mPortDef.nPortIndex,
                           this,
                           mPortDef.nBufferSize);
  if (err != OMX_ErrorNone) {
    LOG_BUF("Failed to allocate the buffer!: 0x%08x", err);
  }
}
开发者ID:staktrace,项目名称:gecko-dev,代码行数:23,代码来源:PureOmxPlatformLayer.cpp


示例5: emit_log_char

static void emit_log_char(char c)
{
	LOG_BUF(log_end) = c;
#ifdef CONFIG_HAS_EARLYSUSPEND
	if(suspend_process_going)
	 IRAM_LOG_BUF(log_end) = c;
#endif
	log_end++;
	if (log_end - log_start > log_buf_len)
		log_start = log_end - log_buf_len;
	if (log_end - con_start > log_buf_len)
		con_start = log_end - log_buf_len;
	if (logged_chars < log_buf_len)
		logged_chars++;
}
开发者ID:m4ttyw,项目名称:linux_kernel_TF101,代码行数:15,代码来源:printk.c


示例6: writeChunkOnLogBlockDuringGC

UINT8 writeChunkOnLogBlockDuringGC(const UINT32 dataLpn, const UINT32 dataChunkOffset, const UINT32 chunkOffsetInBuf, const UINT32 bufAddr)
{
    /* Need this function because during GC can't use the global variables, because those might be related to an outstanding write (which triggered the GC) */
    UINT32 bank = chooseNewBank();
    uart_print("writeChunkOnLogBlockDuringGC, bank="); uart_print_int(bank); uart_print(" dataLpn="); uart_print_int(dataLpn);
    uart_print(", dataChunkOffset="); uart_print_int(dataChunkOffset); uart_print("\r\n");
    int sectOffset = dataChunkOffset * SECTORS_PER_CHUNK;
    UINT32 src = bufAddr + (chunkOffsetInBuf * BYTES_PER_CHUNK);
    UINT32 dst = LOG_BUF(bank) + (chunkPtr[bank] * BYTES_PER_CHUNK); // base address of the destination chunk
    waitBusyBank(bank);
    mem_copy(dst, src, BYTES_PER_CHUNK);
    updateDramBufMetadataDuringGc(bank, dataLpn, sectOffset);
    updateChunkPtrDuringGC(bank);
    return 0;
}
开发者ID:zdvresearch,项目名称:msst2015-ftl,代码行数:15,代码来源:write.c


示例7: writePartialChunkWhenOldIsInOWBuf

static void writePartialChunkWhenOldIsInOWBuf(UINT32 nSectsToWrite, UINT32 oldChunkAddr)
{
    uart_print("writePartialChunkWhenOldIsInOWBuf\r\n");
    // Old Chunk Location
    UINT32 oldBank = ChunkToBank(oldChunkAddr);
    UINT32 oldSectOffset = ChunkToSectOffset(oldChunkAddr);
    // Buffers
    UINT32 dstWBufStart = LOG_BUF(bank_) + (chunkPtr[bank_] * BYTES_PER_CHUNK); // base address of the destination chunk
    UINT32 srcOWBufStart = OW_LOG_BUF(oldBank)+(oldSectOffset*BYTES_PER_SECTOR); // location of old chunk
    // Sizes
    waitBusyBank(bank_);
    mem_copy(dstWBufStart, srcOWBufStart, BYTES_PER_CHUNK);                                                         // First copy old data from OW Buf
    UINT32 startOffsetWrite = (sectOffset_ % SECTORS_PER_CHUNK) * BYTES_PER_SECTOR;
    UINT32 srcSataBufStart = WR_BUF_PTR(g_ftl_write_buf_id)+((sectOffset_ / SECTORS_PER_CHUNK)*BYTES_PER_CHUNK);
    mem_copy(dstWBufStart+startOffsetWrite, srcSataBufStart+startOffsetWrite, nSectsToWrite*BYTES_PER_SECTOR);      // Then copy new data from SATA Buf
}
开发者ID:zdvresearch,项目名称:msst2015-ftl,代码行数:16,代码来源:write.c


示例8: writePartialChunkWhenOldIsInWBuf

static void writePartialChunkWhenOldIsInWBuf(UINT32 nSectsToWrite, UINT32 oldChunkAddr) {
    uart_print("writePartialChunkWhenOldIsInWBuf\r\n");
    // Old Chunk Location
    UINT32 oldBank = ChunkToBank(oldChunkAddr);
    UINT32 oldSectOffset = ChunkToSectOffset(oldChunkAddr);
    // Buffers
    UINT32 dstWBufStart = LOG_BUF(oldBank)+(oldSectOffset*BYTES_PER_SECTOR); // location of old chunk
    UINT32 srcSataBufStart = WR_BUF_PTR(g_ftl_write_buf_id)+((sectOffset_ / SECTORS_PER_CHUNK)*BYTES_PER_CHUNK);
    // Sizes
    UINT32 startOffsetWrite = (sectOffset_ % SECTORS_PER_CHUNK) * BYTES_PER_SECTOR;
    //waitBusyBank(bank_);
    waitBusyBank(oldBank);
    mem_copy(dstWBufStart+startOffsetWrite, srcSataBufStart+startOffsetWrite, nSectsToWrite*BYTES_PER_SECTOR);
    #if MeasureDramAbsorb
    uart_print_level_1("WRDRAM "); uart_print_level_1_int(nSectsToWrite); uart_print_level_1("\r\n");
    #endif
}
开发者ID:zdvresearch,项目名称:msst2015-ftl,代码行数:17,代码来源:write.c


示例9: emit_log_char

static void emit_log_char(char c,int prt_to_con)
{
	LOG_BUF(log_end) = c;
	log_end++;
	if (log_end - log_start > log_buf_len)
		log_start = log_end - log_buf_len;
	if (log_end - con_start > log_buf_len)
		con_start = log_end - log_buf_len;
	if (logged_chars < log_buf_len)
		logged_chars++;

#if defined(CONFIG_PRINTK) || defined(CONFIG_PANIC_PRINTK)
	if (prt_to_con) {
		PRT_BUF(prt_end) = c;
		prt_end++;
		if (prt_end - prt_start > __LOG_BUF_LEN)
			prt_start = prt_end - __LOG_BUF_LEN;
	}
#endif
}
开发者ID:cmotc,项目名称:openwrt-realtek,代码行数:20,代码来源:printk_log.c


示例10: call_console_drivers

/*
 * Call the console drivers, asking them to write out
 * log_buf[start] to log_buf[end - 1].
 * The console_sem must be held.
 */
static void call_console_drivers(unsigned long start, unsigned long end)
{
	unsigned long cur_index, start_print;
	static int msg_level = -1;

	if (((long)(start - end)) > 0)
		BUG();

	cur_index = start;
	start_print = start;
	while (cur_index != end) {
		if (	msg_level < 0 &&
			((end - cur_index) > 2) &&
			LOG_BUF(cur_index + 0) == '<' &&
			LOG_BUF(cur_index + 1) >= '0' &&
			LOG_BUF(cur_index + 1) <= '7' &&
			LOG_BUF(cur_index + 2) == '>')
		{
			msg_level = LOG_BUF(cur_index + 1) - '0';
			cur_index += 3;
			start_print = cur_index;
		}
		while (cur_index != end) {
			char c = LOG_BUF(cur_index);
			cur_index++;

			if (c == '\n') {
				if (msg_level < 0) {
					/*
					 * printk() has already given us loglevel tags in
					 * the buffer.  This code is here in case the
					 * log buffer has wrapped right round and scribbled
					 * on those tags
					 */
					msg_level = default_message_loglevel;
				}
				_call_console_drivers(start_print, cur_index, msg_level);
				msg_level = -1;
				start_print = cur_index;
				break;
			}
		}
	}
	_call_console_drivers(start_print, end, msg_level);
}
开发者ID:Dronevery,项目名称:JetsonTK1-kernel,代码行数:50,代码来源:printk.c


示例11: overwriteChunkOldInWBuf

static void overwriteChunkOldInWBuf(UINT32 chunkAddr) {
    //uart_print_level_1("23 ");
    /* Question: is it better to copy the ow buf or to overwrite in place in w buf?
      * Current implementation: copy to the ow buf, because probably will be overwritten again in the future.
      */
    uart_print("overwriteChunkOldInWBuf\r\n");
    chooseNewBank_();
    UINT32 nSectsToWrite = (((sectOffset_ % SECTORS_PER_CHUNK) + remainingSects_) < SECTORS_PER_CHUNK) ?     remainingSects_ :
                                                            (SECTORS_PER_CHUNK - (sectOffset_ % SECTORS_PER_CHUNK));
    UINT32 srcBank = ChunkToBank(chunkAddr);
    UINT32 srcChunkIdx = ChunkToChunkOffset(chunkAddr);
    UINT32 startOffsetOverwrite = (sectOffset_ % SECTORS_PER_CHUNK) * BYTES_PER_SECTOR;
    UINT32 endOffsetOverwrite =  ((sectOffset_ % SECTORS_PER_CHUNK)  + nSectsToWrite) * BYTES_PER_SECTOR;
    UINT32 wBufAddr = LOG_BUF(srcBank) + srcChunkIdx*BYTES_PER_CHUNK;
    UINT32 owBufAddr = OW_LOG_BUF(bank_) + owChunkPtr[bank_] * BYTES_PER_CHUNK;
    UINT32 sataBufAddr = WR_BUF_PTR(g_ftl_write_buf_id)+(sectOffset_*BYTES_PER_SECTOR);
    UINT32 leftHoleSize = startOffsetOverwrite;
    UINT32 rightHoleSize =  BYTES_PER_CHUNK - endOffsetOverwrite;
    waitBusyBank(bank_); // (Fabio) probably should wait. In contrast to overwriteChunkOldInOwBuf, here we are writing to a new chunk in ow buf, thus it might be that a previous operation involving ow buf is in flight
    mem_copy(owBufAddr + leftHoleSize, sataBufAddr, nSectsToWrite*BYTES_PER_SECTOR);
    if(leftHoleSize > 0) {
        uart_print("copy left hole\r\n");
        mem_copy(owBufAddr, wBufAddr, leftHoleSize); // copy left hole
    }
    if(rightHoleSize > 0) {
        uart_print("copy right hole\r\n");
        mem_copy(owBufAddr+endOffsetOverwrite, wBufAddr+endOffsetOverwrite, rightHoleSize); // copy right hole
    }
    logBufMeta[srcBank].dataLpn[srcChunkIdx]=INVALID; // invalidate in w buf
    updateOwDramBufMetadata();
    updateOwChunkPtr();
    sectOffset_ += nSectsToWrite;
    remainingSects_ -= nSectsToWrite;
    #if MeasureDramAbsorb
    uart_print_level_1("OWDRAM "); uart_print_level_1_int(nSectsToWrite); uart_print_level_1("\r\n");
    #endif
}
开发者ID:zdvresearch,项目名称:msst2015-ftl,代码行数:37,代码来源:overwrite.c


示例12: dev_read_kmsg

int dev_read_kmsg(char __user *buf, int len)
{
	int error = -EINVAL;
	unsigned i;
	char c;

	if (!buf || len < 0)
		goto out;
	error = 0;
	if (!len)
		goto out;
	if (!access_ok(VERIFY_WRITE, buf, len)) {
		error = -EFAULT;
		goto out;
	}
	error = wait_event_interruptible(dev_wait,
						(dev_start - log_end));
	if (error)
		goto out;
	i = 0;
	raw_spin_lock_irq(&logbuf_lock);
	while (!error && (dev_start != log_end) && i < len) {
		c = LOG_BUF(dev_start);
		dev_start++;
		raw_spin_unlock_irq(&logbuf_lock);
		error = __put_user(c,buf);
		buf++;
		i++;
		cond_resched();
		raw_spin_lock_irq(&logbuf_lock);
	}
	raw_spin_unlock_irq(&logbuf_lock);
	if (!error)
		error = i;
out:
	return error;
}
开发者ID:xdatravelbug,项目名称:N909D_Kernel_JB_4.1.2,代码行数:37,代码来源:printk.c


示例13: do_syslog

int do_syslog(int type, char __user *buf, int len, bool from_file)
{
	unsigned i, j, limit, count;
	int do_clear = 0;
	char c;
	int error;

	error = check_syslog_permissions(type, from_file);
	if (error)
		goto out;

	error = security_syslog(type);
	if (error)
		return error;

	switch (type) {
	case SYSLOG_ACTION_CLOSE:	
		break;
	case SYSLOG_ACTION_OPEN:	
		break;
	case SYSLOG_ACTION_READ:	
		error = -EINVAL;
		if (!buf || len < 0)
			goto out;
		error = 0;
		if (!len)
			goto out;
		if (!access_ok(VERIFY_WRITE, buf, len)) {
			error = -EFAULT;
			goto out;
		}
		error = wait_event_interruptible(log_wait,
							(log_start - log_end));
		if (error)
			goto out;
		i = 0;
		raw_spin_lock_irq(&logbuf_lock);
		while (!error && (log_start != log_end) && i < len) {
			c = LOG_BUF(log_start);
			log_start++;
			raw_spin_unlock_irq(&logbuf_lock);
			error = __put_user(c,buf);
			buf++;
			i++;
			cond_resched();
			raw_spin_lock_irq(&logbuf_lock);
		}
		raw_spin_unlock_irq(&logbuf_lock);
		if (!error)
			error = i;
		break;
	
	case SYSLOG_ACTION_READ_CLEAR:
		do_clear = 1;
		
	
	case SYSLOG_ACTION_READ_ALL:
		error = -EINVAL;
		if (!buf || len < 0)
			goto out;
		error = 0;
		if (!len)
			goto out;
		if (!access_ok(VERIFY_WRITE, buf, len)) {
			error = -EFAULT;
			goto out;
		}
		count = len;
		if (count > log_buf_len)
			count = log_buf_len;
		raw_spin_lock_irq(&logbuf_lock);
		if (count > logged_chars)
			count = logged_chars;
		if (do_clear)
			logged_chars = 0;
		limit = log_end;
		for (i = 0; i < count && !error; i++) {
			j = limit-1-i;
			if (j + log_buf_len < log_end)
				break;
			c = LOG_BUF(j);
			raw_spin_unlock_irq(&logbuf_lock);
			error = __put_user(c,&buf[count-1-i]);
			cond_resched();
			raw_spin_lock_irq(&logbuf_lock);
		}
		raw_spin_unlock_irq(&logbuf_lock);
		if (error)
			break;
		error = i;
		if (i != count) {
			int offset = count-error;
			
			for (i = 0; i < error; i++) {
				if (__get_user(c,&buf[i+offset]) ||
				    __put_user(c,&buf[i])) {
					error = -EFAULT;
					break;
				}
				cond_resched();
//.........这里部分代码省略.........
开发者ID:JmzTaylor,项目名称:Evita-Jellybean,代码行数:101,代码来源:printk.c


示例14: do_syslog

/*
 * Commands to do_syslog:
 *
 * 	0 -- Close the log.  Currently a NOP.
 * 	1 -- Open the log. Currently a NOP.
 * 	2 -- Read from the log.
 * 	3 -- Read all messages remaining in the ring buffer.
 * 	4 -- Read and clear all messages remaining in the ring buffer
 * 	5 -- Clear ring buffer.
 * 	6 -- Disable printk's to console
 * 	7 -- Enable printk's to console
 *	8 -- Set level of messages printed to console
 *	9 -- Return number of unread characters in the log buffer
 */
int do_syslog(int type, char * buf, int len)
{
	unsigned long i, j, limit, count;
	int do_clear = 0;
	char c;
	int error = 0;

	switch (type) {
	case 0:		/* Close log */
		break;
	case 1:		/* Open log */
		break;
	case 2:		/* Read from log */
		error = -EINVAL;
		if (!buf || len < 0)
			goto out;
		error = 0;
		if (!len)
			goto out;
		error = verify_area(VERIFY_WRITE,buf,len);
		if (error)
			goto out;
		error = wait_event_interruptible(log_wait, (log_start - log_end));
		if (error)
			goto out;
		i = 0;
		spin_lock_irq(&logbuf_lock);
		while ((log_start != log_end) && i < len) {
			c = LOG_BUF(log_start);
			log_start++;
			spin_unlock_irq(&logbuf_lock);
			__put_user(c,buf);
			buf++;
			i++;
			spin_lock_irq(&logbuf_lock);
		}
		spin_unlock_irq(&logbuf_lock);
		error = i;
		break;
	case 4:		/* Read/clear last kernel messages */
		do_clear = 1; 
		/* FALL THRU */
	case 3:		/* Read last kernel messages */
		error = -EINVAL;
		if (!buf || len < 0)
			goto out;
		error = 0;
		if (!len)
			goto out;
		error = verify_area(VERIFY_WRITE,buf,len);
		if (error)
			goto out;
		count = len;
		if (count > LOG_BUF_LEN)
			count = LOG_BUF_LEN;
		spin_lock_irq(&logbuf_lock);
		if (count > logged_chars)
			count = logged_chars;
		if (do_clear)
			logged_chars = 0;
		limit = log_end;
		/*
		 * __put_user() could sleep, and while we sleep
		 * printk() could overwrite the messages 
		 * we try to copy to user space. Therefore
		 * the messages are copied in reverse. <manfreds>
		 */
		for(i=0;i < count;i++) {
			j = limit-1-i;
			if (j+LOG_BUF_LEN < log_end)
				break;
			c = LOG_BUF(j);
			spin_unlock_irq(&logbuf_lock);
			__put_user(c,&buf[count-1-i]);
			spin_lock_irq(&logbuf_lock);
		}
		spin_unlock_irq(&logbuf_lock);
		error = i;
		if(i != count) {
			int offset = count-error;
			/* buffer overflow during copy, correct user buffer. */
			for(i=0;i<error;i++) {
				__get_user(c,&buf[i+offset]);
				__put_user(c,&buf[i]);
			}
		}
//.........这里部分代码省略.........
开发者ID:cmjonze,项目名称:evlog_cvs,代码行数:101,代码来源:printk.c


示例15: LOG_BUF

PureOmxBufferData::~PureOmxBufferData()
{
  LOG_BUF("");
  ReleaseBuffer();
}
开发者ID:staktrace,项目名称:gecko-dev,代码行数:5,代码来源:PureOmxPlatformLayer.cpp


示例16: md32_aee_dump

int md32_aee_dump(char *buf)
{
    volatile unsigned int *reg;
    char *ptr = buf;

    ssize_t i, len;
    unsigned int log_start_idx;
    unsigned int log_end_idx;
    unsigned int log_buf_max_len;
    unsigned char *__log_buf = (unsigned char *)(MD32_DTCM + md32_log_buf_addr);

    if(!buf)
        return 0;

    printk("md32_aee_dump\n");
    ptr += sprintf(ptr, "md32 status = 0x%08x\n", md32_aee_status.status);
    ptr += sprintf(ptr, "md32 pc=0x%08x, r14=0x%08x, r15=0x%08x\n", md32_aee_status.pc, md32_aee_status.r14, md32_aee_status.r15);
    ptr += sprintf(ptr, "md32 to host irq = 0x%08x\n", md32_aee_status.m2h_irq);
    ptr += sprintf(ptr, "host to md32 irq = 0x%08x\n", HOST_TO_MD32_REG);

    ptr += sprintf(ptr, "wdt en=%d, count=0x%08x\n",
           (MD32_WDT_REG & 0x10000000) ? 1 : 0,
           (MD32_WDT_REG & 0xFFFFF));

    /*dump all md32 regs*/
    for(reg = (volatile unsigned int *)MD32_BASE;
        reg < (MD32_BASE + 0xA8); reg++)
    {
        //if(!(reg & 0xF))
        {
            ptr += sprintf(ptr, "\n");
            ptr += sprintf(ptr, "[0x%p]   ", reg);
        }

        ptr += sprintf(ptr, "0x%08x  ", *reg);

    }
    ptr += sprintf(ptr, "\n");

#define LOG_BUF_MASK (log_buf_max_len-1)
#define LOG_BUF(idx) (__log_buf[(idx) & LOG_BUF_MASK])

    log_start_idx = readl((void __iomem *)(MD32_DTCM + md32_log_start_idx_addr));
    log_end_idx = readl((void __iomem *)(MD32_DTCM + md32_log_end_idx_addr));
    log_buf_max_len = readl((void __iomem *)(MD32_DTCM + md32_log_buf_len_addr));

    ptr += sprintf(ptr, "log_buf_addr = 0x%08x\n", (unsigned int)md32_log_buf_addr);
    ptr += sprintf(ptr, "log_start_idx = %u\n", log_start_idx);
    ptr += sprintf(ptr, "log_end_idx = %u\n", log_end_idx);
    ptr += sprintf(ptr, "log_buf_max_len = %u\n", log_buf_max_len);

    ptr += sprintf(ptr, "<<md32 log buf start>>\n");
    len = (log_buf_max_len > 0x1000) ? 0x1000 : log_buf_max_len;
    i = 0;
    while((log_start_idx != log_end_idx) && i < len)
    {
        ptr += sprintf(ptr, "%c", LOG_BUF(log_start_idx));
        log_start_idx++;
        i++;
    }
    ptr += sprintf(ptr, "<<md32 log buf end>>\n");

    printk("md32_aee_dump end\n");

    return ptr - buf;
}
开发者ID:Jlsmily,项目名称:android_kernel_meilan2,代码行数:66,代码来源:md32_irq.c


示例17: do_syslog

/*
 * Commands to do_syslog:
 *
 * 	0 -- Close the log.  Currently a NOP.
 * 	1 -- Open the log. Currently a NOP.
 * 	2 -- Read from the log.
 * 	3 -- Read all messages remaining in the ring buffer.
 * 	4 -- Read and clear all messages remaining in the ring buffer
 * 	5 -- Clear ring buffer.
 * 	6 -- Disable printk's to console
 * 	7 -- Enable printk's to console
 *	8 -- Set level of messages printed to console
 *	9 -- Return number of unread characters in the log buffer
 *     10 -- Return size of the log buffer
 */
int do_syslog(int type, char __user *buf, int len)
{
	unsigned i, j, limit, count;
	int do_clear = 0;
	char c;
	int error = 0;

	error = security_syslog(type);
	if (error)
		return error;

	switch (type) {
	case 0:		/* Close log */
		break;
	case 1:		/* Open log */
		break;
	case 2:		/* Read from log */
		error = -EINVAL;
		if (!buf || len < 0)
			goto out;
		error = 0;
		if (!len)
			goto out;
		if (!access_ok(VERIFY_WRITE, buf, len)) {
			error = -EFAULT;
			goto out;
		}
		error = wait_event_interruptible(log_wait,
							(log_start - log_end));
		if (error)
			goto out;
		i = 0;
		spin_lock_irq(&logbuf_lock);
		while (!error && (log_start != log_end) && i < len) {
			c = LOG_BUF(log_start);
			log_start++;
			spin_unlock_irq(&logbuf_lock);
			error = __put_user(c,buf);
			buf++;
			i++;
			cond_resched();
			spin_lock_irq(&logbuf_lock);
		}
		spin_unlock_irq(&logbuf_lock);
		if (!error)
			error = i;
		break;
	case 4:		/* Read/clear last kernel messages */
		do_clear = 1;
		/* FALL THRU */
	case 3:		/* Read last kernel messages */
		error = -EINVAL;
		if (!buf || len < 0)
			goto out;
		error = 0;
		if (!len)
			goto out;
		if (!access_ok(VERIFY_WRITE, buf, len)) {
			error = -EFAULT;
			goto out;
		}
		count = len;
		if (count > log_buf_len)
			count = log_buf_len;
		spin_lock_irq(&logbuf_lock);
		if (count > logged_chars)
			count = logged_chars;
		if (do_clear)
			logged_chars = 0;
		limit = log_end;
		/*
		 * __put_user() could sleep, and while we sleep
		 * printk() could overwrite the messages
		 * we try to copy to user space. Therefore
		 * the messages are copied in reverse. <manfreds>
		 */
		for (i = 0; i < count && !error; i++) {
			j = limit-1-i;
			if (j + log_buf_len < log_end)
				break;
			c = LOG_BUF(j);
			spin_unlock_irq(&logbuf_lock);
			error = __put_user(c,&buf[count-1-i]);
			cond_resched();
			spin_lock_irq(&logbuf_lock);
//.........这里部分代码省略.........
开发者ID:Asrake,项目名称:m8_android_kernel,代码行数:101,代码来源:printk.c



注:本文中的LOG_BUF函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LOG_CRITICAL函数代码示例发布时间:2022-05-30
下一篇:
C++ LOG_BLOCK函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap