lkml.org 
[lkml]   [2007]   [Apr]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 13/16] show-pipesize-in-stat.diff
    On Sun, 1 Apr 2007 20:17:24 +0200 (MEST) Jan Engelhardt <jengelh@linux01.gwdg.de> wrote:

    >
    > Show the fill status of a pipe (in bytes) when stat'ing one.
    >

    Is this useful? It seems rather an obscure thing, and we generally need a
    good reason to go adding Linux-specific goodies to standard system calls
    like this. What do "other operating systems" do here?

    > - stat->size = i_size_read(inode);
    > + stat->size = 0;
    > + if (S_ISFIFO(inode->i_mode)) {
    > + const struct pipe_inode_info *info = inode->i_pipe;
    > + int i;
    > + stat->size = 0;
    > + if (info != NULL) {
    > + for (i = 0; i < PIPE_BUFFERS; ++i) {
    > + const struct pipe_buffer *buf = &info->bufs[i];
    > + if (buf != NULL && buf->page != NULL)
    > + stat->size += buf->len;
    > + }
    > + }
    > + } else if (S_ISSOCK(inode->i_mode)) {
    > +#ifdef CONFIG_UNIX_MODULE
    > + loff_t (*uxsize)(struct inode *) = __symbol_get("unixsock_size");
    > + if (uxsize != NULL) {
    > + stat->size = uxsize(inode);
    > + symbol_put("unixsock_size");
    > + }
    > +#endif
    > +#if defined(CONFIG_UNIX) && !defined(CONFIG_UNIX_MODULE)
    > + stat->size = unixsock_size(inode);
    > +#endif
    > + } else {
    > + stat->size = i_size_read(inode);
    > + }

    That's a bit fugly.

    > +loff_t unixsock_size(struct inode *inode) {
    > + struct sock *sk = unix_find_socket_byinode(inode);
    > + loff_t eax;
    > +
    > + if(sk == NULL) { return 0; }
    > + eax = sk->sk_rcvbuf;
    > + sock_put(sk);
    > + return eax;
    > +}
    > +EXPORT_SYMBOL(unixsock_size);

    That's wildly incorrect coding style, and it doesn't use tabs.
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2007-04-02 08:01    [W:0.024 / U:60.068 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site