Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
b7897ff7
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看板
提交
b7897ff7
编写于
6月 05, 2008
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6652379: File.setLastModified fails on large files (lnx only)
Reviewed-by: iris
上级
554f8842
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
150 deletion
+43
-150
src/solaris/native/java/io/UnixFileSystem_md.c
src/solaris/native/java/io/UnixFileSystem_md.c
+22
-142
test/java/io/File/SetLastModified.java
test/java/io/File/SetLastModified.java
+21
-8
未找到文件。
src/solaris/native/java/io/UnixFileSystem_md.c
浏览文件 @
b7897ff7
...
...
@@ -58,70 +58,6 @@ Java_java_io_UnixFileSystem_initIDs(JNIEnv *env, jclass cls)
"path"
,
"Ljava/lang/String;"
);
}
/* -- Large-file support -- */
/* LINUX_FIXME: ifdef __solaris__ here is wrong. We need to move the
* definition of stat64 into a solaris_largefile.h and create a
* linux_largefile.h with a good stat64 structure to compile on
* glibc2.0 based systems.
*/
#if defined(__solaris__) && !defined(_LFS_LARGEFILE) || !_LFS_LARGEFILE
/* The stat64 structure must be provided for systems without large-file support
(e.g., Solaris 2.5.1). These definitions are copied from the Solaris 2.6
<sys/stat.h> and <sys/types.h> files.
*/
typedef
longlong_t
off64_t
;
/* offsets within files */
typedef
u_longlong_t
ino64_t
;
/* expanded inode type */
typedef
longlong_t
blkcnt64_t
;
/* count of file blocks */
struct
stat64
{
dev_t
st_dev
;
long
st_pad1
[
3
];
ino64_t
st_ino
;
mode_t
st_mode
;
nlink_t
st_nlink
;
uid_t
st_uid
;
gid_t
st_gid
;
dev_t
st_rdev
;
long
st_pad2
[
2
];
off64_t
st_size
;
timestruc_t
st_atim
;
timestruc_t
st_mtim
;
timestruc_t
st_ctim
;
long
st_blksize
;
blkcnt64_t
st_blocks
;
char
st_fstype
[
_ST_FSTYPSZ
];
long
st_pad4
[
8
];
};
#endif
/* !_LFS_LARGEFILE */
typedef
int
(
*
STAT64
)(
const
char
*
,
struct
stat64
*
);
#if defined(__linux__) && defined(_LARGEFILE64_SOURCE)
static
STAT64
stat64_ptr
=
&
stat64
;
#else
static
STAT64
stat64_ptr
=
NULL
;
#endif
#ifndef __linux__
#ifdef __GNUC__
static
void
init64IO
(
void
)
__attribute__
((
constructor
));
#else
#pragma init(init64IO)
#endif
#endif
static
void
init64IO
(
void
)
{
void
*
handle
=
dlopen
(
0
,
RTLD_LAZY
);
stat64_ptr
=
(
STAT64
)
dlsym
(
handle
,
"_stat64"
);
dlclose
(
handle
);
}
/* -- Path operations -- */
extern
int
canonicalize
(
char
*
path
,
const
char
*
out
,
int
len
);
...
...
@@ -151,18 +87,10 @@ Java_java_io_UnixFileSystem_canonicalize0(JNIEnv *env, jobject this,
static
jboolean
statMode
(
const
char
*
path
,
int
*
mode
)
{
if
(
stat64_ptr
)
{
struct
stat64
sb
;
if
(((
*
stat64_ptr
)(
path
,
&
sb
))
==
0
)
{
*
mode
=
sb
.
st_mode
;
return
JNI_TRUE
;
}
}
else
{
struct
stat
sb
;
if
(
stat
(
path
,
&
sb
)
==
0
)
{
*
mode
=
sb
.
st_mode
;
return
JNI_TRUE
;
}
struct
stat64
sb
;
if
(
stat64
(
path
,
&
sb
)
==
0
)
{
*
mode
=
sb
.
st_mode
;
return
JNI_TRUE
;
}
return
JNI_FALSE
;
}
...
...
@@ -266,16 +194,9 @@ Java_java_io_UnixFileSystem_getLastModifiedTime(JNIEnv *env, jobject this,
jlong
rv
=
0
;
WITH_FIELD_PLATFORM_STRING
(
env
,
file
,
ids
.
path
,
path
)
{
if
(
stat64_ptr
)
{
struct
stat64
sb
;
if
(((
*
stat64_ptr
)(
path
,
&
sb
))
==
0
)
{
rv
=
1000
*
(
jlong
)
sb
.
st_mtime
;
}
}
else
{
struct
stat
sb
;
if
(
stat
(
path
,
&
sb
)
==
0
)
{
rv
=
1000
*
(
jlong
)
sb
.
st_mtime
;
}
struct
stat64
sb
;
if
(
stat64
(
path
,
&
sb
)
==
0
)
{
rv
=
1000
*
(
jlong
)
sb
.
st_mtime
;
}
}
END_PLATFORM_STRING
(
env
,
path
);
return
rv
;
...
...
@@ -289,16 +210,9 @@ Java_java_io_UnixFileSystem_getLength(JNIEnv *env, jobject this,
jlong
rv
=
0
;
WITH_FIELD_PLATFORM_STRING
(
env
,
file
,
ids
.
path
,
path
)
{
if
(
stat64_ptr
)
{
struct
stat64
sb
;
if
(((
*
stat64_ptr
)(
path
,
&
sb
))
==
0
)
{
rv
=
sb
.
st_size
;
}
}
else
{
struct
stat
sb
;
if
(
stat
(
path
,
&
sb
)
==
0
)
{
rv
=
sb
.
st_size
;
}
struct
stat64
sb
;
if
(
stat64
(
path
,
&
sb
)
==
0
)
{
rv
=
sb
.
st_size
;
}
}
END_PLATFORM_STRING
(
env
,
path
);
return
rv
;
...
...
@@ -447,15 +361,6 @@ Java_java_io_UnixFileSystem_rename0(JNIEnv *env, jobject this,
return
rv
;
}
/* Bug in solaris /usr/include/sys/time.h? */
#ifdef __solaris__
extern
int
utimes
(
const
char
*
,
const
struct
timeval
*
);
#elif defined(__linux___)
extern
int
utimes
(
const
char
*
,
struct
timeval
*
);
#endif
JNIEXPORT
jboolean
JNICALL
Java_java_io_UnixFileSystem_setLastModifiedTime
(
JNIEnv
*
env
,
jobject
this
,
jobject
file
,
jlong
time
)
...
...
@@ -463,47 +368,22 @@ Java_java_io_UnixFileSystem_setLastModifiedTime(JNIEnv *env, jobject this,
jboolean
rv
=
JNI_FALSE
;
WITH_FIELD_PLATFORM_STRING
(
env
,
file
,
ids
.
path
,
path
)
{
struct
timeval
tv
[
2
];
#ifdef __solaris__
timestruc_t
ts
;
if
(
stat64_ptr
)
{
struct
stat64
sb
;
if
(((
*
stat64_ptr
)(
path
,
&
sb
))
==
0
)
ts
=
sb
.
st_atim
;
else
goto
error
;
}
else
{
struct
stat
sb
;
if
(
stat
(
path
,
&
sb
)
==
0
)
ts
=
sb
.
st_atim
;
else
goto
error
;
}
#endif
/* Preserve access time */
#ifdef __linux__
struct
stat
sb
;
if
(
stat
(
path
,
&
sb
)
==
0
)
{
struct
stat64
sb
;
tv
[
0
].
tv_sec
=
sb
.
st_atime
;
tv
[
0
].
tv_usec
=
0
;
}
#else
tv
[
0
].
tv_sec
=
ts
.
tv_sec
;
tv
[
0
].
tv_usec
=
ts
.
tv_nsec
/
1000
;
#endif
if
(
stat64
(
path
,
&
sb
)
==
0
)
{
struct
timeval
tv
[
2
];
/* Change last-modified
time */
tv
[
1
].
tv_sec
=
time
/
1000
;
tv
[
1
].
tv_usec
=
(
time
%
1000
)
*
100
0
;
/* Preserve access
time */
tv
[
0
].
tv_sec
=
sb
.
st_atime
;
tv
[
0
].
tv_usec
=
0
;
if
(
utimes
(
path
,
tv
)
>=
0
)
rv
=
JNI_TRUE
;
/* Change last-modified time */
tv
[
1
].
tv_sec
=
time
/
1000
;
tv
[
1
].
tv_usec
=
(
time
%
1000
)
*
1000
;
error:
;
if
(
utimes
(
path
,
tv
)
==
0
)
rv
=
JNI_TRUE
;
}
}
END_PLATFORM_STRING
(
env
,
path
);
return
rv
;
...
...
test/java/io/File/SetLastModified.java
浏览文件 @
b7897ff7
...
...
@@ -22,11 +22,13 @@
*/
/* @test
@bug 4091757
@bug 4091757
6652379
@summary Basic test for setLastModified method
*/
import
java.io.*
;
import
java.nio.ByteBuffer
;
import
java.nio.channels.FileChannel
;
public
class
SetLastModified
{
...
...
@@ -95,13 +97,24 @@ public class SetLastModified {
if
(
f
.
setLastModified
(
nt
))
throw
new
Exception
(
"Succeeded on non-existent file: "
+
f
);
OutputStream
o
=
new
FileOutputStream
(
f
);
o
.
write
(
'x'
);
o
.
close
();
ot
=
f
.
lastModified
();
if
(!
f
.
setLastModified
(
nt
))
throw
new
Exception
(
"setLastModified failed on file: "
+
f
);
ck
(
f
,
nt
,
f
.
lastModified
());
// set/check last modified on files of size 1, 1GB+1, 2GB+1, ..
// On Windows we only test with a tiny file as that platform doesn't
// support sparse files by default and so the test takes too long.
final
long
G
=
1024L
*
1024L
*
1024L
;
final
long
MAX_POSITION
=
System
.
getProperty
(
"os.name"
).
startsWith
(
"Windows"
)
?
0L
:
3L
*
G
;
long
pos
=
0L
;
while
(
pos
<=
MAX_POSITION
)
{
FileChannel
fc
=
new
FileOutputStream
(
f
).
getChannel
();
fc
.
position
(
pos
).
write
(
ByteBuffer
.
wrap
(
"x"
.
getBytes
()));
fc
.
close
();
ot
=
f
.
lastModified
();
System
.
out
.
format
(
"check with file size: %d\n"
,
f
.
length
());
if
(!
f
.
setLastModified
(
nt
))
throw
new
Exception
(
"setLastModified failed on file: "
+
f
);
ck
(
f
,
nt
,
f
.
lastModified
());
pos
+=
G
;
}
if
(!
f
.
delete
())
throw
new
Exception
(
"Can't delete test file "
+
f
);
if
(!
d2
.
delete
())
throw
new
Exception
(
"Can't delete test directory "
+
d2
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录