Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 9246016 in mainline


Ignore:
Timestamp:
2017-12-08T21:03:35Z (4 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master
Children:
6ad454f
Parents:
f43742e2
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-08 05:21:59)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-08 21:03:35)
Message:

In SYS_KLOG, pass number of bytes read separately from error code.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/log.h

    rf43742e2 r9246016  
    5252
    5353extern sysarg_t sys_klog(sysarg_t, void *buf, size_t size,
    54     sysarg_t level);
     54    sysarg_t level, size_t *uspace_nread);
    5555
    5656#endif /* KERN_LOG_H_ */
  • kernel/generic/src/log/log.c

    rf43742e2 r9246016  
    294294 */
    295295sysarg_t sys_klog(sysarg_t operation, void *buf, size_t size,
    296     sysarg_t level)
     296    sysarg_t level, size_t *uspace_nread)
    297297{
    298298        char *data;
     
    376376                                return (sysarg_t) rc;
    377377                       
    378                         return copied;
     378                        return copy_to_uspace(uspace_nread, &copied, sizeof(copied));
     379                        return EOK;
    379380                default:
    380381                        return (sysarg_t) ENOTSUP;
  • uspace/lib/c/generic/io/klog.c

    rf43742e2 r9246016  
    4242#include <abi/log.h>
    4343
    44 size_t klog_write(log_level_t lvl, const void *buf, size_t size)
     44int klog_write(log_level_t lvl, const void *buf, size_t size)
    4545{
    46         ssize_t ret = (ssize_t) __SYSCALL4(SYS_KLOG, KLOG_WRITE, (sysarg_t) buf,
     46        return (int) __SYSCALL4(SYS_KLOG, KLOG_WRITE, (sysarg_t) buf,
    4747            size, lvl);
    48        
    49         if (ret >= 0)
    50                 return (size_t) ret;
    51        
    52         return 0;
    5348}
    5449
    55 int klog_read(void *data, size_t size)
     50int klog_read(void *data, size_t size, size_t *nread)
    5651{
    57         return (int) __SYSCALL4(SYS_KLOG, KLOG_READ, (uintptr_t) data, size, 0);
     52        return (int) __SYSCALL5(SYS_KLOG, KLOG_READ, (uintptr_t) data,
     53            size, 0, (sysarg_t) nread);
    5854}
    5955
  • uspace/lib/c/include/io/klog.h

    rf43742e2 r9246016  
    4444#include <abi/log.h>
    4545
    46 extern size_t klog_write(log_level_t, const void *, size_t);
    47 extern int klog_read(void *, size_t);
     46extern int klog_write(log_level_t, const void *, size_t);
     47extern int klog_read(void *, size_t, size_t *);
    4848
    4949#define KLOG_PRINTF(lvl, fmt, ...) ({ \
  • uspace/srv/klog/klog.c

    rf43742e2 r9246016  
    100100static void producer(void)
    101101{
    102         int read = klog_read(buffer, BUFFER_SIZE);
    103        
    104         if (read < 0) {
    105                 log_msg(LOG_DEFAULT, LVL_ERROR, "klog_read failed, rc = %d",
    106                     read);
     102        size_t len = 0;
     103        int rc = klog_read(buffer, BUFFER_SIZE, &len);
     104        if (rc != EOK) {
     105                log_msg(LOG_DEFAULT, LVL_ERROR, "klog_read failed, rc = %s",
     106                    str_error_name(rc));
    107107                return;
    108108        }
    109109       
    110         size_t len = read;
    111110        size_t offset = 0;
    112111        while (offset < len) {
Note: See TracChangeset for help on using the changeset viewer.