From owner-freebsd-hackers@FreeBSD.ORG Sun Feb 15 01:44:04 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2F87F33D for ; Sun, 15 Feb 2015 01:44:04 +0000 (UTC) Received: from mail-yh0-x229.google.com (mail-yh0-x229.google.com [IPv6:2607:f8b0:4002:c01::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DDC83114 for ; Sun, 15 Feb 2015 01:44:03 +0000 (UTC) Received: by mail-yh0-f41.google.com with SMTP id 29so11340854yhl.0 for ; Sat, 14 Feb 2015 17:44:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=YAQLCrS/18OKuZgikaoH2f840LcWx9bXjFrzRYy6lks=; b=eXtsh3mnZUSgeiW5+6OerU1QP7Wt9A6rBhzgFkiIH1+5SaA/ASNqAqpkeJu3FaSxG3 1/IiIIFqUkeAAD/E240l9fveJfl6eiehZUrqzEZBHx7UYffjydtWRKepYvZeppXh0WFd d3h4EyYoMayoSQ91fRfhrRQJaeszj0ujy1lYYGLqWWhtvBSrL4Dd2SmMJbwX0C8U2H2y 2LSRKVBmBxRP+HGuUBAJEJOmwwPP9nn/6/brxSUxQymk74oJLV735Kppf39fghcP8Q7w fOqxguhwdnk6qBMfgLzhv+845E0cbhBo3AKAzqHMUXLcm7cnpb3i4mHmGHl53KiAkR4F tfWA== X-Received: by 10.236.66.133 with SMTP id h5mr13010192yhd.28.1423964642981; Sat, 14 Feb 2015 17:44:02 -0800 (PST) MIME-Version: 1.0 Received: by 10.170.118.13 with HTTP; Sat, 14 Feb 2015 17:43:32 -0800 (PST) From: Yue Chen Date: Sat, 14 Feb 2015 20:43:32 -0500 Message-ID: Subject: Suggestions for communication between FreeBSD user-space and kernel modules To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2015 01:44:04 -0000 Dear all, I am working on a project that needs to read some text or binary files, and let my kernel module get the information. What is the best (convenient and efficient) way to implement this? It seems painful if reading files in a kernel module directly. For Linux, there are ways like netlink, virtual filesystems, e.g. /proc, /sys, configfs, relayfs, debugfs, poll() / epoll() / select() related; to send info to/from kernel space. I searched the Internet but most results are for Linux only. One possible way for FreeBSD is to use /dev/kmem, but that is to write information directly to a certain memory address, seems to be error-prone. Any help would be highly appreciated. Best, Yue