From patchwork Thu Feb 25 08:37:55 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: 81917 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 o1P8cahS013825 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 25 Feb 2010 08:39:16 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NkZEh-0001pl-LD; Thu, 25 Feb 2010 08:38:19 +0000 Received: from sfi-mx-3.v28.ch3.sourceforge.com ([172.29.28.123] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NkZEf-0001pb-VD for v9fs-developer@lists.sourceforge.net; Thu, 25 Feb 2010 08:38:17 +0000 X-ACL-Warn: Received: from e28smtp05.in.ibm.com ([122.248.162.5]) by sfi-mx-3.v28.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1NkZEe-0006TR-Fx for v9fs-developer@lists.sourceforge.net; Thu, 25 Feb 2010 08:38:17 +0000 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by e28smtp05.in.ibm.com (8.14.3/8.13.1) with ESMTP id o1P8c2Ix030935 for ; Thu, 25 Feb 2010 14:08:02 +0530 Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o1P8c2Ai2977936 for ; Thu, 25 Feb 2010 14:08:02 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o1P8c1nh006252 for ; Thu, 25 Feb 2010 19:38:01 +1100 Received: from localhost.localdomain ([9.124.31.147]) by d28av02.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o1P8c1Av006243; Thu, 25 Feb 2010 19:38:01 +1100 From: "Aneesh Kumar K.V" To: v9fs-developer@lists.sourceforge.net Date: Thu, 25 Feb 2010 14:07:55 +0530 Message-Id: <1267087076-19441-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.0.83.g241b9 In-Reply-To: <1267087076-19441-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1267087076-19441-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Spam-Score: -0.8 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.8 AWL AWL: From: address is in the auto white-list X-Headers-End: 1NkZEe-0006TR-Fx Subject: [V9fs-developer] [PATCH 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]); Thu, 25 Feb 2010 08:39:16 +0000 (UTC) diff --git a/include/linux/virtio.h b/include/linux/virtio.h index 057a2e0..5177370 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h @@ -94,6 +94,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);