public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: Greg KH <greg@kroah.com>
Cc: James Bottomley <James.Bottomley@SteelEye.com>,
	Patrick Mansfield <patmans@us.ibm.com>,
	SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] 2/2 Use bus dev_attrs to create scsi_device attributes
Date: Wed, 30 Mar 2005 05:15:55 +0200	[thread overview]
Message-ID: <20050330031555.GA18871@vrfy.org> (raw)
In-Reply-To: <20050317170853.GA3006@kroah.com>

On Thu, Mar 17, 2005 at 09:08:53AM -0800, Greg KH wrote:
> On Thu, Mar 17, 2005 at 09:53:21AM -0500, James Bottomley wrote:
> > On Wed, 2005-03-16 at 14:45 -0800, Patrick Mansfield wrote:
> > > Any comments on this? Should I resend these patches?
> > 
> > Well, the basic comment is that there are a lot of features that SCSI
> > has that the driver core lacks:
> > 
> > 1) Attribute overrides.  This is actually part of the published API for SCSI
> > 2) Ability to add extra attributes---several drivers use this
> > 3) Ability to change attribute permissions based on capabilities.

> I would be very interested in seeing the above stuff move into the
> driver core.

Point 3) seems to work for me. :)

Thanks,
Kay

---
sysfs: allow change of permissions for already created attributes

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>

===== fs/sysfs/file.c 1.23 vs edited =====
--- 1.23/fs/sysfs/file.c	2005-02-26 15:48:19 +01:00
+++ edited/fs/sysfs/file.c	2005-03-30 04:16:46 +02:00
@@ -428,6 +428,39 @@ int sysfs_update_file(struct kobject * k
 
 
 /**
+ * sysfs_chmod_file - update the modified mode value on an object attribute.
+ * @kobj: object we're acting for.
+ * @mode: file permissions.
+ *
+ */
+int sysfs_chmod_file(struct kobject *kobj, const struct attribute *attr)
+{
+	struct dentry *dir = kobj->dentry;
+	struct dentry *victim;
+	struct sysfs_dirent *sd;
+	umode_t mode = (attr->mode & S_IALLUGO) | S_IFREG;
+	int res = -ENOENT;
+
+	down(&dir->d_inode->i_sem);
+	victim = sysfs_get_dentry(dir, attr->name);
+	if (!IS_ERR(victim)) {
+		if (victim->d_inode &&
+		    (victim->d_parent->d_inode == dir->d_inode)) {
+			sd = victim->d_fsdata;
+			sd->s_mode = mode;
+			victim->d_inode->i_mode = mode;
+			dput(victim);
+			res = 0;
+		}
+	}
+	up(&dir->d_inode->i_sem);
+
+	return res;
+}
+EXPORT_SYMBOL_GPL(sysfs_chmod_file);
+
+
+/**
  *	sysfs_remove_file - remove an object attribute.
  *	@kobj:	object we're acting for.
  *	@attr:	attribute descriptor.
===== include/linux/sysfs.h 1.39 vs edited =====
--- 1.39/include/linux/sysfs.h	2004-12-21 18:31:01 +01:00
+++ edited/include/linux/sysfs.h	2005-03-30 04:12:38 +02:00
@@ -99,6 +99,9 @@ sysfs_create_file(struct kobject *, cons
 extern int
 sysfs_update_file(struct kobject *, const struct attribute *);
 
+extern int
+sysfs_chmod_file(struct kobject *kobj, const struct attribute *attr);
+
 extern void
 sysfs_remove_file(struct kobject *, const struct attribute *);
 
@@ -137,6 +140,10 @@ static inline int sysfs_create_file(stru
 }
 
 static inline int sysfs_update_file(struct kobject * k, const struct attribute * a)
+{
+	return 0;
+}
+static inline int sysfs_chmod_file(struct kobject *kobj, const struct attribute *attr)
 {
 	return 0;
 }


  reply	other threads:[~2005-03-30  3:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-02 19:44 [PATCH] 0/2 use sysfs bus dev_attrs for scsi_device attributes Patrick Mansfield
2005-03-02 19:45 ` [PATCH] 1/2 remove attr_changed_internally Patrick Mansfield
2005-03-02 19:46   ` [PATCH] 2/2 Use bus dev_attrs to create scsi_device attributes Patrick Mansfield
2005-03-16 22:45     ` Patrick Mansfield
2005-03-17 14:53       ` James Bottomley
2005-03-17 17:08         ` Greg KH
2005-03-30  3:15           ` Kay Sievers [this message]
2005-03-30  4:20             ` Greg KH
2005-03-30 18:07               ` Kay Sievers
2005-04-06 20:22                 ` Greg KH
2005-03-30 18:32         ` Kay Sievers
2005-03-30 21:44           ` Patrick Mansfield
2005-03-30 22:12             ` Kay Sievers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050330031555.GA18871@vrfy.org \
    --to=kay.sievers@vrfy.org \
    --cc=James.Bottomley@SteelEye.com \
    --cc=greg@kroah.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=patmans@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox