stream_open related patches for Linux 5.2

https://lore.kernel.org/linux-fsdevel/CAHk-=wg1tFzcaX2v9Z91vPJiBR486ddW5MtgDL02-fOen2F0Aw@mail.gmail.com/T/#m5b2d9ad3aeacea4bd6aa1964468ac074bf3aa5bf
 -----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCgAuFiEECVWwJCUO7/z+QjZbZsp4hBP2dUkFAlzR1UgQHGtpcnJAbmV4
 ZWRpLmNvbQAKCRBmyniEE/Z1SZBiEACGw1LzUmjV9eBYFjqaUkgX/Zfcu42D4Ek2
 8MuWnNdRabtpGQq0LccYlfoL3yH5xECp14IkCgJvkjqoZ3CcqWcv6uDxf0WtnUqZ
 wPx1RYZykb4RZj2A6/ndhInReP4AlXICyTVulKb+BquVkemMvmXX8k+bkr/msKfT
 9jdKWFIn+ANNABt3y2D7ywZvs9mkxIx+Fti+tVV4BFBeGfUuj4ArZBOHnngRnIk/
 XYlQ7FVzENSPSB+3GvL34jTGEzo8suPHKhHQlIhtcd5hwzVRZKE2sdVXsCc6/WbY
 YnT32gmT1/+cUuDl1mZSiQY5R4Xkb07k6/jNrdmjQpwmWbZu90cuRhb+JBXwnmjZ
 2Wgy3sfwYISDxtePukg1iYePlHlVlGTYqMo3AQrTBs/gEwCKWrsKQb98mRxlf1YK
 e2mdtmq6upYoorLFQesfRgrCg4GTBiPkrR3amXsFgJ2O5fhV6R98ZdGSv4kip19f
 ZNoc/t1EtKGwyAJwjINduv36E3RSHODWwSPtSnmSS1ieCGToY1SI3bVUkFM4C0tO
 5GMdSugHgXRGGVbTd/VftndJm6Wtj8b1j8c/1Vh04Q8qbKKJDRTDzAbK1v8oLaDh
 UXAKMIc8uY4caZy3/bTAB2Ou9dibrSi8Oc+LwZqJlwIcbkwn/IGNvmwtWv4ehorE
 N7EhCFZsFQ==
 =Mavg
 -----END PGP SIGNATURE-----

Merge tag 'stream_open-5.2' of https://lab.nexedi.com/kirr/linux

Pull stream_open conversion from Kirill Smelkov:

 - remove unnecessary double nonseekable_open from drivers/char/dtlk.c
   as noticed by Pavel Machek while reviewing nonseekable_open ->
   stream_open mass conversion.

 - the mass conversion patch promised in commit 10dce8af34 ("fs:
   stream_open - opener for stream-like files so that read and write can
   run simultaneously without deadlock") and is automatically generated
   by running

        $ make coccicheck MODE=patch COCCI=scripts/coccinelle/api/stream_open.cocci

   I've verified each generated change manually - that it is correct to
   convert - and each other nonseekable_open instance left - that it is
   either not correct to convert there, or that it is not converted due
   to current stream_open.cocci limitations. More details on this in the
   patch.

 - finally, change VFS to pass ppos=NULL into .read/.write for files
   that declare themselves streams. It was suggested by Rasmus Villemoes
   and makes sure that if ppos starts to be erroneously used in a stream
   file, such bug won't go unnoticed and will produce an oops instead of
   creating illusion of position change being taken into account.

   Note: this patch does not conflict with "fuse: Add FOPEN_STREAM to
   use stream_open()" that will be hopefully coming via FUSE tree,
   because fs/fuse/ uses new-style .read_iter/.write_iter, and for these
   accessors position is still passed as non-pointer kiocb.ki_pos .

* tag 'stream_open-5.2' of https://lab.nexedi.com/kirr/linux:
  vfs: pass ppos=NULL to .read()/.write() of FMODE_STREAM files
  *: convert stream-like files from nonseekable_open -> stream_open
  dtlk: remove double call to nonseekable_open
This commit is contained in:
Linus Torvalds 2019-05-07 12:15:13 -07:00
Родитель aa26690fab 438ab720c6
Коммит 41bc10cabe
105 изменённых файлов: 179 добавлений и 158 удалений

Просмотреть файл

@ -628,7 +628,7 @@ static int mpc52xx_wdt_open(struct inode *inode, struct file *file)
} }
file->private_data = mpc52xx_gpt_wdt; file->private_data = mpc52xx_gpt_wdt;
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int mpc52xx_wdt_release(struct inode *inode, struct file *file) static int mpc52xx_wdt_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -588,7 +588,7 @@ static int spufs_pipe_open(struct inode *inode, struct file *file)
struct spufs_inode_info *i = SPUFS_I(inode); struct spufs_inode_info *i = SPUFS_I(inode);
file->private_data = i->i_ctx; file->private_data = i->i_ctx;
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/* /*

Просмотреть файл

@ -85,7 +85,7 @@ static int harddog_open(struct inode *inode, struct file *file)
timer_alive = 1; timer_alive = 1;
spin_unlock(&lock); spin_unlock(&lock);
mutex_unlock(&harddog_mutex); mutex_unlock(&harddog_mutex);
return nonseekable_open(inode, file); return stream_open(inode, file);
err: err:
spin_unlock(&lock); spin_unlock(&lock);
mutex_unlock(&harddog_mutex); mutex_unlock(&harddog_mutex);

Просмотреть файл

@ -428,7 +428,7 @@ static int do_microcode_update(const void __user *buf, size_t size)
static int microcode_open(struct inode *inode, struct file *file) static int microcode_open(struct inode *inode, struct file *file)
{ {
return capable(CAP_SYS_RAWIO) ? nonseekable_open(inode, file) : -EPERM; return capable(CAP_SYS_RAWIO) ? stream_open(inode, file) : -EPERM;
} }
static ssize_t microcode_write(struct file *file, const char __user *buf, static ssize_t microcode_write(struct file *file, const char __user *buf,

Просмотреть файл

@ -212,7 +212,7 @@ static void ds1620_read_state(struct therm *therm)
static int ds1620_open(struct inode *inode, struct file *file) static int ds1620_open(struct inode *inode, struct file *file)
{ {
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static ssize_t static ssize_t

Просмотреть файл

@ -298,12 +298,11 @@ static int dtlk_open(struct inode *inode, struct file *file)
{ {
TRACE_TEXT("(dtlk_open"); TRACE_TEXT("(dtlk_open");
nonseekable_open(inode, file);
switch (iminor(inode)) { switch (iminor(inode)) {
case DTLK_MINOR: case DTLK_MINOR:
if (dtlk_busy) if (dtlk_busy)
return -EBUSY; return -EBUSY;
return nonseekable_open(inode, file); return stream_open(inode, file);
default: default:
return -ENXIO; return -ENXIO;

Просмотреть файл

@ -837,7 +837,7 @@ static int ipmi_open(struct inode *ino, struct file *filep)
* first heartbeat. * first heartbeat.
*/ */
ipmi_start_timer_on_heartbeat = 1; ipmi_start_timer_on_heartbeat = 1;
return nonseekable_open(ino, filep); return stream_open(ino, filep);
default: default:
return (-ENODEV); return (-ENODEV);

Просмотреть файл

@ -1682,7 +1682,7 @@ static int cmm_open(struct inode *inode, struct file *filp)
link->open = 1; /* only one open per device */ link->open = 1; /* only one open per device */
DEBUGP(2, dev, "<- cmm_open\n"); DEBUGP(2, dev, "<- cmm_open\n");
ret = nonseekable_open(inode, filp); ret = stream_open(inode, filp);
out: out:
mutex_unlock(&cmm_mutex); mutex_unlock(&cmm_mutex);
return ret; return ret;

Просмотреть файл

@ -92,7 +92,7 @@ static int scr24x_open(struct inode *inode, struct file *filp)
kref_get(&dev->refcnt); kref_get(&dev->refcnt);
filp->private_data = dev; filp->private_data = dev;
return nonseekable_open(inode, filp); return stream_open(inode, filp);
} }
static int scr24x_release(struct inode *inode, struct file *filp) static int scr24x_release(struct inode *inode, struct file *filp)

Просмотреть файл

@ -243,7 +243,7 @@ static int tanbac_tb0219_open(struct inode *inode, struct file *file)
case 16 ... 23: case 16 ... 23:
case 32 ... 39: case 32 ... 39:
case 48 ... 55: case 48 ... 55:
return nonseekable_open(inode, file); return stream_open(inode, file);
default: default:
break; break;
} }

Просмотреть файл

@ -303,7 +303,7 @@ nosy_open(struct inode *inode, struct file *file)
file->private_data = client; file->private_data = client;
return nonseekable_open(inode, file); return stream_open(inode, file);
fail: fail:
kfree(client); kfree(client);
lynx_put(lynx); lynx_put(lynx);

Просмотреть файл

@ -42,7 +42,7 @@ static int gnss_open(struct inode *inode, struct file *file)
get_device(&gdev->dev); get_device(&gdev->dev);
nonseekable_open(inode, file); stream_open(inode, file);
file->private_data = gdev; file->private_data = gdev;
down_write(&gdev->rwsem); down_write(&gdev->rwsem);

Просмотреть файл

@ -632,7 +632,7 @@ static int uhid_char_open(struct inode *inode, struct file *file)
INIT_WORK(&uhid->worker, uhid_device_add_worker); INIT_WORK(&uhid->worker, uhid_device_add_worker);
file->private_data = uhid; file->private_data = uhid;
nonseekable_open(inode, file); stream_open(inode, file);
return 0; return 0;
} }

Просмотреть файл

@ -837,7 +837,7 @@ static int watchdog_open(struct inode *inode, struct file *filp)
watchdog_trigger(data); watchdog_trigger(data);
filp->private_data = data; filp->private_data = data;
return nonseekable_open(inode, filp); return stream_open(inode, filp);
} }
static int watchdog_release(struct inode *inode, struct file *filp) static int watchdog_release(struct inode *inode, struct file *filp)

Просмотреть файл

@ -1341,7 +1341,7 @@ static int watchdog_open(struct inode *inode, struct file *filp)
/* Store pointer to data into filp's private data */ /* Store pointer to data into filp's private data */
filp->private_data = data; filp->private_data = data;
return nonseekable_open(inode, filp); return stream_open(inode, filp);
} }
static int watchdog_close(struct inode *inode, struct file *filp) static int watchdog_close(struct inode *inode, struct file *filp)

Просмотреть файл

@ -1175,7 +1175,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp)
file->filp = filp; file->filp = filp;
file->device = container_of(inode->i_cdev, struct ib_ucm_device, cdev); file->device = container_of(inode->i_cdev, struct ib_ucm_device, cdev);
return nonseekable_open(inode, filp); return stream_open(inode, filp);
} }
static int ib_ucm_close(struct inode *inode, struct file *filp) static int ib_ucm_close(struct inode *inode, struct file *filp)

Просмотреть файл

@ -1744,7 +1744,7 @@ static int ucma_open(struct inode *inode, struct file *filp)
filp->private_data = file; filp->private_data = file;
file->filp = filp; file->filp = filp;
return nonseekable_open(inode, filp); return stream_open(inode, filp);
} }
static int ucma_close(struct inode *inode, struct file *filp) static int ucma_close(struct inode *inode, struct file *filp)

Просмотреть файл

@ -985,7 +985,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
list_add_tail(&file->port_list, &port->file_list); list_add_tail(&file->port_list, &port->file_list);
nonseekable_open(inode, filp); stream_open(inode, filp);
out: out:
mutex_unlock(&port->file_mutex); mutex_unlock(&port->file_mutex);
return ret; return ret;

Просмотреть файл

@ -1132,7 +1132,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
setup_ufile_idr_uobject(file); setup_ufile_idr_uobject(file);
return nonseekable_open(inode, filp); return stream_open(inode, filp);
err_module: err_module:
module_put(ib_dev->owner); module_put(ib_dev->owner);

Просмотреть файл

@ -524,7 +524,7 @@ static int evdev_open(struct inode *inode, struct file *file)
goto err_free_client; goto err_free_client;
file->private_data = client; file->private_data = client;
nonseekable_open(inode, file); stream_open(inode, file);
return 0; return 0;

Просмотреть файл

@ -279,7 +279,7 @@ static int joydev_open(struct inode *inode, struct file *file)
goto err_free_client; goto err_free_client;
file->private_data = client; file->private_data = client;
nonseekable_open(inode, file); stream_open(inode, file);
return 0; return 0;

Просмотреть файл

@ -398,7 +398,7 @@ static int uinput_open(struct inode *inode, struct file *file)
newdev->state = UIST_NEW_DEVICE; newdev->state = UIST_NEW_DEVICE;
file->private_data = newdev; file->private_data = newdev;
nonseekable_open(inode, file); stream_open(inode, file);
return 0; return 0;
} }

Просмотреть файл

@ -960,7 +960,7 @@ static int capi_open(struct inode *inode, struct file *file)
list_add_tail(&cdev->list, &capidev_list); list_add_tail(&cdev->list, &capidev_list);
mutex_unlock(&capidev_list_lock); mutex_unlock(&capidev_list_lock);
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int capi_release(struct inode *inode, struct file *file) static int capi_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -74,7 +74,7 @@ static int uleds_open(struct inode *inode, struct file *file)
udev->state = ULEDS_STATE_UNKNOWN; udev->state = ULEDS_STATE_UNKNOWN;
file->private_data = udev; file->private_data = udev;
nonseekable_open(inode, file); stream_open(inode, file);
return 0; return 0;
} }

Просмотреть файл

@ -195,7 +195,7 @@ static int ir_lirc_open(struct inode *inode, struct file *file)
list_add(&fh->list, &dev->lirc_fh); list_add(&fh->list, &dev->lirc_fh);
spin_unlock_irqrestore(&dev->lirc_fh_lock, flags); spin_unlock_irqrestore(&dev->lirc_fh_lock, flags);
nonseekable_open(inode, file); stream_open(inode, file);
return 0; return 0;
out_kfifo: out_kfifo:

Просмотреть файл

@ -390,7 +390,7 @@ static int switchtec_dev_open(struct inode *inode, struct file *filp)
return PTR_ERR(stuser); return PTR_ERR(stuser);
filp->private_data = stuser; filp->private_data = stuser;
nonseekable_open(inode, filp); stream_open(inode, filp);
dev_dbg(&stdev->dev, "%s: %p\n", __func__, stuser); dev_dbg(&stdev->dev, "%s: %p\n", __func__, stuser);

Просмотреть файл

@ -132,7 +132,7 @@ static int cros_ec_console_log_open(struct inode *inode, struct file *file)
{ {
file->private_data = inode->i_private; file->private_data = inode->i_private;
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static ssize_t cros_ec_console_log_read(struct file *file, char __user *buf, static ssize_t cros_ec_console_log_read(struct file *file, char __user *buf,

Просмотреть файл

@ -467,7 +467,7 @@ static int ds1374_wdt_open(struct inode *inode, struct file *file)
*/ */
wdt_is_open = 1; wdt_is_open = 1;
mutex_unlock(&ds1374->mutex); mutex_unlock(&ds1374->mutex);
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
return -ENODEV; return -ENODEV;
} }

Просмотреть файл

@ -802,7 +802,7 @@ static int wdt_open(struct inode *inode, struct file *file)
*/ */
wdt_is_open = 1; wdt_is_open = 1;
mutex_unlock(&m41t80_rtc_mutex); mutex_unlock(&m41t80_rtc_mutex);
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
return -ENODEV; return -ENODEV;
} }

Просмотреть файл

@ -486,7 +486,7 @@ fs3270_open(struct inode *inode, struct file *filp)
raw3270_del_view(&fp->view); raw3270_del_view(&fp->view);
goto out; goto out;
} }
nonseekable_open(inode, filp); stream_open(inode, filp);
filp->private_data = fp; filp->private_data = fp;
out: out:
mutex_unlock(&fs3270_mutex); mutex_unlock(&fs3270_mutex);

Просмотреть файл

@ -290,7 +290,7 @@ tapechar_open (struct inode *inode, struct file *filp)
rc = tape_open(device); rc = tape_open(device);
if (rc == 0) { if (rc == 0) {
filp->private_data = device; filp->private_data = device;
nonseekable_open(inode, filp); stream_open(inode, filp);
} else } else
tape_put_device(device); tape_put_device(device);

Просмотреть файл

@ -191,7 +191,7 @@ static ssize_t zcore_reipl_write(struct file *filp, const char __user *buf,
static int zcore_reipl_open(struct inode *inode, struct file *filp) static int zcore_reipl_open(struct inode *inode, struct file *filp)
{ {
return nonseekable_open(inode, filp); return stream_open(inode, filp);
} }
static int zcore_reipl_release(struct inode *inode, struct file *filp) static int zcore_reipl_release(struct inode *inode, struct file *filp)

Просмотреть файл

@ -525,7 +525,7 @@ static int zcrypt_open(struct inode *inode, struct file *filp)
filp->private_data = (void *) perms; filp->private_data = (void *) perms;
atomic_inc(&zcrypt_open_count); atomic_inc(&zcrypt_open_count);
return nonseekable_open(inode, filp); return stream_open(inode, filp);
} }
/** /**

Просмотреть файл

@ -593,7 +593,7 @@ static int spidev_open(struct inode *inode, struct file *filp)
spidev->users++; spidev->users++;
filp->private_data = spidev; filp->private_data = spidev;
nonseekable_open(inode, filp); stream_open(inode, filp);
mutex_unlock(&device_list_lock); mutex_unlock(&device_list_lock);
return 0; return 0;

Просмотреть файл

@ -971,7 +971,7 @@ static int pi433_open(struct inode *inode, struct file *filp)
/* instance data as context */ /* instance data as context */
filp->private_data = instance; filp->private_data = instance;
nonseekable_open(inode, filp); stream_open(inode, filp);
return 0; return 0;
} }

Просмотреть файл

@ -307,7 +307,7 @@ static int ld_usb_open(struct inode *inode, struct file *file)
int retval; int retval;
struct usb_interface *interface; struct usb_interface *interface;
nonseekable_open(inode, file); stream_open(inode, file);
subminor = iminor(inode); subminor = iminor(inode);
interface = usb_find_interface(&ld_usb_driver, subminor); interface = usb_find_interface(&ld_usb_driver, subminor);

Просмотреть файл

@ -200,7 +200,7 @@ static int acq_open(struct inode *inode, struct file *file)
/* Activate */ /* Activate */
acq_keepalive(); acq_keepalive();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int acq_close(struct inode *inode, struct file *file) static int acq_close(struct inode *inode, struct file *file)

Просмотреть файл

@ -199,7 +199,7 @@ static int advwdt_open(struct inode *inode, struct file *file)
*/ */
advwdt_ping(); advwdt_ping();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int advwdt_close(struct inode *inode, struct file *file) static int advwdt_close(struct inode *inode, struct file *file)

Просмотреть файл

@ -249,7 +249,7 @@ static int ali_open(struct inode *inode, struct file *file)
/* Activate */ /* Activate */
ali_start(); ali_start();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/* /*

Просмотреть файл

@ -214,7 +214,7 @@ static int fop_open(struct inode *inode, struct file *file)
return -EBUSY; return -EBUSY;
/* Good, fire up the show */ /* Good, fire up the show */
wdt_startup(); wdt_startup();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int fop_close(struct inode *inode, struct file *file) static int fop_close(struct inode *inode, struct file *file)

Просмотреть файл

@ -163,7 +163,7 @@ static int ar7_wdt_open(struct inode *inode, struct file *file)
ar7_wdt_enable_wdt(); ar7_wdt_enable_wdt();
expect_close = 0; expect_close = 0;
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int ar7_wdt_release(struct inode *inode, struct file *file) static int ar7_wdt_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -110,7 +110,7 @@ static int at91_wdt_open(struct inode *inode, struct file *file)
return -EBUSY; return -EBUSY;
at91_wdt_start(); at91_wdt_start();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/* /*

Просмотреть файл

@ -132,7 +132,7 @@ static int ath79_wdt_open(struct inode *inode, struct file *file)
clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags); clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags);
ath79_wdt_enable(); ath79_wdt_enable();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int ath79_wdt_release(struct inode *inode, struct file *file) static int ath79_wdt_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -116,7 +116,7 @@ static int bcm63xx_wdt_open(struct inode *inode, struct file *file)
return -EBUSY; return -EBUSY;
bcm63xx_wdt_start(); bcm63xx_wdt_start();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int bcm63xx_wdt_release(struct inode *inode, struct file *file) static int bcm63xx_wdt_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -140,7 +140,7 @@ static int cpu5wdt_open(struct inode *inode, struct file *file)
{ {
if (test_and_set_bit(0, &cpu5wdt_device.inuse)) if (test_and_set_bit(0, &cpu5wdt_device.inuse))
return -EBUSY; return -EBUSY;
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int cpu5wdt_release(struct inode *inode, struct file *file) static int cpu5wdt_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -394,7 +394,7 @@ static int cpwd_open(struct inode *inode, struct file *f)
mutex_unlock(&cpwd_mutex); mutex_unlock(&cpwd_mutex);
return nonseekable_open(inode, f); return stream_open(inode, f);
} }
static int cpwd_release(struct inode *inode, struct file *file) static int cpwd_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -316,7 +316,7 @@ static int eurwdt_open(struct inode *inode, struct file *file)
eurwdt_timeout = WDT_TIMEOUT; /* initial timeout */ eurwdt_timeout = WDT_TIMEOUT; /* initial timeout */
/* Activate the WDT */ /* Activate the WDT */
eurwdt_activate_timer(); eurwdt_activate_timer();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/** /**

Просмотреть файл

@ -525,7 +525,7 @@ static int watchdog_open(struct inode *inode, struct file *file)
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
watchdog.expect_close = 0; watchdog.expect_close = 0;
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int watchdog_release(struct inode *inode, struct file *file) static int watchdog_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -229,7 +229,7 @@ static int gef_wdt_open(struct inode *inode, struct file *file)
gef_wdt_handler_enable(); gef_wdt_handler_enable();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int gef_wdt_release(struct inode *inode, struct file *file) static int gef_wdt_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -92,7 +92,7 @@ static int geodewdt_open(struct inode *inode, struct file *file)
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
geodewdt_ping(); geodewdt_ping();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int geodewdt_release(struct inode *inode, struct file *file) static int geodewdt_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -238,7 +238,7 @@ static int ibwdt_open(struct inode *inode, struct file *file)
/* Activate */ /* Activate */
ibwdt_ping(); ibwdt_ping();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int ibwdt_close(struct inode *inode, struct file *file) static int ibwdt_close(struct inode *inode, struct file *file)

Просмотреть файл

@ -323,7 +323,7 @@ static int asr_open(struct inode *inode, struct file *file)
asr_toggle(); asr_toggle();
asr_enable(); asr_enable();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int asr_release(struct inode *inode, struct file *file) static int asr_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -77,7 +77,7 @@ static int indydog_open(struct inode *inode, struct file *file)
pr_info("Started watchdog timer\n"); pr_info("Started watchdog timer\n");
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int indydog_release(struct inode *inode, struct file *file) static int indydog_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -304,7 +304,7 @@ static int intel_scu_open(struct inode *inode, struct file *file)
if (watchdog_device.driver_closed) if (watchdog_device.driver_closed)
return -EPERM; return -EPERM;
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int intel_scu_release(struct inode *inode, struct file *file) static int intel_scu_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -101,7 +101,7 @@ static int iop_wdt_open(struct inode *inode, struct file *file)
clear_bit(WDT_OK_TO_CLOSE, &wdt_status); clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
wdt_enable(); wdt_enable();
set_bit(WDT_ENABLED, &wdt_status); set_bit(WDT_ENABLED, &wdt_status);
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static ssize_t iop_wdt_write(struct file *file, const char *data, size_t len, static ssize_t iop_wdt_write(struct file *file, const char *data, size_t len,

Просмотреть файл

@ -327,7 +327,7 @@ static int it8712f_wdt_open(struct inode *inode, struct file *file)
ret = it8712f_wdt_enable(); ret = it8712f_wdt_enable();
if (ret) if (ret)
return ret; return ret;
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int it8712f_wdt_release(struct inode *inode, struct file *file) static int it8712f_wdt_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -65,7 +65,7 @@ static int ixp4xx_wdt_open(struct inode *inode, struct file *file)
clear_bit(WDT_OK_TO_CLOSE, &wdt_status); clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
wdt_enable(); wdt_enable();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static ssize_t static ssize_t

Просмотреть файл

@ -142,7 +142,7 @@ static int ks8695_wdt_open(struct inode *inode, struct file *file)
return -EBUSY; return -EBUSY;
ks8695_wdt_start(); ks8695_wdt_start();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/* /*

Просмотреть файл

@ -85,7 +85,7 @@ static int m54xx_wdt_open(struct inode *inode, struct file *file)
clear_bit(WDT_OK_TO_CLOSE, &wdt_status); clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
wdt_enable(); wdt_enable();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static ssize_t m54xx_wdt_write(struct file *file, const char *data, static ssize_t m54xx_wdt_write(struct file *file, const char *data,

Просмотреть файл

@ -333,7 +333,7 @@ static int zf_open(struct inode *inode, struct file *file)
if (nowayout) if (nowayout)
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
zf_timer_on(); zf_timer_on();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int zf_close(struct inode *inode, struct file *file) static int zf_close(struct inode *inode, struct file *file)

Просмотреть файл

@ -150,7 +150,7 @@ static int mixcomwd_open(struct inode *inode, struct file *file)
mixcomwd_timer_alive = 0; mixcomwd_timer_alive = 0;
} }
} }
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int mixcomwd_release(struct inode *inode, struct file *file) static int mixcomwd_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -118,7 +118,7 @@ static int mtx1_wdt_open(struct inode *inode, struct file *file)
{ {
if (test_and_set_bit(0, &mtx1_wdt_device.inuse)) if (test_and_set_bit(0, &mtx1_wdt_device.inuse))
return -EBUSY; return -EBUSY;
return nonseekable_open(inode, file); return stream_open(inode, file);
} }

Просмотреть файл

@ -133,7 +133,7 @@ static int mv64x60_wdt_open(struct inode *inode, struct file *file)
mv64x60_wdt_handler_enable(); mv64x60_wdt_handler_enable();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int mv64x60_wdt_release(struct inode *inode, struct file *file) static int mv64x60_wdt_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -131,7 +131,7 @@ static int nuc900_wdt_open(struct inode *inode, struct file *file)
nuc900_wdt_start(); nuc900_wdt_start();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int nuc900_wdt_close(struct inode *inode, struct file *file) static int nuc900_wdt_close(struct inode *inode, struct file *file)

Просмотреть файл

@ -161,7 +161,7 @@ static int nv_tco_open(struct inode *inode, struct file *file)
/* Reload and activate timer */ /* Reload and activate timer */
tco_timer_keepalive(); tco_timer_keepalive();
tco_timer_start(); tco_timer_start();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int nv_tco_release(struct inode *inode, struct file *file) static int nv_tco_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -286,7 +286,7 @@ static int pc87413_open(struct inode *inode, struct file *file)
pr_info("Watchdog enabled. Timeout set to %d minute(s).\n", timeout); pr_info("Watchdog enabled. Timeout set to %d minute(s).\n", timeout);
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/** /**

Просмотреть файл

@ -695,7 +695,7 @@ static int pcwd_open(struct inode *inode, struct file *file)
/* Activate */ /* Activate */
pcwd_start(); pcwd_start();
pcwd_keepalive(); pcwd_keepalive();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int pcwd_close(struct inode *inode, struct file *file) static int pcwd_close(struct inode *inode, struct file *file)
@ -734,7 +734,7 @@ static int pcwd_temp_open(struct inode *inode, struct file *file)
if (!pcwd_private.supports_temp) if (!pcwd_private.supports_temp)
return -ENODEV; return -ENODEV;
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int pcwd_temp_close(struct inode *inode, struct file *file) static int pcwd_temp_close(struct inode *inode, struct file *file)

Просмотреть файл

@ -578,7 +578,7 @@ static int pcipcwd_open(struct inode *inode, struct file *file)
/* Activate */ /* Activate */
pcipcwd_start(); pcipcwd_start();
pcipcwd_keepalive(); pcipcwd_keepalive();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int pcipcwd_release(struct inode *inode, struct file *file) static int pcipcwd_release(struct inode *inode, struct file *file)
@ -620,7 +620,7 @@ static int pcipcwd_temp_open(struct inode *inode, struct file *file)
if (!pcipcwd_private.supports_temp) if (!pcipcwd_private.supports_temp)
return -ENODEV; return -ENODEV;
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int pcipcwd_temp_release(struct inode *inode, struct file *file) static int pcipcwd_temp_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -485,7 +485,7 @@ static int usb_pcwd_open(struct inode *inode, struct file *file)
/* Activate */ /* Activate */
usb_pcwd_start(usb_pcwd_device); usb_pcwd_start(usb_pcwd_device);
usb_pcwd_keepalive(usb_pcwd_device); usb_pcwd_keepalive(usb_pcwd_device);
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int usb_pcwd_release(struct inode *inode, struct file *file) static int usb_pcwd_release(struct inode *inode, struct file *file)
@ -524,7 +524,7 @@ static ssize_t usb_pcwd_temperature_read(struct file *file, char __user *data,
static int usb_pcwd_temperature_open(struct inode *inode, struct file *file) static int usb_pcwd_temperature_open(struct inode *inode, struct file *file)
{ {
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int usb_pcwd_temperature_release(struct inode *inode, struct file *file) static int usb_pcwd_temperature_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -118,7 +118,7 @@ static int pikawdt_open(struct inode *inode, struct file *file)
pikawdt_start(); pikawdt_start();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/* /*

Просмотреть файл

@ -116,7 +116,7 @@ static int pnx833x_wdt_open(struct inode *inode, struct file *file)
pr_info("Started watchdog timer\n"); pr_info("Started watchdog timer\n");
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int pnx833x_wdt_release(struct inode *inode, struct file *file) static int pnx833x_wdt_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -150,7 +150,7 @@ static int rc32434_wdt_open(struct inode *inode, struct file *file)
rc32434_wdt_start(); rc32434_wdt_start();
rc32434_wdt_ping(); rc32434_wdt_ping();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int rc32434_wdt_release(struct inode *inode, struct file *file) static int rc32434_wdt_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -142,7 +142,7 @@ static int rdc321x_wdt_open(struct inode *inode, struct file *file)
if (test_and_set_bit(0, &rdc321x_wdt_device.inuse)) if (test_and_set_bit(0, &rdc321x_wdt_device.inuse))
return -EBUSY; return -EBUSY;
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int rdc321x_wdt_release(struct inode *inode, struct file *file) static int rdc321x_wdt_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -76,7 +76,7 @@ static void riowd_writereg(struct riowd *p, u8 val, int index)
static int riowd_open(struct inode *inode, struct file *filp) static int riowd_open(struct inode *inode, struct file *filp)
{ {
nonseekable_open(inode, filp); stream_open(inode, filp);
return 0; return 0;
} }

Просмотреть файл

@ -59,7 +59,7 @@ static int sa1100dog_open(struct inode *inode, struct file *file)
writel_relaxed(OSSR_M3, OSSR); writel_relaxed(OSSR_M3, OSSR);
writel_relaxed(OWER_WME, OWER); writel_relaxed(OWER_WME, OWER);
writel_relaxed(readl_relaxed(OIER) | OIER_E3, OIER); writel_relaxed(readl_relaxed(OIER) | OIER_E3, OIER);
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/* /*

Просмотреть файл

@ -105,7 +105,7 @@ static const struct watchdog_info ident = {
*/ */
static int sbwdog_open(struct inode *inode, struct file *file) static int sbwdog_open(struct inode *inode, struct file *file)
{ {
nonseekable_open(inode, file); stream_open(inode, file);
if (test_and_set_bit(0, &sbwdog_gate)) if (test_and_set_bit(0, &sbwdog_gate))
return -EBUSY; return -EBUSY;
__module_get(THIS_MODULE); __module_get(THIS_MODULE);

Просмотреть файл

@ -208,7 +208,7 @@ static int fop_open(struct inode *inode, struct file *file)
/* Good, fire up the show */ /* Good, fire up the show */
wdt_startup(); wdt_startup();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int fop_close(struct inode *inode, struct file *file) static int fop_close(struct inode *inode, struct file *file)

Просмотреть файл

@ -136,7 +136,7 @@ static int fop_open(struct inode *inode, struct file *file)
wdt_enable(); wdt_enable();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int fop_close(struct inode *inode, struct file *file) static int fop_close(struct inode *inode, struct file *file)

Просмотреть файл

@ -271,7 +271,7 @@ static int sbc8360_open(struct inode *inode, struct file *file)
/* Activate and ping once to start the countdown */ /* Activate and ping once to start the countdown */
sbc8360_activate(); sbc8360_activate();
sbc8360_ping(); sbc8360_ping();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int sbc8360_close(struct inode *inode, struct file *file) static int sbc8360_close(struct inode *inode, struct file *file)

Просмотреть файл

@ -78,7 +78,7 @@ static int epx_c3_open(struct inode *inode, struct file *file)
epx_c3_alive = 1; epx_c3_alive = 1;
pr_info("Started watchdog timer\n"); pr_info("Started watchdog timer\n");
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int epx_c3_release(struct inode *inode, struct file *file) static int epx_c3_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -75,7 +75,7 @@ static int fitpc2_wdt_open(struct inode *inode, struct file *file)
wdt_enable(); wdt_enable();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static ssize_t fitpc2_wdt_write(struct file *file, const char *data, static ssize_t fitpc2_wdt_write(struct file *file, const char *data,

Просмотреть файл

@ -178,7 +178,7 @@ static int sc1200wdt_open(struct inode *inode, struct file *file)
sc1200wdt_start(); sc1200wdt_start();
pr_info("Watchdog enabled, timeout = %d min(s)", timeout); pr_info("Watchdog enabled, timeout = %d min(s)", timeout);
return nonseekable_open(inode, file); return stream_open(inode, file);
} }

Просмотреть файл

@ -258,7 +258,7 @@ static int fop_open(struct inode *inode, struct file *file)
/* Good, fire up the show */ /* Good, fire up the show */
wdt_startup(); wdt_startup();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int fop_close(struct inode *inode, struct file *file) static int fop_close(struct inode *inode, struct file *file)

Просмотреть файл

@ -316,7 +316,7 @@ static int sch311x_wdt_open(struct inode *inode, struct file *file)
* Activate * Activate
*/ */
sch311x_wdt_start(); sch311x_wdt_start();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int sch311x_wdt_close(struct inode *inode, struct file *file) static int sch311x_wdt_close(struct inode *inode, struct file *file)

Просмотреть файл

@ -102,7 +102,7 @@ static int scx200_wdt_open(struct inode *inode, struct file *file)
return -EBUSY; return -EBUSY;
scx200_wdt_enable(); scx200_wdt_enable();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int scx200_wdt_release(struct inode *inode, struct file *file) static int scx200_wdt_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -366,7 +366,7 @@ static int wb_smsc_wdt_open(struct inode *inode, struct file *file)
pr_info("Watchdog enabled. Timeout set to %d %s\n", pr_info("Watchdog enabled. Timeout set to %d %s\n",
timeout, (unit == UNIT_SECOND) ? "second(s)" : "minute(s)"); timeout, (unit == UNIT_SECOND) ? "second(s)" : "minute(s)");
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/* close => shut off the timer */ /* close => shut off the timer */

Просмотреть файл

@ -224,7 +224,7 @@ static int fop_open(struct inode *inode, struct file *file)
/* Good, fire up the show */ /* Good, fire up the show */
wdt_startup(); wdt_startup();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int fop_close(struct inode *inode, struct file *file) static int fop_close(struct inode *inode, struct file *file)

Просмотреть файл

@ -298,7 +298,7 @@ static int wdt_open(struct inode *inode, struct file *file)
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
wdt_start(); wdt_start();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int wdt_release(struct inode *inode, struct file *file) static int wdt_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -197,7 +197,7 @@ static int wafwdt_open(struct inode *inode, struct file *file)
* Activate * Activate
*/ */
wafwdt_start(); wafwdt_start();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int wafwdt_close(struct inode *inode, struct file *file) static int wafwdt_close(struct inode *inode, struct file *file)

Просмотреть файл

@ -825,7 +825,7 @@ static int watchdog_open(struct inode *inode, struct file *file)
kref_get(&wd_data->kref); kref_get(&wd_data->kref);
/* dev/watchdog is a virtual (and thus non-seekable) filesystem */ /* dev/watchdog is a virtual (and thus non-seekable) filesystem */
return nonseekable_open(inode, file); return stream_open(inode, file);
out_mod: out_mod:
module_put(wd_data->wdd->ops->owner); module_put(wd_data->wdd->ops->owner);

Просмотреть файл

@ -376,7 +376,7 @@ static int wdrtas_open(struct inode *inode, struct file *file)
wdrtas_timer_start(); wdrtas_timer_start();
wdrtas_timer_keepalive(); wdrtas_timer_keepalive();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/** /**
@ -442,7 +442,7 @@ static ssize_t wdrtas_temp_read(struct file *file, char __user *buf,
*/ */
static int wdrtas_temp_open(struct inode *inode, struct file *file) static int wdrtas_temp_open(struct inode *inode, struct file *file)
{ {
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/** /**

Просмотреть файл

@ -421,7 +421,7 @@ static int wdt_open(struct inode *inode, struct file *file)
* Activate * Activate
*/ */
wdt_start(); wdt_start();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/** /**
@ -481,7 +481,7 @@ static ssize_t wdt_temp_read(struct file *file, char __user *buf,
static int wdt_temp_open(struct inode *inode, struct file *file) static int wdt_temp_open(struct inode *inode, struct file *file)
{ {
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/** /**

Просмотреть файл

@ -101,7 +101,7 @@ static int watchdog_open(struct inode *inode, struct file *file)
ret = 0; ret = 0;
#endif #endif
nonseekable_open(inode, file); stream_open(inode, file);
return ret; return ret;
} }

Просмотреть файл

@ -273,7 +273,7 @@ static int wdt977_open(struct inode *inode, struct file *file)
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
wdt977_start(); wdt977_start();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
static int wdt977_release(struct inode *inode, struct file *file) static int wdt977_release(struct inode *inode, struct file *file)

Просмотреть файл

@ -461,7 +461,7 @@ static int wdtpci_open(struct inode *inode, struct file *file)
* Activate * Activate
*/ */
wdtpci_start(); wdtpci_start();
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/** /**
@ -524,7 +524,7 @@ static ssize_t wdtpci_temp_read(struct file *file, char __user *buf,
static int wdtpci_temp_open(struct inode *inode, struct file *file) static int wdtpci_temp_open(struct inode *inode, struct file *file)
{ {
return nonseekable_open(inode, file); return stream_open(inode, file);
} }
/** /**

Просмотреть файл

@ -664,7 +664,7 @@ static int evtchn_open(struct inode *inode, struct file *filp)
filp->private_data = u; filp->private_data = u;
return nonseekable_open(inode, filp); return stream_open(inode, filp);
} }
static int evtchn_release(struct inode *inode, struct file *filp) static int evtchn_release(struct inode *inode, struct file *filp)

Просмотреть файл

@ -1219,8 +1219,9 @@ EXPORT_SYMBOL(nonseekable_open);
/* /*
* stream_open is used by subsystems that want stream-like file descriptors. * stream_open is used by subsystems that want stream-like file descriptors.
* Such file descriptors are not seekable and don't have notion of position * Such file descriptors are not seekable and don't have notion of position
* (file.f_pos is always 0). Contrary to file descriptors of other regular * (file.f_pos is always 0 and ppos passed to .read()/.write() is always NULL).
* files, .read() and .write() can run simultaneously. * Contrary to file descriptors of other regular files, .read() and .write()
* can run simultaneously.
* *
* stream_open never fails and is marked to return int so that it could be * stream_open never fails and is marked to return int so that it could be
* directly used as file_operations.open . * directly used as file_operations.open .

Просмотреть файл

@ -365,29 +365,37 @@ out_putf:
int rw_verify_area(int read_write, struct file *file, const loff_t *ppos, size_t count) int rw_verify_area(int read_write, struct file *file, const loff_t *ppos, size_t count)
{ {
struct inode *inode; struct inode *inode;
loff_t pos;
int retval = -EINVAL; int retval = -EINVAL;
inode = file_inode(file); inode = file_inode(file);
if (unlikely((ssize_t) count < 0)) if (unlikely((ssize_t) count < 0))
return retval; return retval;
pos = *ppos;
if (unlikely(pos < 0)) { /*
if (!unsigned_offsets(file)) * ranged mandatory locking does not apply to streams - it makes sense
return retval; * only for files where position has a meaning.
if (count >= -pos) /* both values are in 0..LLONG_MAX */ */
return -EOVERFLOW; if (ppos) {
} else if (unlikely((loff_t) (pos + count) < 0)) { loff_t pos = *ppos;
if (!unsigned_offsets(file))
return retval; if (unlikely(pos < 0)) {
if (!unsigned_offsets(file))
return retval;
if (count >= -pos) /* both values are in 0..LLONG_MAX */
return -EOVERFLOW;
} else if (unlikely((loff_t) (pos + count) < 0)) {
if (!unsigned_offsets(file))
return retval;
}
if (unlikely(inode->i_flctx && mandatory_lock(inode))) {
retval = locks_mandatory_area(inode, file, pos, pos + count - 1,
read_write == READ ? F_RDLCK : F_WRLCK);
if (retval < 0)
return retval;
}
} }
if (unlikely(inode->i_flctx && mandatory_lock(inode))) {
retval = locks_mandatory_area(inode, file, pos, pos + count - 1,
read_write == READ ? F_RDLCK : F_WRLCK);
if (retval < 0)
return retval;
}
return security_file_permission(file, return security_file_permission(file,
read_write == READ ? MAY_READ : MAY_WRITE); read_write == READ ? MAY_READ : MAY_WRITE);
} }
@ -400,12 +408,13 @@ static ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, lo
ssize_t ret; ssize_t ret;
init_sync_kiocb(&kiocb, filp); init_sync_kiocb(&kiocb, filp);
kiocb.ki_pos = *ppos; kiocb.ki_pos = (ppos ? *ppos : 0);
iov_iter_init(&iter, READ, &iov, 1, len); iov_iter_init(&iter, READ, &iov, 1, len);
ret = call_read_iter(filp, &kiocb, &iter); ret = call_read_iter(filp, &kiocb, &iter);
BUG_ON(ret == -EIOCBQUEUED); BUG_ON(ret == -EIOCBQUEUED);
*ppos = kiocb.ki_pos; if (ppos)
*ppos = kiocb.ki_pos;
return ret; return ret;
} }
@ -468,12 +477,12 @@ static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t
ssize_t ret; ssize_t ret;
init_sync_kiocb(&kiocb, filp); init_sync_kiocb(&kiocb, filp);
kiocb.ki_pos = *ppos; kiocb.ki_pos = (ppos ? *ppos : 0);
iov_iter_init(&iter, WRITE, &iov, 1, len); iov_iter_init(&iter, WRITE, &iov, 1, len);
ret = call_write_iter(filp, &kiocb, &iter); ret = call_write_iter(filp, &kiocb, &iter);
BUG_ON(ret == -EIOCBQUEUED); BUG_ON(ret == -EIOCBQUEUED);
if (ret > 0) if (ret > 0 && ppos)
*ppos = kiocb.ki_pos; *ppos = kiocb.ki_pos;
return ret; return ret;
} }
@ -558,15 +567,10 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
return ret; return ret;
} }
static inline loff_t file_pos_read(struct file *file) /* file_ppos returns &file->f_pos or NULL if file is stream */
static inline loff_t *file_ppos(struct file *file)
{ {
return file->f_mode & FMODE_STREAM ? 0 : file->f_pos; return file->f_mode & FMODE_STREAM ? NULL : &file->f_pos;
}
static inline void file_pos_write(struct file *file, loff_t pos)
{
if ((file->f_mode & FMODE_STREAM) == 0)
file->f_pos = pos;
} }
ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count) ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count)
@ -575,10 +579,14 @@ ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count)
ssize_t ret = -EBADF; ssize_t ret = -EBADF;
if (f.file) { if (f.file) {
loff_t pos = file_pos_read(f.file); loff_t pos, *ppos = file_ppos(f.file);
ret = vfs_read(f.file, buf, count, &pos); if (ppos) {
if (ret >= 0) pos = *ppos;
file_pos_write(f.file, pos); ppos = &pos;
}
ret = vfs_read(f.file, buf, count, ppos);
if (ret >= 0 && ppos)
f.file->f_pos = pos;
fdput_pos(f); fdput_pos(f);
} }
return ret; return ret;
@ -595,10 +603,14 @@ ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count)
ssize_t ret = -EBADF; ssize_t ret = -EBADF;
if (f.file) { if (f.file) {
loff_t pos = file_pos_read(f.file); loff_t pos, *ppos = file_ppos(f.file);
ret = vfs_write(f.file, buf, count, &pos); if (ppos) {
if (ret >= 0) pos = *ppos;
file_pos_write(f.file, pos); ppos = &pos;
}
ret = vfs_write(f.file, buf, count, ppos);
if (ret >= 0 && ppos)
f.file->f_pos = pos;
fdput_pos(f); fdput_pos(f);
} }
@ -673,14 +685,15 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
ret = kiocb_set_rw_flags(&kiocb, flags); ret = kiocb_set_rw_flags(&kiocb, flags);
if (ret) if (ret)
return ret; return ret;
kiocb.ki_pos = *ppos; kiocb.ki_pos = (ppos ? *ppos : 0);
if (type == READ) if (type == READ)
ret = call_read_iter(filp, &kiocb, iter); ret = call_read_iter(filp, &kiocb, iter);
else else
ret = call_write_iter(filp, &kiocb, iter); ret = call_write_iter(filp, &kiocb, iter);
BUG_ON(ret == -EIOCBQUEUED); BUG_ON(ret == -EIOCBQUEUED);
*ppos = kiocb.ki_pos; if (ppos)
*ppos = kiocb.ki_pos;
return ret; return ret;
} }
@ -1013,10 +1026,14 @@ static ssize_t do_readv(unsigned long fd, const struct iovec __user *vec,
ssize_t ret = -EBADF; ssize_t ret = -EBADF;
if (f.file) { if (f.file) {
loff_t pos = file_pos_read(f.file); loff_t pos, *ppos = file_ppos(f.file);
ret = vfs_readv(f.file, vec, vlen, &pos, flags); if (ppos) {
if (ret >= 0) pos = *ppos;
file_pos_write(f.file, pos); ppos = &pos;
}
ret = vfs_readv(f.file, vec, vlen, ppos, flags);
if (ret >= 0 && ppos)
f.file->f_pos = pos;
fdput_pos(f); fdput_pos(f);
} }
@ -1033,10 +1050,14 @@ static ssize_t do_writev(unsigned long fd, const struct iovec __user *vec,
ssize_t ret = -EBADF; ssize_t ret = -EBADF;
if (f.file) { if (f.file) {
loff_t pos = file_pos_read(f.file); loff_t pos, *ppos = file_ppos(f.file);
ret = vfs_writev(f.file, vec, vlen, &pos, flags); if (ppos) {
if (ret >= 0) pos = *ppos;
file_pos_write(f.file, pos); ppos = &pos;
}
ret = vfs_writev(f.file, vec, vlen, ppos, flags);
if (ret >= 0 && ppos)
f.file->f_pos = pos;
fdput_pos(f); fdput_pos(f);
} }

Просмотреть файл

@ -77,7 +77,7 @@ static int batadv_socket_open(struct inode *inode, struct file *file)
batadv_debugfs_deprecated(file, ""); batadv_debugfs_deprecated(file, "");
nonseekable_open(inode, file); stream_open(inode, file);
socket_client = kmalloc(sizeof(*socket_client), GFP_KERNEL); socket_client = kmalloc(sizeof(*socket_client), GFP_KERNEL);
if (!socket_client) { if (!socket_client) {

Просмотреть файл

@ -102,7 +102,7 @@ static int batadv_log_open(struct inode *inode, struct file *file)
batadv_debugfs_deprecated(file, batadv_debugfs_deprecated(file,
"Use tracepoint batadv:batadv_dbg instead\n"); "Use tracepoint batadv:batadv_dbg instead\n");
nonseekable_open(inode, file); stream_open(inode, file);
file->private_data = inode->i_private; file->private_data = inode->i_private;
return 0; return 0;
} }

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше