All of lore.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 20:07:02 +0200	[thread overview]
Message-ID: <20050330180702.GA4654@vrfy.org> (raw)
In-Reply-To: <20050330042043.GA9002@kroah.com>

On Tue, Mar 29, 2005 at 08:20:43PM -0800, Greg KH wrote:
> On Wed, Mar 30, 2005 at 05:15:55AM +0200, Kay Sievers wrote:
> >  /**
> > + * 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)
> 
> Your documentation doesn't match up with your function arguments :)

Bah, I tried both versions. :)

> Shouldn't you want an extra mode variable?  Makes it easier to override
> than remembering to change the mode in the attribute before calling the
> function.

If that's better, sure. Here is a new patch.

Thanks,
Kay

---
sysfs: allow changing the 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 20:01:16 +02:00
@@ -428,6 +428,41 @@ 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.
+ * @attr: attribute descriptor.
+ * @mode: file permissions.
+ *
+ */
+int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode)
+{
+	struct dentry *dir = kobj->dentry;
+	struct dentry *victim;
+	struct sysfs_dirent *sd;
+	umode_t umode = (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;
+			attr->mode = mode;
+			sd->s_mode = umode;
+			victim->d_inode->i_mode = umode;
+			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 15:06:23 +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, struct attribute *attr, mode_t mode);
+
 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, struct attribute *attr, mode_t mode)
 {
 	return 0;
 }


  reply	other threads:[~2005-03-30 18:07 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
2005-03-30  4:20             ` Greg KH
2005-03-30 18:07               ` Kay Sievers [this message]
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=20050330180702.GA4654@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.