Messages in this thread | | | Date | Sun, 1 Apr 2007 22:58:33 -0700 | From | Andrew Morton <> | Subject | Re: [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/
| |