forked from luck/tmp_suning_uos_patched
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:
commit
41bc10cabe
|
@ -628,7 +628,7 @@ static int mpc52xx_wdt_open(struct inode *inode, struct file *file)
|
|||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -588,7 +588,7 @@ static int spufs_pipe_open(struct inode *inode, struct file *file)
|
|||
struct spufs_inode_info *i = SPUFS_I(inode);
|
||||
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;
|
||||
spin_unlock(&lock);
|
||||
mutex_unlock(&harddog_mutex);
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, file);
|
||||
err:
|
||||
spin_unlock(&lock);
|
||||
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)
|
||||
{
|
||||
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,
|
||||
|
|
|
@ -212,7 +212,7 @@ static void ds1620_read_state(struct therm *therm)
|
|||
|
||||
static int ds1620_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, file);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
|
|
|
@ -298,12 +298,11 @@ static int dtlk_open(struct inode *inode, struct file *file)
|
|||
{
|
||||
TRACE_TEXT("(dtlk_open");
|
||||
|
||||
nonseekable_open(inode, file);
|
||||
switch (iminor(inode)) {
|
||||
case DTLK_MINOR:
|
||||
if (dtlk_busy)
|
||||
return -EBUSY;
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, file);
|
||||
|
||||
default:
|
||||
return -ENXIO;
|
||||
|
|
|
@ -837,7 +837,7 @@ static int ipmi_open(struct inode *ino, struct file *filep)
|
|||
* first heartbeat.
|
||||
*/
|
||||
ipmi_start_timer_on_heartbeat = 1;
|
||||
return nonseekable_open(ino, filep);
|
||||
return stream_open(ino, filep);
|
||||
|
||||
default:
|
||||
return (-ENODEV);
|
||||
|
|
|
@ -1682,7 +1682,7 @@ static int cmm_open(struct inode *inode, struct file *filp)
|
|||
link->open = 1; /* only one open per device */
|
||||
|
||||
DEBUGP(2, dev, "<- cmm_open\n");
|
||||
ret = nonseekable_open(inode, filp);
|
||||
ret = stream_open(inode, filp);
|
||||
out:
|
||||
mutex_unlock(&cmm_mutex);
|
||||
return ret;
|
||||
|
|
|
@ -92,7 +92,7 @@ static int scr24x_open(struct inode *inode, struct file *filp)
|
|||
kref_get(&dev->refcnt);
|
||||
filp->private_data = dev;
|
||||
|
||||
return nonseekable_open(inode, filp);
|
||||
return stream_open(inode, 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 32 ... 39:
|
||||
case 48 ... 55:
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, file);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -303,7 +303,7 @@ nosy_open(struct inode *inode, struct file *file)
|
|||
|
||||
file->private_data = client;
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, file);
|
||||
fail:
|
||||
kfree(client);
|
||||
lynx_put(lynx);
|
||||
|
|
|
@ -42,7 +42,7 @@ static int gnss_open(struct inode *inode, struct file *file)
|
|||
|
||||
get_device(&gdev->dev);
|
||||
|
||||
nonseekable_open(inode, file);
|
||||
stream_open(inode, file);
|
||||
file->private_data = gdev;
|
||||
|
||||
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);
|
||||
|
||||
file->private_data = uhid;
|
||||
nonseekable_open(inode, file);
|
||||
stream_open(inode, file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -837,7 +837,7 @@ static int watchdog_open(struct inode *inode, struct file *filp)
|
|||
watchdog_trigger(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)
|
||||
|
|
|
@ -1341,7 +1341,7 @@ static int watchdog_open(struct inode *inode, struct file *filp)
|
|||
/* Store pointer to data into filp's private 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)
|
||||
|
|
|
@ -1175,7 +1175,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp)
|
|||
file->filp = filp;
|
||||
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)
|
||||
|
|
|
@ -1744,7 +1744,7 @@ static int ucma_open(struct inode *inode, struct file *filp)
|
|||
filp->private_data = file;
|
||||
file->filp = filp;
|
||||
|
||||
return nonseekable_open(inode, filp);
|
||||
return stream_open(inode, 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);
|
||||
|
||||
nonseekable_open(inode, filp);
|
||||
stream_open(inode, filp);
|
||||
out:
|
||||
mutex_unlock(&port->file_mutex);
|
||||
return ret;
|
||||
|
|
|
@ -1132,7 +1132,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
|
|||
|
||||
setup_ufile_idr_uobject(file);
|
||||
|
||||
return nonseekable_open(inode, filp);
|
||||
return stream_open(inode, filp);
|
||||
|
||||
err_module:
|
||||
module_put(ib_dev->owner);
|
||||
|
|
|
@ -524,7 +524,7 @@ static int evdev_open(struct inode *inode, struct file *file)
|
|||
goto err_free_client;
|
||||
|
||||
file->private_data = client;
|
||||
nonseekable_open(inode, file);
|
||||
stream_open(inode, file);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ static int joydev_open(struct inode *inode, struct file *file)
|
|||
goto err_free_client;
|
||||
|
||||
file->private_data = client;
|
||||
nonseekable_open(inode, file);
|
||||
stream_open(inode, file);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -398,7 +398,7 @@ static int uinput_open(struct inode *inode, struct file *file)
|
|||
newdev->state = UIST_NEW_DEVICE;
|
||||
|
||||
file->private_data = newdev;
|
||||
nonseekable_open(inode, file);
|
||||
stream_open(inode, file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -960,7 +960,7 @@ static int capi_open(struct inode *inode, struct file *file)
|
|||
list_add_tail(&cdev->list, &capidev_list);
|
||||
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)
|
||||
|
|
|
@ -74,7 +74,7 @@ static int uleds_open(struct inode *inode, struct file *file)
|
|||
udev->state = ULEDS_STATE_UNKNOWN;
|
||||
|
||||
file->private_data = udev;
|
||||
nonseekable_open(inode, file);
|
||||
stream_open(inode, file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ static int ir_lirc_open(struct inode *inode, struct file *file)
|
|||
list_add(&fh->list, &dev->lirc_fh);
|
||||
spin_unlock_irqrestore(&dev->lirc_fh_lock, flags);
|
||||
|
||||
nonseekable_open(inode, file);
|
||||
stream_open(inode, file);
|
||||
|
||||
return 0;
|
||||
out_kfifo:
|
||||
|
|
|
@ -390,7 +390,7 @@ static int switchtec_dev_open(struct inode *inode, struct file *filp)
|
|||
return PTR_ERR(stuser);
|
||||
|
||||
filp->private_data = stuser;
|
||||
nonseekable_open(inode, filp);
|
||||
stream_open(inode, filp);
|
||||
|
||||
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;
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, file);
|
||||
}
|
||||
|
||||
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;
|
||||
mutex_unlock(&ds1374->mutex);
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, file);
|
||||
}
|
||||
return -ENODEV;
|
||||
}
|
||||
|
|
|
@ -802,7 +802,7 @@ static int wdt_open(struct inode *inode, struct file *file)
|
|||
*/
|
||||
wdt_is_open = 1;
|
||||
mutex_unlock(&m41t80_rtc_mutex);
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, file);
|
||||
}
|
||||
return -ENODEV;
|
||||
}
|
||||
|
|
|
@ -486,7 +486,7 @@ fs3270_open(struct inode *inode, struct file *filp)
|
|||
raw3270_del_view(&fp->view);
|
||||
goto out;
|
||||
}
|
||||
nonseekable_open(inode, filp);
|
||||
stream_open(inode, filp);
|
||||
filp->private_data = fp;
|
||||
out:
|
||||
mutex_unlock(&fs3270_mutex);
|
||||
|
|
|
@ -290,7 +290,7 @@ tapechar_open (struct inode *inode, struct file *filp)
|
|||
rc = tape_open(device);
|
||||
if (rc == 0) {
|
||||
filp->private_data = device;
|
||||
nonseekable_open(inode, filp);
|
||||
stream_open(inode, filp);
|
||||
} else
|
||||
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)
|
||||
{
|
||||
return nonseekable_open(inode, filp);
|
||||
return stream_open(inode, 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;
|
||||
|
||||
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++;
|
||||
filp->private_data = spidev;
|
||||
nonseekable_open(inode, filp);
|
||||
stream_open(inode, filp);
|
||||
|
||||
mutex_unlock(&device_list_lock);
|
||||
return 0;
|
||||
|
|
|
@ -971,7 +971,7 @@ static int pi433_open(struct inode *inode, struct file *filp)
|
|||
|
||||
/* instance data as context */
|
||||
filp->private_data = instance;
|
||||
nonseekable_open(inode, filp);
|
||||
stream_open(inode, filp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ static int ld_usb_open(struct inode *inode, struct file *file)
|
|||
int retval;
|
||||
struct usb_interface *interface;
|
||||
|
||||
nonseekable_open(inode, file);
|
||||
stream_open(inode, file);
|
||||
subminor = iminor(inode);
|
||||
|
||||
interface = usb_find_interface(&ld_usb_driver, subminor);
|
||||
|
|
|
@ -200,7 +200,7 @@ static int acq_open(struct inode *inode, struct file *file)
|
|||
|
||||
/* Activate */
|
||||
acq_keepalive();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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 */
|
||||
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;
|
||||
/* Good, fire up the show */
|
||||
wdt_startup();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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();
|
||||
expect_close = 0;
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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;
|
||||
|
||||
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);
|
||||
ath79_wdt_enable();
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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;
|
||||
|
||||
bcm63xx_wdt_start();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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))
|
||||
return -EBUSY;
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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);
|
||||
|
||||
return nonseekable_open(inode, f);
|
||||
return stream_open(inode, f);
|
||||
}
|
||||
|
||||
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 */
|
||||
/* Activate the WDT */
|
||||
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);
|
||||
|
||||
watchdog.expect_close = 0;
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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();
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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);
|
||||
|
||||
geodewdt_ping();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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 */
|
||||
ibwdt_ping();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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_enable();
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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");
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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)
|
||||
return -EPERM;
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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);
|
||||
wdt_enable();
|
||||
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,
|
||||
|
|
|
@ -327,7 +327,7 @@ static int it8712f_wdt_open(struct inode *inode, struct file *file)
|
|||
ret = it8712f_wdt_enable();
|
||||
if (ret)
|
||||
return ret;
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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);
|
||||
wdt_enable();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, file);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
|
|
|
@ -142,7 +142,7 @@ static int ks8695_wdt_open(struct inode *inode, struct file *file)
|
|||
return -EBUSY;
|
||||
|
||||
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);
|
||||
wdt_enable();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, file);
|
||||
}
|
||||
|
||||
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)
|
||||
__module_get(THIS_MODULE);
|
||||
zf_timer_on();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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;
|
||||
}
|
||||
}
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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))
|
||||
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();
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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();
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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 */
|
||||
tco_timer_keepalive();
|
||||
tco_timer_start();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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);
|
||||
|
||||
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 */
|
||||
pcwd_start();
|
||||
pcwd_keepalive();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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)
|
||||
return -ENODEV;
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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 */
|
||||
pcipcwd_start();
|
||||
pcipcwd_keepalive();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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)
|
||||
return -ENODEV;
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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 */
|
||||
usb_pcwd_start(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)
|
||||
|
@ -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)
|
||||
{
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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();
|
||||
|
||||
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");
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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_ping();
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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))
|
||||
return -EBUSY;
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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)
|
||||
{
|
||||
nonseekable_open(inode, filp);
|
||||
stream_open(inode, filp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ static int sa1100dog_open(struct inode *inode, struct file *file)
|
|||
writel_relaxed(OSSR_M3, OSSR);
|
||||
writel_relaxed(OWER_WME, OWER);
|
||||
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)
|
||||
{
|
||||
nonseekable_open(inode, file);
|
||||
stream_open(inode, file);
|
||||
if (test_and_set_bit(0, &sbwdog_gate))
|
||||
return -EBUSY;
|
||||
__module_get(THIS_MODULE);
|
||||
|
|
|
@ -208,7 +208,7 @@ static int fop_open(struct inode *inode, struct file *file)
|
|||
|
||||
/* Good, fire up the show */
|
||||
wdt_startup();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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();
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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 */
|
||||
sbc8360_activate();
|
||||
sbc8360_ping();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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;
|
||||
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)
|
||||
|
|
|
@ -75,7 +75,7 @@ static int fitpc2_wdt_open(struct inode *inode, struct file *file)
|
|||
|
||||
wdt_enable();
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, file);
|
||||
}
|
||||
|
||||
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();
|
||||
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 */
|
||||
wdt_startup();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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
|
||||
*/
|
||||
sch311x_wdt_start();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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;
|
||||
scx200_wdt_enable();
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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",
|
||||
timeout, (unit == UNIT_SECOND) ? "second(s)" : "minute(s)");
|
||||
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, file);
|
||||
}
|
||||
|
||||
/* close => shut off the timer */
|
||||
|
|
|
@ -224,7 +224,7 @@ static int fop_open(struct inode *inode, struct file *file)
|
|||
|
||||
/* Good, fire up the show */
|
||||
wdt_startup();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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);
|
||||
|
||||
wdt_start();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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
|
||||
*/
|
||||
wafwdt_start();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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);
|
||||
|
||||
/* dev/watchdog is a virtual (and thus non-seekable) filesystem */
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, file);
|
||||
|
||||
out_mod:
|
||||
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_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)
|
||||
{
|
||||
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
|
||||
*/
|
||||
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)
|
||||
{
|
||||
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;
|
||||
#endif
|
||||
nonseekable_open(inode, file);
|
||||
stream_open(inode, file);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ static int wdt977_open(struct inode *inode, struct file *file)
|
|||
__module_get(THIS_MODULE);
|
||||
|
||||
wdt977_start();
|
||||
return nonseekable_open(inode, file);
|
||||
return stream_open(inode, 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
|
||||
*/
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
return nonseekable_open(inode, filp);
|
||||
return stream_open(inode, 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.
|
||||
* 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
|
||||
* files, .read() and .write() can run simultaneously.
|
||||
* (file.f_pos is always 0 and ppos passed to .read()/.write() is always NULL).
|
||||
* 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
|
||||
* directly used as file_operations.open .
|
||||
|
|
113
fs/read_write.c
113
fs/read_write.c
|
@ -365,29 +365,37 @@ SYSCALL_DEFINE5(llseek, unsigned int, fd, unsigned long, offset_high,
|
|||
int rw_verify_area(int read_write, struct file *file, const loff_t *ppos, size_t count)
|
||||
{
|
||||
struct inode *inode;
|
||||
loff_t pos;
|
||||
int retval = -EINVAL;
|
||||
|
||||
inode = file_inode(file);
|
||||
if (unlikely((ssize_t) count < 0))
|
||||
return retval;
|
||||
pos = *ppos;
|
||||
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;
|
||||
|
||||
/*
|
||||
* ranged mandatory locking does not apply to streams - it makes sense
|
||||
* only for files where position has a meaning.
|
||||
*/
|
||||
if (ppos) {
|
||||
loff_t pos = *ppos;
|
||||
|
||||
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,
|
||||
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;
|
||||
|
||||
init_sync_kiocb(&kiocb, filp);
|
||||
kiocb.ki_pos = *ppos;
|
||||
kiocb.ki_pos = (ppos ? *ppos : 0);
|
||||
iov_iter_init(&iter, READ, &iov, 1, len);
|
||||
|
||||
ret = call_read_iter(filp, &kiocb, &iter);
|
||||
BUG_ON(ret == -EIOCBQUEUED);
|
||||
*ppos = kiocb.ki_pos;
|
||||
if (ppos)
|
||||
*ppos = kiocb.ki_pos;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -468,12 +477,12 @@ static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t
|
|||
ssize_t ret;
|
||||
|
||||
init_sync_kiocb(&kiocb, filp);
|
||||
kiocb.ki_pos = *ppos;
|
||||
kiocb.ki_pos = (ppos ? *ppos : 0);
|
||||
iov_iter_init(&iter, WRITE, &iov, 1, len);
|
||||
|
||||
ret = call_write_iter(filp, &kiocb, &iter);
|
||||
BUG_ON(ret == -EIOCBQUEUED);
|
||||
if (ret > 0)
|
||||
if (ret > 0 && ppos)
|
||||
*ppos = kiocb.ki_pos;
|
||||
return ret;
|
||||
}
|
||||
|
@ -558,15 +567,10 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
|
|||
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;
|
||||
}
|
||||
|
||||
static inline void file_pos_write(struct file *file, loff_t pos)
|
||||
{
|
||||
if ((file->f_mode & FMODE_STREAM) == 0)
|
||||
file->f_pos = pos;
|
||||
return file->f_mode & FMODE_STREAM ? NULL : &file->f_pos;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (f.file) {
|
||||
loff_t pos = file_pos_read(f.file);
|
||||
ret = vfs_read(f.file, buf, count, &pos);
|
||||
if (ret >= 0)
|
||||
file_pos_write(f.file, pos);
|
||||
loff_t pos, *ppos = file_ppos(f.file);
|
||||
if (ppos) {
|
||||
pos = *ppos;
|
||||
ppos = &pos;
|
||||
}
|
||||
ret = vfs_read(f.file, buf, count, ppos);
|
||||
if (ret >= 0 && ppos)
|
||||
f.file->f_pos = pos;
|
||||
fdput_pos(f);
|
||||
}
|
||||
return ret;
|
||||
|
@ -595,10 +603,14 @@ ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count)
|
|||
ssize_t ret = -EBADF;
|
||||
|
||||
if (f.file) {
|
||||
loff_t pos = file_pos_read(f.file);
|
||||
ret = vfs_write(f.file, buf, count, &pos);
|
||||
if (ret >= 0)
|
||||
file_pos_write(f.file, pos);
|
||||
loff_t pos, *ppos = file_ppos(f.file);
|
||||
if (ppos) {
|
||||
pos = *ppos;
|
||||
ppos = &pos;
|
||||
}
|
||||
ret = vfs_write(f.file, buf, count, ppos);
|
||||
if (ret >= 0 && ppos)
|
||||
f.file->f_pos = pos;
|
||||
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);
|
||||
if (ret)
|
||||
return ret;
|
||||
kiocb.ki_pos = *ppos;
|
||||
kiocb.ki_pos = (ppos ? *ppos : 0);
|
||||
|
||||
if (type == READ)
|
||||
ret = call_read_iter(filp, &kiocb, iter);
|
||||
else
|
||||
ret = call_write_iter(filp, &kiocb, iter);
|
||||
BUG_ON(ret == -EIOCBQUEUED);
|
||||
*ppos = kiocb.ki_pos;
|
||||
if (ppos)
|
||||
*ppos = kiocb.ki_pos;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1013,10 +1026,14 @@ static ssize_t do_readv(unsigned long fd, const struct iovec __user *vec,
|
|||
ssize_t ret = -EBADF;
|
||||
|
||||
if (f.file) {
|
||||
loff_t pos = file_pos_read(f.file);
|
||||
ret = vfs_readv(f.file, vec, vlen, &pos, flags);
|
||||
if (ret >= 0)
|
||||
file_pos_write(f.file, pos);
|
||||
loff_t pos, *ppos = file_ppos(f.file);
|
||||
if (ppos) {
|
||||
pos = *ppos;
|
||||
ppos = &pos;
|
||||
}
|
||||
ret = vfs_readv(f.file, vec, vlen, ppos, flags);
|
||||
if (ret >= 0 && ppos)
|
||||
f.file->f_pos = pos;
|
||||
fdput_pos(f);
|
||||
}
|
||||
|
||||
|
@ -1033,10 +1050,14 @@ static ssize_t do_writev(unsigned long fd, const struct iovec __user *vec,
|
|||
ssize_t ret = -EBADF;
|
||||
|
||||
if (f.file) {
|
||||
loff_t pos = file_pos_read(f.file);
|
||||
ret = vfs_writev(f.file, vec, vlen, &pos, flags);
|
||||
if (ret >= 0)
|
||||
file_pos_write(f.file, pos);
|
||||
loff_t pos, *ppos = file_ppos(f.file);
|
||||
if (ppos) {
|
||||
pos = *ppos;
|
||||
ppos = &pos;
|
||||
}
|
||||
ret = vfs_writev(f.file, vec, vlen, ppos, flags);
|
||||
if (ret >= 0 && ppos)
|
||||
f.file->f_pos = pos;
|
||||
fdput_pos(f);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ static int batadv_socket_open(struct inode *inode, struct file *file)
|
|||
|
||||
batadv_debugfs_deprecated(file, "");
|
||||
|
||||
nonseekable_open(inode, file);
|
||||
stream_open(inode, file);
|
||||
|
||||
socket_client = kmalloc(sizeof(*socket_client), GFP_KERNEL);
|
||||
if (!socket_client) {
|
||||
|
|
|
@ -102,7 +102,7 @@ static int batadv_log_open(struct inode *inode, struct file *file)
|
|||
batadv_debugfs_deprecated(file,
|
||||
"Use tracepoint batadv:batadv_dbg instead\n");
|
||||
|
||||
nonseekable_open(inode, file);
|
||||
stream_open(inode, file);
|
||||
file->private_data = inode->i_private;
|
||||
return 0;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user