Skip to content
  • David Howells's avatar
    vfs: Implement logging through fs_context · e6d72ffc
    David Howells authored
    
    
    Implement the ability for filesystems to log error, warning and
    informational messages through the fs_context.  In the future, these will
    be extractable by userspace by reading from an fd created by the fsopen()
    syscall.
    
    Error messages are prefixed with "e ", warnings with "w " and informational
    messages with "i ".
    
    In the future, inside the kernel, formatted messages will be malloc'd but
    unformatted messages will not copied if they're either in the core .rodata
    section or in the .rodata section of the filesystem module pinned by
    fs_context::fs_type.  The messages will only be good till the fs_type is
    released.
    
    Note that the logging object will be shared between duplicated fs_context
    structures.  This is so that such as NFS which do a mount within a mount
    can get at least some of the errors from the inner mount.
    
    Five logging functions are provided for this:
    
     (1) void logfc(struct fs_context *fc, const char *fmt, ...);
    
         This logs a message into the context.  If the buffer is full, the
         earliest message is discarded.
    
     (2) void errorf(fc, fmt, ...);
    
         This wraps logfc() to log an error.
    
     (3) void invalf(fc, fmt, ...);
    
         This wraps errorf() and returns -EINVAL for convenience.
    
     (4) void warnf(fc, fmt, ...);
    
         This wraps logfc() to log a warning.
    
     (5) void infof(fc, fmt, ...);
    
         This wraps logfc() to log an informational message.
    
    Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
    Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
    e6d72ffc