Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
af1ce33a
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
af1ce33a
编写于
2月 18, 2020
作者:
V
vkempik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8229872: (fs) Increase buffer size used with getmntent
Summary: Dynamically allocate memory for getmntent Reviewed-by: yan
上级
aa251cfb
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
98 addition
and
13 deletion
+98
-13
make/mapfiles/libnio/mapfile-linux
make/mapfiles/libnio/mapfile-linux
+3
-1
src/solaris/classes/sun/nio/fs/LinuxFileSystem.java
src/solaris/classes/sun/nio/fs/LinuxFileSystem.java
+18
-2
src/solaris/classes/sun/nio/fs/LinuxNativeDispatcher.java
src/solaris/classes/sun/nio/fs/LinuxNativeDispatcher.java
+17
-2
src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java
src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java
+6
-1
src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c
src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c
+39
-6
src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
+15
-1
未找到文件。
make/mapfiles/libnio/mapfile-linux
浏览文件 @
af1ce33a
...
...
@@ -153,8 +153,9 @@ SUNWprivate_1.1 {
Java_sun_nio_fs_LinuxNativeDispatcher_fsetxattr0;
Java_sun_nio_fs_LinuxNativeDispatcher_fremovexattr0;
Java_sun_nio_fs_LinuxNativeDispatcher_setmntent0;
Java_sun_nio_fs_LinuxNativeDispatcher_getmntent
;
Java_sun_nio_fs_LinuxNativeDispatcher_getmntent0
;
Java_sun_nio_fs_LinuxNativeDispatcher_endmntent;
Java_sun_nio_fs_LinuxNativeDispatcher_getlinelen;
Java_sun_nio_fs_UnixNativeDispatcher_init;
Java_sun_nio_fs_UnixNativeDispatcher_getcwd;
Java_sun_nio_fs_UnixNativeDispatcher_strerror;
...
...
@@ -176,6 +177,7 @@ SUNWprivate_1.1 {
Java_sun_nio_fs_UnixNativeDispatcher_close;
Java_sun_nio_fs_UnixNativeDispatcher_read;
Java_sun_nio_fs_UnixNativeDispatcher_write;
Java_sun_nio_fs_UnixNativeDispatcher_rewind;
Java_sun_nio_fs_UnixNativeDispatcher_fopen0;
Java_sun_nio_fs_UnixNativeDispatcher_fclose;
Java_sun_nio_fs_UnixNativeDispatcher_opendir0;
...
...
src/solaris/classes/sun/nio/fs/LinuxFileSystem.java
浏览文件 @
af1ce33a
/*
* Copyright (c) 2008, 201
8
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 201
9
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -79,10 +79,26 @@ class LinuxFileSystem extends UnixFileSystem {
ArrayList
<
UnixMountEntry
>
entries
=
new
ArrayList
<>();
try
{
long
fp
=
setmntent
(
Util
.
toBytes
(
fstab
),
Util
.
toBytes
(
"r"
));
int
maxLineSize
=
1024
;
try
{
for
(;;)
{
int
lineSize
=
getlinelen
(
fp
);
if
(
lineSize
==
-
1
)
break
;
if
(
lineSize
>
maxLineSize
)
maxLineSize
=
lineSize
;
}
}
catch
(
UnixException
x
)
{
// nothing we need to do
}
finally
{
rewind
(
fp
);
}
try
{
for
(;;)
{
UnixMountEntry
entry
=
new
UnixMountEntry
();
int
res
=
getmntent
(
fp
,
entry
);
// count in NUL character at the end
int
res
=
getmntent
(
fp
,
entry
,
maxLineSize
+
1
);
if
(
res
<
0
)
break
;
entries
.
add
(
entry
);
...
...
src/solaris/classes/sun/nio/fs/LinuxNativeDispatcher.java
浏览文件 @
af1ce33a
/*
* Copyright (c) 2008, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 201
9
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -54,7 +54,17 @@ class LinuxNativeDispatcher extends UnixNativeDispatcher {
/**
* int getmntent(FILE *fp, struct mnttab *mp, int len);
*/
static
native
int
getmntent
(
long
fp
,
UnixMountEntry
entry
)
static
int
getmntent
(
long
fp
,
UnixMountEntry
entry
,
int
buflen
)
throws
UnixException
{
NativeBuffer
buffer
=
NativeBuffers
.
getNativeBuffer
(
buflen
);
try
{
return
getmntent0
(
fp
,
entry
,
buffer
.
address
(),
buflen
);
}
finally
{
buffer
.
release
();
}
}
static
native
int
getmntent0
(
long
fp
,
UnixMountEntry
entry
,
long
buffer
,
int
bufLen
)
throws
UnixException
;
/**
...
...
@@ -62,6 +72,11 @@ class LinuxNativeDispatcher extends UnixNativeDispatcher {
*/
static
native
void
endmntent
(
long
stream
)
throws
UnixException
;
/**
* ssize_t getline(char **lineptr, size_t *n, FILE *stream);
*/
static
native
int
getlinelen
(
long
stream
)
throws
UnixException
;
/**
* ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size);
*/
...
...
src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java
浏览文件 @
af1ce33a
/*
* Copyright (c) 2008, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 201
9
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -116,6 +116,11 @@ class UnixNativeDispatcher {
*/
static
native
void
fclose
(
long
stream
)
throws
UnixException
;
/**
* void rewind(FILE* stream);
*/
static
native
void
rewind
(
long
stream
)
throws
UnixException
;
/**
* link(const char* existing, const char* new)
*/
...
...
src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c
浏览文件 @
af1ce33a
/*
* Copyright (c) 2008, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 201
9
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -169,12 +169,11 @@ Java_sun_nio_fs_LinuxNativeDispatcher_setmntent0(JNIEnv* env, jclass this, jlong
}
JNIEXPORT
jint
JNICALL
Java_sun_nio_fs_LinuxNativeDispatcher_getmntent
(
JNIEnv
*
env
,
jclass
this
,
jlong
value
,
jobject
entry
)
Java_sun_nio_fs_LinuxNativeDispatcher_getmntent
0
(
JNIEnv
*
env
,
jclass
this
,
jlong
value
,
jobject
entry
,
jlong
buffer
,
jint
bufLen
)
{
struct
mntent
ent
;
char
buf
[
1024
];
int
buflen
=
sizeof
(
buf
);
char
*
buf
=
(
char
*
)
jlong_to_ptr
(
buffer
);
struct
mntent
*
m
;
FILE
*
fp
=
jlong_to_ptr
(
value
);
jsize
len
;
...
...
@@ -184,7 +183,7 @@ Java_sun_nio_fs_LinuxNativeDispatcher_getmntent(JNIEnv* env, jclass this,
char
*
fstype
;
char
*
options
;
m
=
getmntent_r
(
fp
,
&
ent
,
(
char
*
)
&
buf
,
bufl
en
);
m
=
getmntent_r
(
fp
,
&
ent
,
buf
,
(
int
)
bufL
en
);
if
(
m
==
NULL
)
return
-
1
;
name
=
m
->
mnt_fsname
;
...
...
@@ -230,3 +229,37 @@ Java_sun_nio_fs_LinuxNativeDispatcher_endmntent(JNIEnv* env, jclass this, jlong
/* FIXME - man page doesn't explain how errors are returned */
endmntent
(
fp
);
}
/**
* This function returns line length without NUL terminator or -1 on EOF.
* Since getline is missing on Solaris10 this function was moved from
* UnixNativeDispatcher to LinuxNativeDispatcher as part of backport form jdk11.
*/
JNIEXPORT
jint
JNICALL
Java_sun_nio_fs_LinuxNativeDispatcher_getlinelen
(
JNIEnv
*
env
,
jclass
this
,
jlong
stream
)
{
FILE
*
fp
=
jlong_to_ptr
(
stream
);
size_t
lineSize
=
0
;
char
*
lineBuffer
=
NULL
;
int
saved_errno
;
ssize_t
res
=
getline
(
&
lineBuffer
,
&
lineSize
,
fp
);
saved_errno
=
errno
;
/* Should free lineBuffer no matter result, according to man page */
if
(
lineBuffer
!=
NULL
)
free
(
lineBuffer
);
if
(
feof
(
fp
))
return
-
1
;
/* On successfull return res >= 0, otherwise res is -1 */
if
(
res
==
-
1
)
throwUnixException
(
env
,
saved_errno
);
if
(
res
>
INT_MAX
)
throwUnixException
(
env
,
EOVERFLOW
);
return
(
jint
)
res
;
}
src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
浏览文件 @
af1ce33a
/*
* Copyright (c) 2008, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 201
9
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -367,6 +367,20 @@ Java_sun_nio_fs_UnixNativeDispatcher_fclose(JNIEnv* env, jclass this, jlong stre
}
}
JNIEXPORT
void
JNICALL
Java_sun_nio_fs_UnixNativeDispatcher_rewind
(
JNIEnv
*
env
,
jclass
this
,
jlong
stream
)
{
FILE
*
fp
=
jlong_to_ptr
(
stream
);
int
saved_errno
;
errno
=
0
;
rewind
(
fp
);
saved_errno
=
errno
;
if
(
ferror
(
fp
))
{
throwUnixException
(
env
,
saved_errno
);
}
}
JNIEXPORT
jint
JNICALL
Java_sun_nio_fs_UnixNativeDispatcher_open0
(
JNIEnv
*
env
,
jclass
this
,
jlong
pathAddress
,
jint
oflags
,
jint
mode
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录