Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
b25472f9
K
kernel_linux
项目概览
OpenHarmony
/
kernel_linux
上一次同步 3 年多
通知
13
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kernel_linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
b25472f9
编写于
9年前
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
new helpers: no_seek_end_llseek{,_size}()
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
b808b1d6
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
54 addition
and
222 deletion
+54
-222
arch/sparc/kernel/mdesc.c
arch/sparc/kernel/mdesc.c
+2
-18
arch/x86/kernel/cpuid.c
arch/x86/kernel/cpuid.c
+1
-23
arch/x86/kernel/msr.c
arch/x86/kernel/msr.c
+1
-23
drivers/char/nwflash.c
drivers/char/nwflash.c
+1
-30
drivers/net/wireless/ti/wlcore/debugfs.c
drivers/net/wireless/ti/wlcore/debugfs.c
+1
-16
drivers/s390/char/vmur.c
drivers/s390/char/vmur.c
+1
-14
drivers/s390/char/zcore.c
drivers/s390/char/zcore.c
+1
-12
drivers/usb/core/devices.c
drivers/usb/core/devices.c
+1
-25
drivers/usb/core/devio.c
drivers/usb/core/devio.c
+1
-25
drivers/usb/host/uhci-debug.c
drivers/usb/host/uhci-debug.c
+2
-21
drivers/usb/misc/sisusbvga/sisusb.c
drivers/usb/misc/sisusbvga/sisusb.c
+1
-15
fs/read_write.c
fs/read_write.c
+39
-0
include/linux/fs.h
include/linux/fs.h
+2
-0
未找到文件。
arch/sparc/kernel/mdesc.c
浏览文件 @
b25472f9
...
...
@@ -1033,25 +1033,9 @@ static ssize_t mdesc_read(struct file *file, char __user *buf,
static
loff_t
mdesc_llseek
(
struct
file
*
file
,
loff_t
offset
,
int
whence
)
{
struct
mdesc_handle
*
hp
;
switch
(
whence
)
{
case
SEEK_CUR
:
offset
+=
file
->
f_pos
;
break
;
case
SEEK_SET
:
break
;
default:
return
-
EINVAL
;
}
hp
=
file
->
private_data
;
if
(
offset
>
hp
->
handle_size
)
return
-
EINVAL
;
else
file
->
f_pos
=
offset
;
struct
mdesc_handle
*
hp
=
file
->
private_data
;
return
offset
;
return
no_seek_end_llseek_size
(
file
,
offset
,
whence
,
hp
->
handle_size
)
;
}
/* mdesc_close() - /dev/mdesc is being closed, release the reference to
...
...
This diff is collapsed.
Click to expand it.
arch/x86/kernel/cpuid.c
浏览文件 @
b25472f9
...
...
@@ -58,28 +58,6 @@ static void cpuid_smp_cpuid(void *cmd_block)
&
cmd
->
eax
,
&
cmd
->
ebx
,
&
cmd
->
ecx
,
&
cmd
->
edx
);
}
static
loff_t
cpuid_seek
(
struct
file
*
file
,
loff_t
offset
,
int
orig
)
{
loff_t
ret
;
struct
inode
*
inode
=
file
->
f_mapping
->
host
;
mutex_lock
(
&
inode
->
i_mutex
);
switch
(
orig
)
{
case
0
:
file
->
f_pos
=
offset
;
ret
=
file
->
f_pos
;
break
;
case
1
:
file
->
f_pos
+=
offset
;
ret
=
file
->
f_pos
;
break
;
default:
ret
=
-
EINVAL
;
}
mutex_unlock
(
&
inode
->
i_mutex
);
return
ret
;
}
static
ssize_t
cpuid_read
(
struct
file
*
file
,
char
__user
*
buf
,
size_t
count
,
loff_t
*
ppos
)
{
...
...
@@ -132,7 +110,7 @@ static int cpuid_open(struct inode *inode, struct file *file)
*/
static
const
struct
file_operations
cpuid_fops
=
{
.
owner
=
THIS_MODULE
,
.
llseek
=
cpuid_
seek
,
.
llseek
=
no_seek_end_ll
seek
,
.
read
=
cpuid_read
,
.
open
=
cpuid_open
,
};
...
...
This diff is collapsed.
Click to expand it.
arch/x86/kernel/msr.c
浏览文件 @
b25472f9
...
...
@@ -45,28 +45,6 @@
static
struct
class
*
msr_class
;
static
loff_t
msr_seek
(
struct
file
*
file
,
loff_t
offset
,
int
orig
)
{
loff_t
ret
;
struct
inode
*
inode
=
file_inode
(
file
);
mutex_lock
(
&
inode
->
i_mutex
);
switch
(
orig
)
{
case
SEEK_SET
:
file
->
f_pos
=
offset
;
ret
=
file
->
f_pos
;
break
;
case
SEEK_CUR
:
file
->
f_pos
+=
offset
;
ret
=
file
->
f_pos
;
break
;
default:
ret
=
-
EINVAL
;
}
mutex_unlock
(
&
inode
->
i_mutex
);
return
ret
;
}
static
ssize_t
msr_read
(
struct
file
*
file
,
char
__user
*
buf
,
size_t
count
,
loff_t
*
ppos
)
{
...
...
@@ -194,7 +172,7 @@ static int msr_open(struct inode *inode, struct file *file)
*/
static
const
struct
file_operations
msr_fops
=
{
.
owner
=
THIS_MODULE
,
.
llseek
=
msr_
seek
,
.
llseek
=
no_seek_end_ll
seek
,
.
read
=
msr_read
,
.
write
=
msr_write
,
.
open
=
msr_open
,
...
...
This diff is collapsed.
Click to expand it.
drivers/char/nwflash.c
浏览文件 @
b25472f9
...
...
@@ -277,36 +277,7 @@ static loff_t flash_llseek(struct file *file, loff_t offset, int orig)
printk
(
KERN_DEBUG
"flash_llseek: offset=0x%X, orig=0x%X.
\n
"
,
(
unsigned
int
)
offset
,
orig
);
switch
(
orig
)
{
case
0
:
if
(
offset
<
0
)
{
ret
=
-
EINVAL
;
break
;
}
if
((
unsigned
int
)
offset
>
gbFlashSize
)
{
ret
=
-
EINVAL
;
break
;
}
file
->
f_pos
=
(
unsigned
int
)
offset
;
ret
=
file
->
f_pos
;
break
;
case
1
:
if
((
file
->
f_pos
+
offset
)
>
gbFlashSize
)
{
ret
=
-
EINVAL
;
break
;
}
if
((
file
->
f_pos
+
offset
)
<
0
)
{
ret
=
-
EINVAL
;
break
;
}
file
->
f_pos
+=
offset
;
ret
=
file
->
f_pos
;
break
;
default:
ret
=
-
EINVAL
;
}
ret
=
no_seek_end_llseek_size
(
file
,
offset
,
orig
,
gbFlashSize
);
mutex_unlock
(
&
flash_mutex
);
return
ret
;
}
...
...
This diff is collapsed.
Click to expand it.
drivers/net/wireless/ti/wlcore/debugfs.c
浏览文件 @
b25472f9
...
...
@@ -1205,26 +1205,11 @@ static ssize_t dev_mem_write(struct file *file, const char __user *user_buf,
static
loff_t
dev_mem_seek
(
struct
file
*
file
,
loff_t
offset
,
int
orig
)
{
loff_t
ret
;
/* only requests of dword-aligned size and offset are supported */
if
(
offset
%
4
)
return
-
EINVAL
;
switch
(
orig
)
{
case
SEEK_SET
:
file
->
f_pos
=
offset
;
ret
=
file
->
f_pos
;
break
;
case
SEEK_CUR
:
file
->
f_pos
+=
offset
;
ret
=
file
->
f_pos
;
break
;
default:
ret
=
-
EINVAL
;
}
return
ret
;
return
no_seek_end_llseek
(
file
,
offset
,
orig
);
}
static
const
struct
file_operations
dev_mem_ops
=
{
...
...
This diff is collapsed.
Click to expand it.
drivers/s390/char/vmur.c
浏览文件 @
b25472f9
...
...
@@ -782,24 +782,11 @@ static int ur_release(struct inode *inode, struct file *file)
static
loff_t
ur_llseek
(
struct
file
*
file
,
loff_t
offset
,
int
whence
)
{
loff_t
newpos
;
if
((
file
->
f_flags
&
O_ACCMODE
)
!=
O_RDONLY
)
return
-
ESPIPE
;
/* seek allowed only for reader */
if
(
offset
%
PAGE_SIZE
)
return
-
ESPIPE
;
/* only multiples of 4K allowed */
switch
(
whence
)
{
case
0
:
/* SEEK_SET */
newpos
=
offset
;
break
;
case
1
:
/* SEEK_CUR */
newpos
=
file
->
f_pos
+
offset
;
break
;
default:
return
-
EINVAL
;
}
file
->
f_pos
=
newpos
;
return
newpos
;
return
no_seek_end_llseek
(
file
,
offset
,
whence
);
}
static
const
struct
file_operations
ur_fops
=
{
...
...
This diff is collapsed.
Click to expand it.
drivers/s390/char/zcore.c
浏览文件 @
b25472f9
...
...
@@ -385,18 +385,7 @@ static loff_t zcore_lseek(struct file *file, loff_t offset, int orig)
loff_t
rc
;
mutex_lock
(
&
zcore_mutex
);
switch
(
orig
)
{
case
0
:
file
->
f_pos
=
offset
;
rc
=
file
->
f_pos
;
break
;
case
1
:
file
->
f_pos
+=
offset
;
rc
=
file
->
f_pos
;
break
;
default:
rc
=
-
EINVAL
;
}
rc
=
no_seek_end_llseek
(
file
,
offset
,
orig
);
mutex_unlock
(
&
zcore_mutex
);
return
rc
;
}
...
...
This diff is collapsed.
Click to expand it.
drivers/usb/core/devices.c
浏览文件 @
b25472f9
...
...
@@ -661,32 +661,8 @@ static unsigned int usb_device_poll(struct file *file,
return
0
;
}
static
loff_t
usb_device_lseek
(
struct
file
*
file
,
loff_t
offset
,
int
orig
)
{
loff_t
ret
;
mutex_lock
(
&
file_inode
(
file
)
->
i_mutex
);
switch
(
orig
)
{
case
0
:
file
->
f_pos
=
offset
;
ret
=
file
->
f_pos
;
break
;
case
1
:
file
->
f_pos
+=
offset
;
ret
=
file
->
f_pos
;
break
;
case
2
:
default:
ret
=
-
EINVAL
;
}
mutex_unlock
(
&
file_inode
(
file
)
->
i_mutex
);
return
ret
;
}
const
struct
file_operations
usbfs_devices_fops
=
{
.
llseek
=
usb_device_
lseek
,
.
llseek
=
no_seek_end_l
lseek
,
.
read
=
usb_device_read
,
.
poll
=
usb_device_poll
,
};
This diff is collapsed.
Click to expand it.
drivers/usb/core/devio.c
浏览文件 @
b25472f9
...
...
@@ -157,30 +157,6 @@ static int connected(struct usb_dev_state *ps)
ps
->
dev
->
state
!=
USB_STATE_NOTATTACHED
);
}
static
loff_t
usbdev_lseek
(
struct
file
*
file
,
loff_t
offset
,
int
orig
)
{
loff_t
ret
;
mutex_lock
(
&
file_inode
(
file
)
->
i_mutex
);
switch
(
orig
)
{
case
0
:
file
->
f_pos
=
offset
;
ret
=
file
->
f_pos
;
break
;
case
1
:
file
->
f_pos
+=
offset
;
ret
=
file
->
f_pos
;
break
;
case
2
:
default:
ret
=
-
EINVAL
;
}
mutex_unlock
(
&
file_inode
(
file
)
->
i_mutex
);
return
ret
;
}
static
ssize_t
usbdev_read
(
struct
file
*
file
,
char
__user
*
buf
,
size_t
nbytes
,
loff_t
*
ppos
)
{
...
...
@@ -2366,7 +2342,7 @@ static unsigned int usbdev_poll(struct file *file,
const
struct
file_operations
usbdev_file_operations
=
{
.
owner
=
THIS_MODULE
,
.
llseek
=
usbdev_
lseek
,
.
llseek
=
no_seek_end_l
lseek
,
.
read
=
usbdev_read
,
.
poll
=
usbdev_poll
,
.
unlocked_ioctl
=
usbdev_ioctl
,
...
...
This diff is collapsed.
Click to expand it.
drivers/usb/host/uhci-debug.c
浏览文件 @
b25472f9
...
...
@@ -584,27 +584,8 @@ static int uhci_debug_open(struct inode *inode, struct file *file)
static
loff_t
uhci_debug_lseek
(
struct
file
*
file
,
loff_t
off
,
int
whence
)
{
struct
uhci_debug
*
up
;
loff_t
new
=
-
1
;
up
=
file
->
private_data
;
/*
* XXX: atomic 64bit seek access, but that needs to be fixed in the VFS
*/
switch
(
whence
)
{
case
0
:
new
=
off
;
break
;
case
1
:
new
=
file
->
f_pos
+
off
;
break
;
}
if
(
new
<
0
||
new
>
up
->
size
)
return
-
EINVAL
;
return
(
file
->
f_pos
=
new
);
struct
uhci_debug
*
up
=
file
->
private_data
;
return
no_seek_end_llseek_size
(
file
,
off
,
whence
,
up
->
size
);
}
static
ssize_t
uhci_debug_read
(
struct
file
*
file
,
char
__user
*
buf
,
...
...
This diff is collapsed.
Click to expand it.
drivers/usb/misc/sisusbvga/sisusb.c
浏览文件 @
b25472f9
...
...
@@ -2825,21 +2825,7 @@ sisusb_lseek(struct file *file, loff_t offset, int orig)
return
-
ENODEV
;
}
switch
(
orig
)
{
case
0
:
file
->
f_pos
=
offset
;
ret
=
file
->
f_pos
;
/* never negative, no force_successful_syscall needed */
break
;
case
1
:
file
->
f_pos
+=
offset
;
ret
=
file
->
f_pos
;
/* never negative, no force_successful_syscall needed */
break
;
default:
/* seeking relative to "end of file" is not supported */
ret
=
-
EINVAL
;
}
ret
=
no_seek_end_llseek
(
file
,
offset
,
orig
);
mutex_unlock
(
&
sisusb
->
lock
);
return
ret
;
...
...
This diff is collapsed.
Click to expand it.
fs/read_write.c
浏览文件 @
b25472f9
...
...
@@ -170,6 +170,45 @@ loff_t fixed_size_llseek(struct file *file, loff_t offset, int whence, loff_t si
}
EXPORT_SYMBOL
(
fixed_size_llseek
);
/**
* no_seek_end_llseek - llseek implementation for fixed-sized devices
* @file: file structure to seek on
* @offset: file offset to seek to
* @whence: type of seek
*
*/
loff_t
no_seek_end_llseek
(
struct
file
*
file
,
loff_t
offset
,
int
whence
)
{
switch
(
whence
)
{
case
SEEK_SET
:
case
SEEK_CUR
:
return
generic_file_llseek_size
(
file
,
offset
,
whence
,
~
0ULL
,
0
);
default:
return
-
EINVAL
;
}
}
EXPORT_SYMBOL
(
no_seek_end_llseek
);
/**
* no_seek_end_llseek_size - llseek implementation for fixed-sized devices
* @file: file structure to seek on
* @offset: file offset to seek to
* @whence: type of seek
* @size: maximal offset allowed
*
*/
loff_t
no_seek_end_llseek_size
(
struct
file
*
file
,
loff_t
offset
,
int
whence
,
loff_t
size
)
{
switch
(
whence
)
{
case
SEEK_SET
:
case
SEEK_CUR
:
return
generic_file_llseek_size
(
file
,
offset
,
whence
,
size
,
0
);
default:
return
-
EINVAL
;
}
}
EXPORT_SYMBOL
(
no_seek_end_llseek_size
);
/**
* noop_llseek - No Operation Performed llseek implementation
* @file: file structure to seek on
...
...
This diff is collapsed.
Click to expand it.
include/linux/fs.h
浏览文件 @
b25472f9
...
...
@@ -2660,6 +2660,8 @@ extern loff_t generic_file_llseek_size(struct file *file, loff_t offset,
int
whence
,
loff_t
maxsize
,
loff_t
eof
);
extern
loff_t
fixed_size_llseek
(
struct
file
*
file
,
loff_t
offset
,
int
whence
,
loff_t
size
);
extern
loff_t
no_seek_end_llseek_size
(
struct
file
*
,
loff_t
,
int
,
loff_t
);
extern
loff_t
no_seek_end_llseek
(
struct
file
*
,
loff_t
,
int
);
extern
int
generic_file_open
(
struct
inode
*
inode
,
struct
file
*
filp
);
extern
int
nonseekable_open
(
struct
inode
*
inode
,
struct
file
*
filp
);
...
...
This diff is collapsed.
Click to expand it.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
新手
引导
客服
返回
顶部