aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/osd/osd_uld.c63
-rw-r--r--include/scsi/osd_initiator.h4
2 files changed, 67 insertions, 0 deletions
diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index f6f9a99adaa6..cd4ca7cd9f75 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -173,6 +173,69 @@ static const struct file_operations osd_fops = {
173 .unlocked_ioctl = osd_uld_ioctl, 173 .unlocked_ioctl = osd_uld_ioctl,
174}; 174};
175 175
176struct osd_dev *osduld_path_lookup(const char *path)
177{
178 struct nameidata nd;
179 struct inode *inode;
180 struct cdev *cdev;
181 struct osd_uld_device *uninitialized_var(oud);
182 int error;
183
184 if (!path || !*path) {
185 OSD_ERR("Mount with !path || !*path\n");
186 return ERR_PTR(-EINVAL);
187 }
188
189 error = path_lookup(path, LOOKUP_FOLLOW, &nd);
190 if (error) {
191 OSD_ERR("path_lookup of %s faild=>%d\n", path, error);
192 return ERR_PTR(error);
193 }
194
195 inode = nd.path.dentry->d_inode;
196 error = -EINVAL; /* Not the right device e.g osd_uld_device */
197 if (!S_ISCHR(inode->i_mode)) {
198 OSD_DEBUG("!S_ISCHR()\n");
199 goto out;
200 }
201
202 cdev = inode->i_cdev;
203 if (!cdev) {
204 OSD_ERR("Before mounting an OSD Based filesystem\n");
205 OSD_ERR(" user-mode must open+close the %s device\n", path);
206 OSD_ERR(" Example: bash: echo < %s\n", path);
207 goto out;
208 }
209
210 /* The Magic wand. Is it our char-dev */
211 /* TODO: Support sg devices */
212 if (cdev->owner != THIS_MODULE) {
213 OSD_ERR("Error mounting %s - is not an OSD device\n", path);
214 goto out;
215 }
216
217 oud = container_of(cdev, struct osd_uld_device, cdev);
218
219 __uld_get(oud);
220 error = 0;
221
222out:
223 path_put(&nd.path);
224 return error ? ERR_PTR(error) : &oud->od;
225}
226EXPORT_SYMBOL(osduld_path_lookup);
227
228void osduld_put_device(struct osd_dev *od)
229{
230 if (od) {
231 struct osd_uld_device *oud = container_of(od,
232 struct osd_uld_device, od);
233
234 __uld_put(oud);
235 }
236}
237EXPORT_SYMBOL(osduld_put_device);
238
176/* 239/*
177 * Scsi Device operations 240 * Scsi Device operations
178 */ 241 */
diff --git a/include/scsi/osd_initiator.h b/include/scsi/osd_initiator.h
index a5dbbddcf73b..e84dc7aa5e34 100644
--- a/include/scsi/osd_initiator.h
+++ b/include/scsi/osd_initiator.h
@@ -33,6 +33,10 @@ struct osd_dev {
33 unsigned def_timeout; 33 unsigned def_timeout;
34}; 34};
35 35
36/* Retrieve/return osd_dev(s) for use by Kernel clients */
37struct osd_dev *osduld_path_lookup(const char *dev_name); /*Use IS_ERR/ERR_PTR*/
38void osduld_put_device(struct osd_dev *od);
39
36/* Add/remove test ioctls from external modules */ 40/* Add/remove test ioctls from external modules */
37typedef int (do_test_fn)(struct osd_dev *od, unsigned cmd, unsigned long arg); 41typedef int (do_test_fn)(struct osd_dev *od, unsigned cmd, unsigned long arg);
38int osduld_register_test(unsigned ioctl, do_test_fn *do_test); 42int osduld_register_test(unsigned ioctl, do_test_fn *do_test);