No, this patch does not update the proper file within sysfs, only the
directory entry, which isn't what we really want. I just sent off the
following patch to Pat Mochel that adds sysfs_update_file() to sysfs,
and modified the pci hotplug core to use it. I've already applied your
previous patches, so you don't have to resend anything to me :)
thanks,
greg k-h
# sysfs: add sysfs_update_file() function.
diff -Nru a/fs/sysfs/inode.c b/fs/sysfs/inode.c
--- a/fs/sysfs/inode.c Wed Jan 29 14:05:17 2003
+++ b/fs/sysfs/inode.c Wed Jan 29 14:05:17 2003
@@ -37,6 +37,7 @@
#include <linux/backing-dev.h>
#include <linux/kobject.h>
#include <linux/mount.h>
+#include <linux/dnotify.h>
#include <asm/uaccess.h>
/* Random magic number */
@@ -714,6 +715,46 @@
dput(victim);
}
up(&dir->d_inode->i_sem);
+}
+
+/**
+ * sysfs_update_file - update the modified timestamp on an object attribute.
+ * @kobj: object we're acting for.
+ * @attr: attribute descriptor.
+ *
+ * Also call dnotify for the dentry, which lots of userspace programs
+ * use.
+ */
+int sysfs_update_file(struct kobject * kobj, struct attribute * attr)
+{
+ struct dentry * dir = kobj->dentry;
+ struct dentry * victim;
+ int res = -ENOENT;
+
+ down(&dir->d_inode->i_sem);
+ victim = get_dentry(dir, attr->name);
+ if (!IS_ERR(victim)) {
+ /* make sure dentry is really there */
+ if (victim->d_inode &&
+ (victim->d_parent->d_inode == dir->d_inode)) {
+ victim->d_inode->i_mtime = CURRENT_TIME;
+ dnotify_parent(victim, DN_MODIFY);
+
+ /**
+ * Drop reference from initial get_dentry().
+ */
+ dput(victim);
+ res = 0;
+ }
+
+ /**
+ * Drop the reference acquired from get_dentry() above.
+ */
+ dput(victim);
+ }
+ up(&dir->d_inode->i_sem);
+
+ return res;
}
diff -Nru a/include/linux/sysfs.h b/include/linux/sysfs.h
--- a/include/linux/sysfs.h Wed Jan 29 14:05:17 2003
+++ b/include/linux/sysfs.h Wed Jan 29 14:05:17 2003
@@ -30,6 +30,9 @@
extern int
sysfs_create_file(struct kobject *, struct attribute *);
+extern int
+sysfs_update_file(struct kobject *, struct attribute *);
+
extern void
sysfs_remove_file(struct kobject *, struct attribute *);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/