aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/osd/osd_uld.c63
1 files changed, 63 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 */