Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nccf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
702
Provoz
nccf
Commits
40b12759
Commit
40b12759
authored
7 years ago
by
Yorhel
Browse files
Options
Downloads
Patches
Plain Diff
Import/export extended information
And stick to the more portable second resolution timestamps for mtime.
parent
47e969cd
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/dir_export.c
+15
-3
15 additions, 3 deletions
src/dir_export.c
src/dir_import.c
+16
-0
16 additions, 0 deletions
src/dir_import.c
src/dir_scan.c
+1
-1
1 addition, 1 deletion
src/dir_scan.c
src/global.h
+1
-1
1 addition, 1 deletion
src/global.h
with
33 additions
and
5 deletions
src/dir_export.c
+
15
−
3
View file @
40b12759
...
@@ -75,6 +75,9 @@ static void output_int(uint64_t n) {
...
@@ -75,6 +75,9 @@ static void output_int(uint64_t n) {
static
void
output_info
(
struct
dir
*
d
,
const
char
*
name
,
struct
dir_ext
*
e
)
{
static
void
output_info
(
struct
dir
*
d
,
const
char
*
name
,
struct
dir_ext
*
e
)
{
if
(
!
extended_info
||
!
(
d
->
flags
&
FF_EXT
))
e
=
NULL
;
fputs
(
"{
\"
name
\"
:
\"
"
,
stream
);
fputs
(
"{
\"
name
\"
:
\"
"
,
stream
);
output_string
(
name
);
output_string
(
name
);
fputc
(
'"'
,
stream
);
fputc
(
'"'
,
stream
);
...
@@ -96,6 +99,17 @@ static void output_info(struct dir *d, const char *name, struct dir_ext *e) {
...
@@ -96,6 +99,17 @@ static void output_info(struct dir *d, const char *name, struct dir_ext *e) {
fputs
(
",
\"
ino
\"
:"
,
stream
);
fputs
(
",
\"
ino
\"
:"
,
stream
);
output_int
(
d
->
ino
);
output_int
(
d
->
ino
);
if
(
e
)
{
fputs
(
",
\"
uid
\"
:"
,
stream
);
output_int
(
e
->
uid
);
fputs
(
",
\"
gid
\"
:"
,
stream
);
output_int
(
e
->
gid
);
fputs
(
",
\"
mode
\"
:"
,
stream
);
output_int
(
e
->
mode
);
fputs
(
",
\"
mtime
\"
:"
,
stream
);
output_int
(
e
->
mtime
);
}
/* TODO: Including the actual number of links would be nicer. */
/* TODO: Including the actual number of links would be nicer. */
if
(
d
->
flags
&
FF_HLNKC
)
if
(
d
->
flags
&
FF_HLNKC
)
fputs
(
",
\"
hlnkc
\"
:true"
,
stream
);
fputs
(
",
\"
hlnkc
\"
:true"
,
stream
);
...
@@ -109,8 +123,6 @@ static void output_info(struct dir *d, const char *name, struct dir_ext *e) {
...
@@ -109,8 +123,6 @@ static void output_info(struct dir *d, const char *name, struct dir_ext *e) {
else
if
(
d
->
flags
&
FF_OTHFS
)
else
if
(
d
->
flags
&
FF_OTHFS
)
fputs
(
",
\"
excluded
\"
:
\"
othfs
\"
"
,
stream
);
fputs
(
",
\"
excluded
\"
:
\"
othfs
\"
"
,
stream
);
/* TODO: Output extended info if -e is given */
fputc
(
'}'
,
stream
);
fputc
(
'}'
,
stream
);
}
}
...
@@ -136,7 +148,7 @@ static int item(struct dir *item, const char *name, struct dir_ext *ext) {
...
@@ -136,7 +148,7 @@ static int item(struct dir *item, const char *name, struct dir_ext *ext) {
/* File header.
/* File header.
* TODO: Add scan options? */
* TODO: Add scan options? */
if
(
!
stack
.
top
)
{
if
(
!
stack
.
top
)
{
fputs
(
"[1,
0
,{
\"
progname
\"
:
\"
"
PACKAGE
"
\"
,
\"
progver
\"
:
\"
"
PACKAGE_VERSION
"
\"
,
\"
timestamp
\"
:"
,
stream
);
fputs
(
"[1,
1
,{
\"
progname
\"
:
\"
"
PACKAGE
"
\"
,
\"
progver
\"
:
\"
"
PACKAGE_VERSION
"
\"
,
\"
timestamp
\"
:"
,
stream
);
output_int
((
uint64_t
)
time
(
NULL
));
output_int
((
uint64_t
)
time
(
NULL
));
fputc
(
'}'
,
stream
);
fputc
(
'}'
,
stream
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/dir_import.c
+
16
−
0
View file @
40b12759
...
@@ -448,6 +448,22 @@ static int iteminfo() {
...
@@ -448,6 +448,22 @@ static int iteminfo() {
}
else
if
(
strcmp
(
ctx
->
val
,
"ino"
)
==
0
)
{
/* ino */
}
else
if
(
strcmp
(
ctx
->
val
,
"ino"
)
==
0
)
{
/* ino */
C
(
rint64
(
&
iv
,
UINT64_MAX
));
C
(
rint64
(
&
iv
,
UINT64_MAX
));
ctx
->
buf_dir
->
ino
=
iv
;
ctx
->
buf_dir
->
ino
=
iv
;
}
else
if
(
strcmp
(
ctx
->
val
,
"uid"
)
==
0
)
{
/* uid */
C
(
rint64
(
&
iv
,
INT32_MAX
));
ctx
->
buf_dir
->
flags
|=
FF_EXT
;
ctx
->
buf_ext
->
uid
=
iv
;
}
else
if
(
strcmp
(
ctx
->
val
,
"gid"
)
==
0
)
{
/* gid */
C
(
rint64
(
&
iv
,
INT32_MAX
));
ctx
->
buf_dir
->
flags
|=
FF_EXT
;
ctx
->
buf_ext
->
gid
=
iv
;
}
else
if
(
strcmp
(
ctx
->
val
,
"mode"
)
==
0
)
{
/* mode */
C
(
rint64
(
&
iv
,
UINT16_MAX
));
ctx
->
buf_dir
->
flags
|=
FF_EXT
;
ctx
->
buf_ext
->
mode
=
iv
;
}
else
if
(
strcmp
(
ctx
->
val
,
"mtime"
)
==
0
)
{
/* mtime */
C
(
rint64
(
&
iv
,
UINT64_MAX
));
ctx
->
buf_dir
->
flags
|=
FF_EXT
;
ctx
->
buf_ext
->
mtime
=
iv
;
}
else
if
(
strcmp
(
ctx
->
val
,
"hlnkc"
)
==
0
)
{
/* hlnkc */
}
else
if
(
strcmp
(
ctx
->
val
,
"hlnkc"
)
==
0
)
{
/* hlnkc */
if
(
*
ctx
->
buf
==
't'
)
{
if
(
*
ctx
->
buf
==
't'
)
{
C
(
rlit
(
"true"
,
4
));
C
(
rlit
(
"true"
,
4
));
...
...
This diff is collapsed.
Click to expand it.
src/dir_scan.c
+
1
−
1
View file @
40b12759
...
@@ -75,7 +75,7 @@ static void stat_to_dir(struct stat *fs) {
...
@@ -75,7 +75,7 @@ static void stat_to_dir(struct stat *fs) {
}
}
buf_ext
->
mode
=
fs
->
st_mode
;
buf_ext
->
mode
=
fs
->
st_mode
;
buf_ext
->
mtime
=
fs
->
st_mtim
;
buf_ext
->
mtime
=
fs
->
st_mtim
e
;
buf_ext
->
uid
=
(
int
)
fs
->
st_uid
;
buf_ext
->
uid
=
(
int
)
fs
->
st_uid
;
buf_ext
->
gid
=
(
int
)
fs
->
st_gid
;
buf_ext
->
gid
=
(
int
)
fs
->
st_gid
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/global.h
+
1
−
1
View file @
40b12759
...
@@ -85,7 +85,7 @@ struct dir {
...
@@ -85,7 +85,7 @@ struct dir {
* memory region as struct dir, placed after the name field. See util.h for
* memory region as struct dir, placed after the name field. See util.h for
* macros to help manage this. */
* macros to help manage this. */
struct
dir_ext
{
struct
dir_ext
{
struct
timespec
mtime
;
uint64_t
mtime
;
int
uid
,
gid
;
int
uid
,
gid
;
unsigned
short
mode
;
unsigned
short
mode
;
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment