From patchwork Sat Mar 6 04:44:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 83873 X-Patchwork-Delegate: ericvh@gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o264idqq032176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 6 Mar 2010 04:45:16 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NnlsP-0008Bo-L7; Sat, 06 Mar 2010 04:44:33 +0000 Received: from sfi-mx-3.v28.ch3.sourceforge.com ([172.29.28.123] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NnlsN-0008Bg-VA for v9fs-developer@lists.sourceforge.net; Sat, 06 Mar 2010 04:44:31 +0000 X-ACL-Warn: Received: from e28smtp02.in.ibm.com ([122.248.162.2]) by sfi-mx-3.v28.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1NnlsM-0001Io-Ao for v9fs-developer@lists.sourceforge.net; Sat, 06 Mar 2010 04:44:31 +0000 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by e28smtp02.in.ibm.com (8.14.3/8.13.1) with ESMTP id o264iKDJ017544 for ; Sat, 6 Mar 2010 10:14:20 +0530 Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o264iKCq2953254 for ; Sat, 6 Mar 2010 10:14:20 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o264iKH2005284 for ; Sat, 6 Mar 2010 10:14:20 +0530 Received: from localhost.localdomain ([9.77.124.141]) by d28av01.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o264iJ66005272; Sat, 6 Mar 2010 10:14:19 +0530 From: "Aneesh Kumar K.V" To: v9fs-developer@lists.sourceforge.net Date: Sat, 6 Mar 2010 10:14:15 +0530 Message-Id: <1267850656-14653-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.0.1.147.g6d84b In-Reply-To: <1267850656-14653-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1267850656-14653-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Spam-Score: -0.1 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.1 AWL AWL: From: address is in the auto white-list X-Headers-End: 1NnlsM-0001Io-Ao Subject: [V9fs-developer] [PATCH -V3 2/3] net/9p: Add sysfs mount_tag file for virtio 9P device X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 06 Mar 2010 04:45:16 +0000 (UTC) diff --git a/include/linux/virtio.h b/include/linux/virtio.h index f508c65..40d1709 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h @@ -98,6 +98,7 @@ struct virtio_device { void *priv; }; +#define dev_to_virtio(dev) container_of(dev, struct virtio_device, dev) int register_virtio_device(struct virtio_device *dev); void unregister_virtio_device(struct virtio_device *dev); diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index 026775a..afde1a8 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c @@ -220,6 +220,20 @@ p9_virtio_request(struct p9_client *client, struct p9_req_t *req) return 0; } +static ssize_t p9_mount_tag_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct virtio_chan *chan; + struct virtio_device *vdev; + + vdev = dev_to_virtio(dev); + chan = vdev->priv; + + return snprintf(buf, chan->tag_len + 1, "%s", chan->tag); +} + +static DEVICE_ATTR(mount_tag, 0444, p9_mount_tag_show, NULL); + /** * p9_virtio_probe - probe for existence of 9P virtio channels * @vdev: virtio device to probe @@ -273,6 +287,11 @@ static int p9_virtio_probe(struct virtio_device *vdev) tag, tag_len); chan->tag = tag; chan->tag_len = tag_len; + err = sysfs_create_file(&(vdev->dev.kobj), &dev_attr_mount_tag.attr); + if (err) { + kfree(tag); + goto out_free_vq; + } mutex_lock(&virtio_9p_lock); list_add_tail(&chan->chan_list, &virtio_chan_list); mutex_unlock(&virtio_9p_lock); @@ -348,6 +367,7 @@ static void p9_virtio_remove(struct virtio_device *vdev) mutex_lock(&virtio_9p_lock); list_del(&chan->chan_list); mutex_unlock(&virtio_9p_lock); + sysfs_remove_file(&(vdev->dev.kobj), &dev_attr_mount_tag.attr); kfree(chan->tag); kfree(chan);