Skip to content
  • David Howells's avatar
    vfs: Implement logging through fs_context · a1794f41
    David Howells authored
    
    
    Implement the ability for filesystems to log error, warning and
    informational messages through the fs_context.  These can be extracted by
    userspace by reading from an fd created by fsopen().
    
    Error messages are prefixed with "e ", warnings with "w " and informational
    messages with "i ".
    
    Inside the kernel, formatted messages are malloc'd but unformatted messages
    are 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 are only good till the fs_type is released.
    
    Note that the logging object is 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>
    a1794f41