Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Trung Lê
aports
Commits
0365f746
Commit
0365f746
authored
Jan 17, 2009
by
Timo Teräs
Browse files
archive: preserve mtime on extraction
parent
a98b57b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/archive.c
View file @
0365f746
...
...
@@ -14,6 +14,7 @@
#include
<err.h>
#include
<errno.h>
#include
<fcntl.h>
#include
<utime.h>
#include
<malloc.h>
#include
<string.h>
#include
<unistd.h>
...
...
@@ -194,6 +195,7 @@ int apk_archive_entry_extract(const struct apk_file_info *ae,
const
char
*
fn
,
apk_progress_cb
cb
,
void
*
cb_ctx
)
{
struct
utimbuf
utb
;
int
r
=
-
1
,
fd
;
if
(
fn
==
NULL
)
...
...
@@ -238,17 +240,34 @@ int apk_archive_entry_extract(const struct apk_file_info *ae,
r
=
chown
(
fn
,
ae
->
uid
,
ae
->
gid
);
else
r
=
lchown
(
fn
,
ae
->
uid
,
ae
->
gid
);
if
(
r
<
0
)
apk_error
(
"Failed to set ownership on %s: %s"
,
fn
,
strerror
(
errno
));
if
(
r
<
0
)
{
apk_error
(
"Failed to set ownership on %s: %s"
,
fn
,
strerror
(
errno
));
return
-
errno
;
}
/* chown resets suid bit so we need set it again */
if
(
ae
->
mode
&
07000
)
if
(
ae
->
mode
&
07000
)
{
r
=
chmod
(
fn
,
ae
->
mode
&
07777
);
if
(
r
<
0
)
apk_error
(
"Failed to set file permissions on %s: %s"
,
if
(
r
<
0
)
{
apk_error
(
"Failed to set file permissions "
"on %s: %s"
,
fn
,
strerror
(
errno
));
return
-
errno
;
}
}
/* preserve modification time */
utb
.
actime
=
utb
.
modtime
=
ae
->
mtime
;
r
=
utime
(
fn
,
&
utb
);
if
(
r
<
0
)
{
apk_error
(
"Failed to preserve modification time on %s: %s"
,
fn
,
strerror
(
errno
));
return
-
errno
;
}
}
else
{
apk_error
(
"Failed to extract %s
\n
"
,
ae
->
name
);
apk_error
(
"Failed to extract %s: %s"
,
ae
->
name
,
strerror
(
errno
));
return
-
errno
;
}
return
r
;
return
0
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment