openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/sys-utils/dmesg.c
static ssize_t read_buffer(struct dmesg_control* ctl, char** buf)
{
    ssize_t n = -1;

    switch (ctl->method)
    {
        case DMESG_METHOD_MMAP:
            n = mmap_file_buffer(ctl, buf);
            break;
        case DMESG_METHOD_SYSLOG:
            if (!ctl->bufsize)
                ctl->bufsize = get_syslog_buffer_size();

            n = read_syslog_buffer(ctl, buf);
            break;
        case DMESG_METHOD_KMSG:
            /*
             * Since kernel 3.5.0
             */
            n = read_kmsg(ctl);
            if (n == 0 && ctl->action == SYSLOG_ACTION_READ_CLEAR)
                n = klogctl(SYSLOG_ACTION_CLEAR, NULL, 0);
            break;
        default:
            abort(); /* impossible method -> drop core */
    }

    return n;
}
/*
 * Top level function to read messages
 */
Top level function to read messages
Top level function to read messages
static ssize_t read_buffer(struct dmesg_control* ctl, char** buf)
{
    ssize_t n = -1;
    switch (ctl->method)
    {
        case DMESG_METHOD_MMAP:
            n = mmap_file_buffer(ctl, buf);
            break;
        case DMESG_METHOD_SYSLOG:
            if (!ctl->bufsize)
                ctl->bufsize = get_syslog_buffer_size();
            n = read_syslog_buffer(ctl, buf);
            break;
        case DMESG_METHOD_KMSG:
            n = read_kmsg(ctl);
            if (n == 0 && ctl->action == SYSLOG_ACTION_READ_CLEAR)
                n = klogctl(SYSLOG_ACTION_CLEAR, NULL, 0);
            break;
        default:
            abort(); 
    }
    return n;
}
static ssize_t read_buffer ( struct dmesg_control * ctl , char * * buf ) { ssize_t n = -1 ; switch ( ctl -> method ) { case DMESG_METHOD_MMAP : n = mmap_file_buffer ( ctl , buf ) ; break ; case DMESG_METHOD_SYSLOG : if ( ! ctl -> bufsize ) ctl -> bufsize = get_syslog_buffer_size ( ) ; n = read_syslog_buffer ( ctl , buf ) ; break ; case DMESG_METHOD_KMSG : n = read_kmsg ( ctl ) ; if ( n == 0 && ctl -> action == SYSLOG_ACTION_READ_CLEAR ) n = klogctl ( SYSLOG_ACTION_CLEAR , NULL , 0 ) ; break ; default : abort ( ) ; } return n ; }
Top level function to read messages
Top level function to read messages
/*
             * Since kernel 3.5.0
             */ /* impossible method -> drop core */