diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-11-13 01:34:18 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-11-13 01:34:18 -0500 |
| commit | 9bc9ccd7db1c9f043f75380b5a5b94912046a60e (patch) | |
| tree | dd0a1b3396ae9414f668b0110cc39d11268ad3ed /drivers | |
| parent | f0230294271f511b41797305b685365a9e569a09 (diff) | |
| parent | bdd3536618443809d18868563eeafa63b9d29603 (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro:
"All kinds of stuff this time around; some more notable parts:
- RCU'd vfsmounts handling
- new primitives for coredump handling
- files_lock is gone
- Bruce's delegations handling series
- exportfs fixes
plus misc stuff all over the place"
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (101 commits)
ecryptfs: ->f_op is never NULL
locks: break delegations on any attribute modification
locks: break delegations on link
locks: break delegations on rename
locks: helper functions for delegation breaking
locks: break delegations on unlink
namei: minor vfs_unlink cleanup
locks: implement delegations
locks: introduce new FL_DELEG lock flag
vfs: take i_mutex on renamed file
vfs: rename I_MUTEX_QUOTA now that it's not used for quotas
vfs: don't use PARENT/CHILD lock classes for non-directories
vfs: pull ext4's double-i_mutex-locking into common code
exportfs: fix quadratic behavior in filehandle lookup
exportfs: better variable name
exportfs: move most of reconnect_path to helper function
exportfs: eliminate unused "noprogress" counter
exportfs: stop retrying once we race with rename/remove
exportfs: clear DISCONNECTED on all parents sooner
exportfs: more detailed comment for path_reconnect
...
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/base/devtmpfs.c | 6 | ||||
| -rw-r--r-- | drivers/char/misc.c | 12 | ||||
| -rw-r--r-- | drivers/gpu/drm/drm_fops.c | 17 | ||||
| -rw-r--r-- | drivers/media/dvb-core/dmxdev.c | 4 | ||||
| -rw-r--r-- | drivers/media/dvb-core/dvbdev.c | 19 | ||||
| -rw-r--r-- | drivers/mtd/nand/nandsim.c | 2 | ||||
| -rw-r--r-- | drivers/staging/comedi/comedi_compat32.c | 3 | ||||
| -rw-r--r-- | drivers/staging/lustre/lustre/include/linux/lustre_compat25.h | 4 | ||||
| -rw-r--r-- | drivers/staging/lustre/lustre/llite/namei.c | 2 | ||||
| -rw-r--r-- | drivers/staging/lustre/lustre/lvfs/lvfs_linux.c | 2 | ||||
| -rw-r--r-- | drivers/staging/rtl8188eu/include/osdep_service.h | 5 | ||||
| -rw-r--r-- | drivers/staging/rtl8188eu/os_dep/osdep_service.c | 208 | ||||
| -rw-r--r-- | drivers/usb/core/file.c | 16 |
13 files changed, 27 insertions, 273 deletions
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index 7413d065906b..0f3820121e02 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c | |||
| @@ -216,7 +216,7 @@ static int handle_create(const char *nodename, umode_t mode, kuid_t uid, | |||
| 216 | newattrs.ia_gid = gid; | 216 | newattrs.ia_gid = gid; |
| 217 | newattrs.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID; | 217 | newattrs.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID; |
| 218 | mutex_lock(&dentry->d_inode->i_mutex); | 218 | mutex_lock(&dentry->d_inode->i_mutex); |
| 219 | notify_change(dentry, &newattrs); | 219 | notify_change(dentry, &newattrs, NULL); |
| 220 | mutex_unlock(&dentry->d_inode->i_mutex); | 220 | mutex_unlock(&dentry->d_inode->i_mutex); |
| 221 | 221 | ||
| 222 | /* mark as kernel-created inode */ | 222 | /* mark as kernel-created inode */ |
| @@ -322,9 +322,9 @@ static int handle_remove(const char *nodename, struct device *dev) | |||
| 322 | newattrs.ia_valid = | 322 | newattrs.ia_valid = |
| 323 | ATTR_UID|ATTR_GID|ATTR_MODE; | 323 | ATTR_UID|ATTR_GID|ATTR_MODE; |
| 324 | mutex_lock(&dentry->d_inode->i_mutex); | 324 | mutex_lock(&dentry->d_inode->i_mutex); |
| 325 | notify_change(dentry, &newattrs); | 325 | notify_change(dentry, &newattrs, NULL); |
| 326 | mutex_unlock(&dentry->d_inode->i_mutex); | 326 | mutex_unlock(&dentry->d_inode->i_mutex); |
| 327 | err = vfs_unlink(parent.dentry->d_inode, dentry); | 327 | err = vfs_unlink(parent.dentry->d_inode, dentry, NULL); |
| 328 | if (!err || err == -ENOENT) | 328 | if (!err || err == -ENOENT) |
| 329 | deleted = 1; | 329 | deleted = 1; |
| 330 | } | 330 | } |
diff --git a/drivers/char/misc.c b/drivers/char/misc.c index 2f685f6eda48..ffa97d261cf3 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c | |||
| @@ -114,7 +114,7 @@ static int misc_open(struct inode * inode, struct file * file) | |||
| 114 | int minor = iminor(inode); | 114 | int minor = iminor(inode); |
| 115 | struct miscdevice *c; | 115 | struct miscdevice *c; |
| 116 | int err = -ENODEV; | 116 | int err = -ENODEV; |
| 117 | const struct file_operations *old_fops, *new_fops = NULL; | 117 | const struct file_operations *new_fops = NULL; |
| 118 | 118 | ||
| 119 | mutex_lock(&misc_mtx); | 119 | mutex_lock(&misc_mtx); |
| 120 | 120 | ||
| @@ -141,17 +141,11 @@ static int misc_open(struct inode * inode, struct file * file) | |||
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | err = 0; | 143 | err = 0; |
| 144 | old_fops = file->f_op; | 144 | replace_fops(file, new_fops); |
| 145 | file->f_op = new_fops; | ||
| 146 | if (file->f_op->open) { | 145 | if (file->f_op->open) { |
| 147 | file->private_data = c; | 146 | file->private_data = c; |
| 148 | err=file->f_op->open(inode,file); | 147 | err = file->f_op->open(inode,file); |
| 149 | if (err) { | ||
| 150 | fops_put(file->f_op); | ||
| 151 | file->f_op = fops_get(old_fops); | ||
| 152 | } | ||
| 153 | } | 148 | } |
| 154 | fops_put(old_fops); | ||
| 155 | fail: | 149 | fail: |
| 156 | mutex_unlock(&misc_mtx); | 150 | mutex_unlock(&misc_mtx); |
| 157 | return err; | 151 | return err; |
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index 3f84277d7036..22d14ecbd3ec 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c | |||
| @@ -148,7 +148,7 @@ int drm_stub_open(struct inode *inode, struct file *filp) | |||
| 148 | struct drm_minor *minor; | 148 | struct drm_minor *minor; |
| 149 | int minor_id = iminor(inode); | 149 | int minor_id = iminor(inode); |
| 150 | int err = -ENODEV; | 150 | int err = -ENODEV; |
| 151 | const struct file_operations *old_fops; | 151 | const struct file_operations *new_fops; |
| 152 | 152 | ||
| 153 | DRM_DEBUG("\n"); | 153 | DRM_DEBUG("\n"); |
| 154 | 154 | ||
| @@ -163,18 +163,13 @@ int drm_stub_open(struct inode *inode, struct file *filp) | |||
| 163 | if (drm_device_is_unplugged(dev)) | 163 | if (drm_device_is_unplugged(dev)) |
| 164 | goto out; | 164 | goto out; |
| 165 | 165 | ||
| 166 | old_fops = filp->f_op; | 166 | new_fops = fops_get(dev->driver->fops); |
| 167 | filp->f_op = fops_get(dev->driver->fops); | 167 | if (!new_fops) |
| 168 | if (filp->f_op == NULL) { | ||
| 169 | filp->f_op = old_fops; | ||
| 170 | goto out; | 168 | goto out; |
| 171 | } | ||
| 172 | if (filp->f_op->open && (err = filp->f_op->open(inode, filp))) { | ||
| 173 | fops_put(filp->f_op); | ||
| 174 | filp->f_op = fops_get(old_fops); | ||
| 175 | } | ||
| 176 | fops_put(old_fops); | ||
| 177 | 169 | ||
| 170 | replace_fops(filp, new_fops); | ||
| 171 | if (filp->f_op->open) | ||
| 172 | err = filp->f_op->open(inode, filp); | ||
| 178 | out: | 173 | out: |
| 179 | mutex_unlock(&drm_global_mutex); | 174 | mutex_unlock(&drm_global_mutex); |
| 180 | return err; | 175 | return err; |
diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c index 0b4616b87195..c0363f1b6c90 100644 --- a/drivers/media/dvb-core/dmxdev.c +++ b/drivers/media/dvb-core/dmxdev.c | |||
| @@ -206,8 +206,6 @@ static int dvb_dvr_release(struct inode *inode, struct file *file) | |||
| 206 | /* TODO */ | 206 | /* TODO */ |
| 207 | dvbdev->users--; | 207 | dvbdev->users--; |
| 208 | if (dvbdev->users == 1 && dmxdev->exit == 1) { | 208 | if (dvbdev->users == 1 && dmxdev->exit == 1) { |
| 209 | fops_put(file->f_op); | ||
| 210 | file->f_op = NULL; | ||
| 211 | mutex_unlock(&dmxdev->mutex); | 209 | mutex_unlock(&dmxdev->mutex); |
| 212 | wake_up(&dvbdev->wait_queue); | 210 | wake_up(&dvbdev->wait_queue); |
| 213 | } else | 211 | } else |
| @@ -1120,8 +1118,6 @@ static int dvb_demux_release(struct inode *inode, struct file *file) | |||
| 1120 | mutex_lock(&dmxdev->mutex); | 1118 | mutex_lock(&dmxdev->mutex); |
| 1121 | dmxdev->dvbdev->users--; | 1119 | dmxdev->dvbdev->users--; |
| 1122 | if(dmxdev->dvbdev->users==1 && dmxdev->exit==1) { | 1120 | if(dmxdev->dvbdev->users==1 && dmxdev->exit==1) { |
| 1123 | fops_put(file->f_op); | ||
| 1124 | file->f_op = NULL; | ||
| 1125 | mutex_unlock(&dmxdev->mutex); | 1121 | mutex_unlock(&dmxdev->mutex); |
| 1126 | wake_up(&dmxdev->dvbdev->wait_queue); | 1122 | wake_up(&dmxdev->dvbdev->wait_queue); |
| 1127 | } else | 1123 | } else |
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 401ef64f92c6..983db75de350 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c | |||
| @@ -74,22 +74,15 @@ static int dvb_device_open(struct inode *inode, struct file *file) | |||
| 74 | 74 | ||
| 75 | if (dvbdev && dvbdev->fops) { | 75 | if (dvbdev && dvbdev->fops) { |
| 76 | int err = 0; | 76 | int err = 0; |
| 77 | const struct file_operations *old_fops; | 77 | const struct file_operations *new_fops; |
| 78 | 78 | ||
| 79 | file->private_data = dvbdev; | 79 | new_fops = fops_get(dvbdev->fops); |
| 80 | old_fops = file->f_op; | 80 | if (!new_fops) |
| 81 | file->f_op = fops_get(dvbdev->fops); | ||
| 82 | if (file->f_op == NULL) { | ||
| 83 | file->f_op = old_fops; | ||
| 84 | goto fail; | 81 | goto fail; |
| 85 | } | 82 | file->private_data = dvbdev; |
| 86 | if(file->f_op->open) | 83 | replace_fops(file, new_fops); |
| 84 | if (file->f_op->open) | ||
| 87 | err = file->f_op->open(inode,file); | 85 | err = file->f_op->open(inode,file); |
| 88 | if (err) { | ||
| 89 | fops_put(file->f_op); | ||
| 90 | file->f_op = fops_get(old_fops); | ||
| 91 | } | ||
| 92 | fops_put(old_fops); | ||
| 93 | up_read(&minor_rwsem); | 86 | up_read(&minor_rwsem); |
| 94 | mutex_unlock(&dvbdev_mutex); | 87 | mutex_unlock(&dvbdev_mutex); |
| 95 | return err; | 88 | return err; |
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index bdc1d15369f8..d1c7de92cfdf 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
| @@ -575,7 +575,7 @@ static int alloc_device(struct nandsim *ns) | |||
| 575 | cfile = filp_open(cache_file, O_CREAT | O_RDWR | O_LARGEFILE, 0600); | 575 | cfile = filp_open(cache_file, O_CREAT | O_RDWR | O_LARGEFILE, 0600); |
| 576 | if (IS_ERR(cfile)) | 576 | if (IS_ERR(cfile)) |
| 577 | return PTR_ERR(cfile); | 577 | return PTR_ERR(cfile); |
| 578 | if (!cfile->f_op || (!cfile->f_op->read && !cfile->f_op->aio_read)) { | 578 | if (!cfile->f_op->read && !cfile->f_op->aio_read) { |
| 579 | NS_ERR("alloc_device: cache file not readable\n"); | 579 | NS_ERR("alloc_device: cache file not readable\n"); |
| 580 | err = -EINVAL; | 580 | err = -EINVAL; |
| 581 | goto err_close; | 581 | goto err_close; |
diff --git a/drivers/staging/comedi/comedi_compat32.c b/drivers/staging/comedi/comedi_compat32.c index 2dfb06aedb15..1e9da405d833 100644 --- a/drivers/staging/comedi/comedi_compat32.c +++ b/drivers/staging/comedi/comedi_compat32.c | |||
| @@ -86,9 +86,6 @@ struct comedi32_insnlist_struct { | |||
| 86 | static int translated_ioctl(struct file *file, unsigned int cmd, | 86 | static int translated_ioctl(struct file *file, unsigned int cmd, |
| 87 | unsigned long arg) | 87 | unsigned long arg) |
| 88 | { | 88 | { |
| 89 | if (!file->f_op) | ||
| 90 | return -ENOTTY; | ||
| 91 | |||
| 92 | if (file->f_op->unlocked_ioctl) | 89 | if (file->f_op->unlocked_ioctl) |
| 93 | return file->f_op->unlocked_ioctl(file, cmd, arg); | 90 | return file->f_op->unlocked_ioctl(file, cmd, arg); |
| 94 | 91 | ||
diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 359c6c1ba68d..eefdb8d061b1 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h | |||
| @@ -105,8 +105,8 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, | |||
| 105 | #define ll_vfs_unlink(inode,entry,mnt) vfs_unlink(inode,entry) | 105 | #define ll_vfs_unlink(inode,entry,mnt) vfs_unlink(inode,entry) |
| 106 | #define ll_vfs_mknod(dir,entry,mnt,mode,dev) vfs_mknod(dir,entry,mode,dev) | 106 | #define ll_vfs_mknod(dir,entry,mnt,mode,dev) vfs_mknod(dir,entry,mode,dev) |
| 107 | #define ll_security_inode_unlink(dir,entry,mnt) security_inode_unlink(dir,entry) | 107 | #define ll_security_inode_unlink(dir,entry,mnt) security_inode_unlink(dir,entry) |
| 108 | #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \ | 108 | #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1,delegated_inode) \ |
| 109 | vfs_rename(old,old_dir,new,new_dir) | 109 | vfs_rename(old,old_dir,new,new_dir,delegated_inode) |
| 110 | 110 | ||
| 111 | #define cfs_bio_io_error(a,b) bio_io_error((a)) | 111 | #define cfs_bio_io_error(a,b) bio_io_error((a)) |
| 112 | #define cfs_bio_endio(a,b,c) bio_endio((a),(c)) | 112 | #define cfs_bio_endio(a,b,c) bio_endio((a),(c)) |
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 34815b550e71..90bbdae824ac 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c | |||
| @@ -83,7 +83,7 @@ int ll_unlock(__u32 mode, struct lustre_handle *lockh) | |||
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | 85 | ||
| 86 | /* called from iget5_locked->find_inode() under inode_lock spinlock */ | 86 | /* called from iget5_locked->find_inode() under inode_hash_lock spinlock */ |
| 87 | static int ll_test_inode(struct inode *inode, void *opaque) | 87 | static int ll_test_inode(struct inode *inode, void *opaque) |
| 88 | { | 88 | { |
| 89 | struct ll_inode_info *lli = ll_i2info(inode); | 89 | struct ll_inode_info *lli = ll_i2info(inode); |
diff --git a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c index 1ef06fea793b..09474e7553dd 100644 --- a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c +++ b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c | |||
| @@ -224,7 +224,7 @@ int lustre_rename(struct dentry *dir, struct vfsmount *mnt, | |||
| 224 | GOTO(put_old, err = PTR_ERR(dchild_new)); | 224 | GOTO(put_old, err = PTR_ERR(dchild_new)); |
| 225 | 225 | ||
| 226 | err = ll_vfs_rename(dir->d_inode, dchild_old, mnt, | 226 | err = ll_vfs_rename(dir->d_inode, dchild_old, mnt, |
| 227 | dir->d_inode, dchild_new, mnt); | 227 | dir->d_inode, dchild_new, mnt, NULL); |
| 228 | 228 | ||
| 229 | dput(dchild_new); | 229 | dput(dchild_new); |
| 230 | put_old: | 230 | put_old: |
diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 44f24fa31a34..36523edf6a71 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h | |||
| @@ -430,11 +430,6 @@ int ATOMIC_SUB_RETURN(ATOMIC_T *v, int i); | |||
| 430 | int ATOMIC_INC_RETURN(ATOMIC_T *v); | 430 | int ATOMIC_INC_RETURN(ATOMIC_T *v); |
| 431 | int ATOMIC_DEC_RETURN(ATOMIC_T *v); | 431 | int ATOMIC_DEC_RETURN(ATOMIC_T *v); |
| 432 | 432 | ||
| 433 | /* File operation APIs, just for linux now */ | ||
| 434 | int rtw_is_file_readable(char *path); | ||
| 435 | int rtw_retrive_from_file(char *path, u8 __user *buf, u32 sz); | ||
| 436 | int rtw_store_to_file(char *path, u8 __user *buf, u32 sz); | ||
| 437 | |||
| 438 | struct rtw_netdev_priv_indicator { | 433 | struct rtw_netdev_priv_indicator { |
| 439 | void *priv; | 434 | void *priv; |
| 440 | u32 sizeof_priv; | 435 | u32 sizeof_priv; |
diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c index 5a9e9e4558aa..a1ae72772c5f 100644 --- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c +++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c | |||
| @@ -356,214 +356,6 @@ inline int ATOMIC_DEC_RETURN(ATOMIC_T *v) | |||
| 356 | return atomic_dec_return(v); | 356 | return atomic_dec_return(v); |
| 357 | } | 357 | } |
| 358 | 358 | ||
| 359 | /* Open a file with the specific @param path, @param flag, @param mode | ||
| 360 | * @param fpp the pointer of struct file pointer to get struct file pointer while file opening is success | ||
| 361 | * @param path the path of the file to open | ||
| 362 | * @param flag file operation flags, please refer to linux document | ||
| 363 | * @param mode please refer to linux document | ||
| 364 | * @return Linux specific error code | ||
| 365 | */ | ||
| 366 | static int openfile(struct file **fpp, char *path, int flag, int mode) | ||
| 367 | { | ||
| 368 | struct file *fp; | ||
| 369 | |||
| 370 | fp = filp_open(path, flag, mode); | ||
| 371 | if (IS_ERR(fp)) { | ||
| 372 | *fpp = NULL; | ||
| 373 | return PTR_ERR(fp); | ||
| 374 | } else { | ||
| 375 | *fpp = fp; | ||
| 376 | return 0; | ||
| 377 | } | ||
| 378 | } | ||
| 379 | |||
| 380 | /* Close the file with the specific @param fp | ||
| 381 | * @param fp the pointer of struct file to close | ||
| 382 | * @return always 0 | ||
| 383 | */ | ||
| 384 | static int closefile(struct file *fp) | ||
| 385 | { | ||
| 386 | filp_close(fp, NULL); | ||
| 387 | return 0; | ||
| 388 | } | ||
| 389 | |||
| 390 | static int readfile(struct file *fp, char __user *buf, int len) | ||
| 391 | { | ||
| 392 | int rlen = 0, sum = 0; | ||
| 393 | |||
| 394 | if (!fp->f_op || !fp->f_op->read) | ||
| 395 | return -EPERM; | ||
| 396 | |||
| 397 | while (sum < len) { | ||
| 398 | rlen = fp->f_op->read(fp, buf+sum, len-sum, &fp->f_pos); | ||
| 399 | if (rlen > 0) | ||
| 400 | sum += rlen; | ||
| 401 | else if (0 != rlen) | ||
| 402 | return rlen; | ||
| 403 | else | ||
| 404 | break; | ||
| 405 | } | ||
| 406 | return sum; | ||
| 407 | } | ||
| 408 | |||
| 409 | static int writefile(struct file *fp, char __user *buf, int len) | ||
| 410 | { | ||
| 411 | int wlen = 0, sum = 0; | ||
| 412 | |||
| 413 | if (!fp->f_op || !fp->f_op->write) | ||
| 414 | return -EPERM; | ||
| 415 | |||
| 416 | while (sum < len) { | ||
| 417 | wlen = fp->f_op->write(fp, buf+sum, len-sum, &fp->f_pos); | ||
| 418 | if (wlen > 0) | ||
| 419 | sum += wlen; | ||
| 420 | else if (0 != wlen) | ||
| 421 | return wlen; | ||
| 422 | else | ||
| 423 | break; | ||
| 424 | } | ||
| 425 | return sum; | ||
| 426 | } | ||
| 427 | |||
| 428 | /* Test if the specifi @param path is a file and readable | ||
| 429 | * @param path the path of the file to test | ||
| 430 | * @return Linux specific error code | ||
| 431 | */ | ||
| 432 | static int isfilereadable(char *path) | ||
| 433 | { | ||
| 434 | struct file *fp; | ||
| 435 | int ret = 0; | ||
| 436 | mm_segment_t oldfs; | ||
| 437 | char __user buf; | ||
| 438 | |||
| 439 | fp = filp_open(path, O_RDONLY, 0); | ||
| 440 | if (IS_ERR(fp)) { | ||
| 441 | ret = PTR_ERR(fp); | ||
| 442 | } else { | ||
| 443 | oldfs = get_fs(); set_fs(get_ds()); | ||
| 444 | |||
| 445 | if (1 != readfile(fp, &buf, 1)) | ||
| 446 | ret = PTR_ERR(fp); | ||
| 447 | |||
| 448 | set_fs(oldfs); | ||
| 449 | filp_close(fp, NULL); | ||
| 450 | } | ||
| 451 | return ret; | ||
| 452 | } | ||
| 453 | |||
| 454 | /* Open the file with @param path and retrive the file content into | ||
| 455 | * memory starting from @param buf for @param sz at most | ||
| 456 | * @param path the path of the file to open and read | ||
| 457 | * @param buf the starting address of the buffer to store file content | ||
| 458 | * @param sz how many bytes to read at most | ||
| 459 | * @return the byte we've read, or Linux specific error code | ||
| 460 | */ | ||
| 461 | static int retrievefromfile(char *path, u8 __user *buf, u32 sz) | ||
| 462 | { | ||
| 463 | int ret = -1; | ||
| 464 | mm_segment_t oldfs; | ||
| 465 | struct file *fp; | ||
| 466 | |||
| 467 | if (path && buf) { | ||
| 468 | ret = openfile(&fp, path, O_RDONLY, 0); | ||
| 469 | if (0 == ret) { | ||
| 470 | DBG_88E("%s openfile path:%s fp =%p\n", __func__, | ||
| 471 | path, fp); | ||
| 472 | |||
| 473 | oldfs = get_fs(); set_fs(get_ds()); | ||
| 474 | ret = readfile(fp, buf, sz); | ||
| 475 | set_fs(oldfs); | ||
| 476 | closefile(fp); | ||
| 477 | |||
| 478 | DBG_88E("%s readfile, ret:%d\n", __func__, ret); | ||
| 479 | |||
| 480 | } else { | ||
| 481 | DBG_88E("%s openfile path:%s Fail, ret:%d\n", __func__, | ||
| 482 | path, ret); | ||
| 483 | } | ||
| 484 | } else { | ||
| 485 | DBG_88E("%s NULL pointer\n", __func__); | ||
| 486 | ret = -EINVAL; | ||
| 487 | } | ||
| 488 | return ret; | ||
| 489 | } | ||
| 490 | |||
| 491 | /* | ||
| 492 | * Open the file with @param path and wirte @param sz byte of data starting from @param buf into the file | ||
| 493 | * @param path the path of the file to open and write | ||
| 494 | * @param buf the starting address of the data to write into file | ||
| 495 | * @param sz how many bytes to write at most | ||
| 496 | * @return the byte we've written, or Linux specific error code | ||
| 497 | */ | ||
| 498 | static int storetofile(char *path, u8 __user *buf, u32 sz) | ||
| 499 | { | ||
| 500 | int ret = 0; | ||
| 501 | mm_segment_t oldfs; | ||
| 502 | struct file *fp; | ||
| 503 | |||
| 504 | if (path && buf) { | ||
| 505 | ret = openfile(&fp, path, O_CREAT|O_WRONLY, 0666); | ||
| 506 | if (0 == ret) { | ||
| 507 | DBG_88E("%s openfile path:%s fp =%p\n", __func__, path, fp); | ||
| 508 | |||
| 509 | oldfs = get_fs(); set_fs(get_ds()); | ||
| 510 | ret = writefile(fp, buf, sz); | ||
| 511 | set_fs(oldfs); | ||
| 512 | closefile(fp); | ||
| 513 | |||
| 514 | DBG_88E("%s writefile, ret:%d\n", __func__, ret); | ||
| 515 | |||
| 516 | } else { | ||
| 517 | DBG_88E("%s openfile path:%s Fail, ret:%d\n", __func__, path, ret); | ||
| 518 | } | ||
| 519 | } else { | ||
| 520 | DBG_88E("%s NULL pointer\n", __func__); | ||
| 521 | ret = -EINVAL; | ||
| 522 | } | ||
| 523 | return ret; | ||
| 524 | } | ||
| 525 | |||
| 526 | /* | ||
| 527 | * Test if the specifi @param path is a file and readable | ||
| 528 | * @param path the path of the file to test | ||
| 529 | * @return true or false | ||
| 530 | */ | ||
| 531 | int rtw_is_file_readable(char *path) | ||
| 532 | { | ||
| 533 | if (isfilereadable(path) == 0) | ||
| 534 | return true; | ||
| 535 | else | ||
| 536 | return false; | ||
| 537 | } | ||
| 538 | |||
| 539 | /* | ||
| 540 | * Open the file with @param path and retrive the file content into memory starting from @param buf for @param sz at most | ||
| 541 | * @param path the path of the file to open and read | ||
| 542 | * @param buf the starting address of the buffer to store file content | ||
| 543 | * @param sz how many bytes to read at most | ||
| 544 | * @return the byte we've read | ||
| 545 | */ | ||
| 546 | int rtw_retrive_from_file(char *path, u8 __user *buf, u32 sz) | ||
| 547 | { | ||
| 548 | int ret = retrievefromfile(path, buf, sz); | ||
| 549 | |||
| 550 | return ret >= 0 ? ret : 0; | ||
| 551 | } | ||
| 552 | |||
| 553 | /* | ||
| 554 | * Open the file with @param path and wirte @param sz byte of data | ||
| 555 | * starting from @param buf into the file | ||
| 556 | * @param path the path of the file to open and write | ||
| 557 | * @param buf the starting address of the data to write into file | ||
| 558 | * @param sz how many bytes to write at most | ||
| 559 | * @return the byte we've written | ||
| 560 | */ | ||
| 561 | int rtw_store_to_file(char *path, u8 __user *buf, u32 sz) | ||
| 562 | { | ||
| 563 | int ret = storetofile(path, buf, sz); | ||
| 564 | return ret >= 0 ? ret : 0; | ||
| 565 | } | ||
| 566 | |||
| 567 | struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, | 359 | struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, |
| 568 | void *old_priv) | 360 | void *old_priv) |
| 569 | { | 361 | { |
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 3bdfbf88a0ae..ea337a718cc1 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c | |||
| @@ -29,27 +29,19 @@ static DECLARE_RWSEM(minor_rwsem); | |||
| 29 | 29 | ||
| 30 | static int usb_open(struct inode *inode, struct file *file) | 30 | static int usb_open(struct inode *inode, struct file *file) |
| 31 | { | 31 | { |
| 32 | int minor = iminor(inode); | ||
| 33 | const struct file_operations *c; | ||
| 34 | int err = -ENODEV; | 32 | int err = -ENODEV; |
| 35 | const struct file_operations *old_fops, *new_fops = NULL; | 33 | const struct file_operations *new_fops; |
| 36 | 34 | ||
| 37 | down_read(&minor_rwsem); | 35 | down_read(&minor_rwsem); |
| 38 | c = usb_minors[minor]; | 36 | new_fops = fops_get(usb_minors[iminor(inode)]); |
| 39 | 37 | ||
| 40 | if (!c || !(new_fops = fops_get(c))) | 38 | if (!new_fops) |
| 41 | goto done; | 39 | goto done; |
| 42 | 40 | ||
| 43 | old_fops = file->f_op; | 41 | replace_fops(file, new_fops); |
| 44 | file->f_op = new_fops; | ||
| 45 | /* Curiouser and curiouser... NULL ->open() as "no device" ? */ | 42 | /* Curiouser and curiouser... NULL ->open() as "no device" ? */ |
| 46 | if (file->f_op->open) | 43 | if (file->f_op->open) |
| 47 | err = file->f_op->open(inode, file); | 44 | err = file->f_op->open(inode, file); |
| 48 | if (err) { | ||
| 49 | fops_put(file->f_op); | ||
| 50 | file->f_op = fops_get(old_fops); | ||
| 51 | } | ||
| 52 | fops_put(old_fops); | ||
| 53 | done: | 45 | done: |
| 54 | up_read(&minor_rwsem); | 46 | up_read(&minor_rwsem); |
| 55 | return err; | 47 | return err; |
