X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fsysfs%2Ffile.c;h=669e09d93545cf42c8d134d9f66ec2be8cf7a74c;hb=refs%2Fheads%2Fvserver;hp=da0b930e89eb5048968969adbce8572d276a55bd;hpb=43bc926fffd92024b46cafaf7350d669ba9ca884;p=linux-2.6.git diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index da0b930e8..669e09d93 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c @@ -155,11 +155,11 @@ sysfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos) down(&buffer->sem); if (buffer->needs_read_fill) { - if ((retval = fill_read_buffer(file->f_dentry,buffer))) + if ((retval = fill_read_buffer(file->f_path.dentry,buffer))) goto out; } - pr_debug("%s: count = %d, ppos = %lld, buf = %s\n", - __FUNCTION__,count,*ppos,buffer->page); + pr_debug("%s: count = %zd, ppos = %lld, buf = %s\n", + __FUNCTION__, count, *ppos, buffer->page); retval = flush_read_buffer(buffer,buf,count,ppos); out: up(&buffer->sem); @@ -191,6 +191,9 @@ fill_write_buffer(struct sysfs_buffer * buffer, const char __user * buf, size_t count = PAGE_SIZE - 1; error = copy_from_user(buffer->page,buf,count); buffer->needs_read_fill = 1; + /* if buf is assumed to contain a string, terminate it by \0, + so e.g. sscanf() can scan the string easily */ + buffer->page[count] = 0; return error ? -EFAULT : count; } @@ -243,7 +246,7 @@ sysfs_write_file(struct file *file, const char __user *buf, size_t count, loff_t down(&buffer->sem); len = fill_write_buffer(buffer, buf, count); if (len > 0) - len = flush_write_buffer(file->f_dentry, buffer, len); + len = flush_write_buffer(file->f_path.dentry, buffer, len); if (len > 0) *ppos += len; up(&buffer->sem); @@ -252,8 +255,8 @@ sysfs_write_file(struct file *file, const char __user *buf, size_t count, loff_t static int check_perm(struct inode * inode, struct file * file) { - struct kobject *kobj = sysfs_get_kobject(file->f_dentry->d_parent); - struct attribute * attr = to_attr(file->f_dentry); + struct kobject *kobj = sysfs_get_kobject(file->f_path.dentry->d_parent); + struct attribute * attr = to_attr(file->f_path.dentry); struct sysfs_buffer * buffer; struct sysfs_ops * ops = NULL; int error = 0; @@ -341,8 +344,8 @@ static int sysfs_open_file(struct inode * inode, struct file * filp) static int sysfs_release(struct inode * inode, struct file * filp) { - struct kobject * kobj = to_kobj(filp->f_dentry->d_parent); - struct attribute * attr = to_attr(filp->f_dentry); + struct kobject * kobj = to_kobj(filp->f_path.dentry->d_parent); + struct attribute * attr = to_attr(filp->f_path.dentry); struct module * owner = attr->owner; struct sysfs_buffer * buffer = filp->private_data; @@ -376,8 +379,8 @@ static int sysfs_release(struct inode * inode, struct file * filp) static unsigned int sysfs_poll(struct file *filp, poll_table *wait) { struct sysfs_buffer * buffer = filp->private_data; - struct kobject * kobj = to_kobj(filp->f_dentry->d_parent); - struct sysfs_dirent * sd = filp->f_dentry->d_fsdata; + struct kobject * kobj = to_kobj(filp->f_path.dentry->d_parent); + struct sysfs_dirent * sd = filp->f_path.dentry->d_fsdata; int res = 0; poll_wait(filp, &kobj->poll, wait); @@ -490,17 +493,12 @@ int sysfs_update_file(struct kobject * kobj, const struct attribute * attr) (victim->d_parent->d_inode == dir->d_inode)) { victim->d_inode->i_mtime = CURRENT_TIME; fsnotify_modify(victim); - - /** - * Drop reference from initial sysfs_get_dentry(). - */ - dput(victim); res = 0; } else d_drop(victim); /** - * Drop the reference acquired from sysfs_get_dentry() above. + * Drop the reference acquired from lookup_one_len() above. */ dput(victim); }