~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/target/target_core_file.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include <linux/blkdev.h>
34
34
#include <linux/slab.h>
35
35
#include <linux/spinlock.h>
36
 
#include <linux/smp_lock.h>
37
36
#include <scsi/scsi.h>
38
37
#include <scsi/scsi_host.h>
39
38
 
135
134
        mm_segment_t old_fs;
136
135
        struct file *file;
137
136
        struct inode *inode = NULL;
138
 
        int dev_flags = 0, flags;
 
137
        int dev_flags = 0, flags, ret = -EINVAL;
139
138
 
140
139
        memset(&dev_limits, 0, sizeof(struct se_dev_limits));
141
140
 
147
146
        if (IS_ERR(dev_p)) {
148
147
                printk(KERN_ERR "getname(%s) failed: %lu\n",
149
148
                        fd_dev->fd_dev_name, IS_ERR(dev_p));
 
149
                ret = PTR_ERR(dev_p);
150
150
                goto fail;
151
151
        }
152
152
#if 0
159
159
#endif
160
160
/*      flags |= O_DIRECT; */
161
161
        /*
162
 
         * If fd_buffered_io=1 has not been set explictly (the default),
 
162
         * If fd_buffered_io=1 has not been set explicitly (the default),
163
163
         * use O_SYNC to force FILEIO writes to disk.
164
164
         */
165
165
        if (!(fd_dev->fbd_flags & FDBD_USE_BUFFERED_IO))
166
166
                flags |= O_SYNC;
167
167
 
168
168
        file = filp_open(dev_p, flags, 0600);
169
 
 
170
 
        if (IS_ERR(file) || !file || !file->f_dentry) {
 
169
        if (IS_ERR(file)) {
 
170
                printk(KERN_ERR "filp_open(%s) failed\n", dev_p);
 
171
                ret = PTR_ERR(file);
 
172
                goto fail;
 
173
        }
 
174
        if (!file || !file->f_dentry) {
171
175
                printk(KERN_ERR "filp_open(%s) failed\n", dev_p);
172
176
                goto fail;
173
177
        }
242
246
                fd_dev->fd_file = NULL;
243
247
        }
244
248
        putname(dev_p);
245
 
        return NULL;
 
249
        return ERR_PTR(ret);
246
250
}
247
251
 
248
252
/*      fd_free_device(): (Part of se_subsystem_api_t template)
510
514
static match_table_t tokens = {
511
515
        {Opt_fd_dev_name, "fd_dev_name=%s"},
512
516
        {Opt_fd_dev_size, "fd_dev_size=%s"},
513
 
        {Opt_fd_buffered_io, "fd_buffered_id=%d"},
 
517
        {Opt_fd_buffered_io, "fd_buffered_io=%d"},
514
518
        {Opt_err, NULL}
515
519
};
516
520
 
537
541
                token = match_token(ptr, tokens, args);
538
542
                switch (token) {
539
543
                case Opt_fd_dev_name:
 
544
                        arg_p = match_strdup(&args[0]);
 
545
                        if (!arg_p) {
 
546
                                ret = -ENOMEM;
 
547
                                break;
 
548
                        }
540
549
                        snprintf(fd_dev->fd_dev_name, FD_MAX_DEV_NAME,
541
 
                                        "%s", match_strdup(&args[0]));
 
550
                                        "%s", arg_p);
 
551
                        kfree(arg_p);
542
552
                        printk(KERN_INFO "FILEIO: Referencing Path: %s\n",
543
553
                                        fd_dev->fd_dev_name);
544
554
                        fd_dev->fbd_flags |= FBDF_HAS_PATH;
545
555
                        break;
546
556
                case Opt_fd_dev_size:
547
557
                        arg_p = match_strdup(&args[0]);
 
558
                        if (!arg_p) {
 
559
                                ret = -ENOMEM;
 
560
                                break;
 
561
                        }
548
562
                        ret = strict_strtoull(arg_p, 0, &fd_dev->fd_dev_size);
 
563
                        kfree(arg_p);
549
564
                        if (ret < 0) {
550
565
                                printk(KERN_ERR "strict_strtoull() failed for"
551
566
                                                " fd_dev_size=\n");