From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Schmidt Subject: [RFC] Passing stream to userspace Date: Fri, 12 Aug 2011 17:30:32 +0200 Message-ID: <4E454718.6000206@jan-o-sch.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Cc: Chris Mason , Matthew Wilcox , linux-btrfs , linux-fsdevel@vger.kernel.org To: Al Viro , Christoph Hellwig Return-path: List-ID: Hi there, I was promised you (viro, hch) have a decided opinion on this topic. The original mail ("Getting a lot of fs-generated information to user space") contains a lot of background and is way too long. Point is: I want to get a bunch of data generated by the kernel (btrfs) to userland (really). Matthew Wilcox suggested to use an ioctl changing f_ops.read. Userland would be like: > int fd = open("/mnt/btrfs"); > ioctl(fd, BTRFS_IOC_STREAM); > while (...) { > read(fd, buf, 4096); > ... > } > close(fd); To avoid doing buffering myself, I suggested passing a fd to the kernel where it is expected to dump the generated information, like: > int fd; > int pipefd[2]; > struct io_args io_args; > > fd = open("/mnt/btrfs"); > pipe(pipefd); > io_agrs.dest = pipefd[0]; > > /* thread 1 */ > ioctl(fd, BTRFS_IOC_STREAM, &io_args); > /* thread 2 */ > while (...) { > read(pipefd[1], buf, 4096); > ... > } Any opinions on those or different suggestions? Thanks, -Jan