Changeset 8e9b2534 in mainline


Ignore:
Timestamp:
2017-03-26T10:28:44Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f644472
Parents:
58898d1d
Message:

Set logger's VFS root

As an init task, logger starts with no VFS root, which effectively
disables logging to /log/*. In this commit we add a way to set logger's
root after the root is mounted in init to fix this. Note that some log
entries might be still missing as file-based logging kicks in quite
late.

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/init/init.c

    r58898d1d r8e9b2534  
    5050#include <str_error.h>
    5151#include <config.h>
     52#include <io/logctl.h>
    5253#include "init.h"
    5354
     
    129130        int rc = mount(fstype, ROOT_MOUNT_POINT, ROOT_DEVICE, opts,
    130131            IPC_FLAG_BLOCKING, 0);
     132        if (rc == EOK)
     133                logctl_set_root();
    131134        return mount_report("Root filesystem", ROOT_MOUNT_POINT, fstype,
    132135            ROOT_DEVICE, rc);
  • uspace/lib/c/generic/io/logctl.c

    r58898d1d r8e9b2534  
    3939#include <ns.h>
    4040#include <str.h>
     41#include <vfs/vfs.h>
    4142
    4243/** IPC session with the logger service. */
     
    122123}
    123124
     125/** Set logger's VFS root.
     126 *
     127 * @return Error code or EOK on success.
     128 */
     129int logctl_set_root(void)
     130{
     131        async_exch_t *exchange = NULL;
     132        int rc = start_logger_exchange(&exchange);
     133        if (rc != EOK)
     134                return rc;
     135
     136        aid_t reg_msg = async_send_0(exchange, LOGGER_CONTROL_SET_ROOT, NULL);
     137        async_exch_t *vfs_exch = vfs_exchange_begin();
     138        rc = vfs_pass_handle(vfs_exch, vfs_root(), exchange);
     139        vfs_exchange_end(vfs_exch);
     140        sysarg_t reg_msg_rc;
     141        async_wait_for(reg_msg, &reg_msg_rc);
     142
     143        async_exchange_end(exchange);
     144
     145        if (rc != EOK)
     146                return rc;
     147
     148        return (int) reg_msg_rc;
     149}
     150
    124151/** @}
    125152 */
  • uspace/lib/c/include/io/logctl.h

    r58898d1d r8e9b2534  
    3838extern int logctl_set_default_level(log_level_t);
    3939extern int logctl_set_log_level(const char *, log_level_t);
     40extern int logctl_set_root(void);
    4041
    4142#endif
  • uspace/lib/c/include/ipc/logger.h

    r58898d1d r8e9b2534  
    4949         * Followed by: string with full log name.
    5050         */
    51         LOGGER_CONTROL_SET_LOG_LEVEL
     51        LOGGER_CONTROL_SET_LOG_LEVEL,
     52        /** Set VFS root.
     53         *
     54         * Returns: error code
     55         * Followed by: vfs_pass_handle() request.
     56         */
     57        LOGGER_CONTROL_SET_ROOT
    5258} logger_control_request_t;
    5359
  • uspace/srv/logger/ctl.c

    r58898d1d r8e9b2534  
    4141#include <io/logctl.h>
    4242#include <ipc/logger.h>
     43#include <vfs/vfs.h>
    4344#include "logger.h"
    4445
     
    8687                        break;
    8788                }
     89                case LOGGER_CONTROL_SET_ROOT: {
     90                        int fd = vfs_receive_handle(true);
     91                        vfs_root_set(fd);
     92                        async_answer_0(callid, fd >= 0 ? EOK : fd);
     93                        break;
     94                }
    8895                default:
    8996                        async_answer_0(callid, EINVAL);
Note: See TracChangeset for help on using the changeset viewer.