Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 148163
b: refs/heads/master
c: 021e223
h: refs/heads/master
i:
  148161: 7953923
  148159: 6d1780c
v: v3
  • Loading branch information
Boaz Harrosh authored and James Bottomley committed Jun 10, 2009
1 parent 4dbce09 commit ada4032
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 37 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fc2fac5b5f11e2bee3bf37215c8746236f5ea188
refs/heads/master: 021e2230d6c04d80289fceb2d21c9ce93a615b32
66 changes: 30 additions & 36 deletions trunk/drivers/scsi/osd/osd_uld.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <linux/device.h>
#include <linux/idr.h>
#include <linux/major.h>
#include <linux/file.h>

#include <scsi/scsi.h>
#include <scsi/scsi_driver.h>
Expand Down Expand Up @@ -175,63 +176,56 @@ static const struct file_operations osd_fops = {

struct osd_dev *osduld_path_lookup(const char *name)
{
struct path path;
struct inode *inode;
struct cdev *cdev;
struct osd_uld_device *uninitialized_var(oud);
struct osd_uld_device *oud;
struct osd_dev *od;
struct file *file;
int error;

if (!name || !*name) {
OSD_ERR("Mount with !path || !*path\n");
return ERR_PTR(-EINVAL);
}

error = kern_path(name, LOOKUP_FOLLOW, &path);
if (error) {
OSD_ERR("path_lookup of %s failed=>%d\n", name, error);
return ERR_PTR(error);
}
od = kzalloc(sizeof(*od), GFP_KERNEL);
if (!od)
return ERR_PTR(-ENOMEM);

inode = path.dentry->d_inode;
error = -EINVAL; /* Not the right device e.g osd_uld_device */
if (!S_ISCHR(inode->i_mode)) {
OSD_DEBUG("!S_ISCHR()\n");
goto out;
file = filp_open(name, O_RDWR, 0);
if (IS_ERR(file)) {
error = PTR_ERR(file);
goto free_od;
}

cdev = inode->i_cdev;
if (!cdev) {
OSD_ERR("Before mounting an OSD Based filesystem\n");
OSD_ERR(" user-mode must open+close the %s device\n", name);
OSD_ERR(" Example: bash: echo < %s\n", name);
goto out;
if (file->f_op != &osd_fops){
error = -EINVAL;
goto close_file;
}

/* The Magic wand. Is it our char-dev */
/* TODO: Support sg devices */
if (cdev->owner != THIS_MODULE) {
OSD_ERR("Error mounting %s - is not an OSD device\n", name);
goto out;
}
oud = file->private_data;

oud = container_of(cdev, struct osd_uld_device, cdev);
*od = oud->od;
od->file = file;

__uld_get(oud);
error = 0;
return od;

out:
path_put(&path);
return error ? ERR_PTR(error) : &oud->od;
close_file:
fput(file);
free_od:
kfree(od);
return ERR_PTR(error);
}
EXPORT_SYMBOL(osduld_path_lookup);

void osduld_put_device(struct osd_dev *od)
{
if (od) {
struct osd_uld_device *oud = container_of(od,
struct osd_uld_device, od);

__uld_put(oud);
if (od && !IS_ERR(od)) {
struct osd_uld_device *oud = od->file->private_data;

BUG_ON(od->scsi_device != oud->od.scsi_device);

fput(od->file);
kfree(od);
}
}
EXPORT_SYMBOL(osduld_put_device);
Expand Down
1 change: 1 addition & 0 deletions trunk/include/scsi/osd_initiator.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ enum osd_std_version {
*/
struct osd_dev {
struct scsi_device *scsi_device;
struct file *file;
unsigned def_timeout;

#ifdef OSD_VER1_SUPPORT
Expand Down

0 comments on commit ada4032

Please sign in to comment.