Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
apk-tools
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
Service Desk
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
Show more breadcrumbs
alpine
apk-tools
Commits
3d203e8f
Commit
3d203e8f
authored
3 years ago
by
Timo Teräs
Browse files
Options
Downloads
Patches
Plain Diff
db: allow read-only operations without cache
fixes #10748
parent
a0e9c909
No related branches found
No related tags found
No related merge requests found
Pipeline
#88350
passed
3 years ago
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/apk_defines.h
+2
-1
2 additions, 1 deletion
src/apk_defines.h
src/database.c
+6
-3
6 additions, 3 deletions
src/database.c
src/io.c
+15
-0
15 additions, 0 deletions
src/io.c
src/print.c
+1
-0
1 addition, 0 deletions
src/print.c
with
24 additions
and
4 deletions
src/apk_defines.h
+
2
−
1
View file @
3d203e8f
...
@@ -60,7 +60,8 @@ enum {
...
@@ -60,7 +60,8 @@ enum {
APKE_PACKAGE_NOT_FOUND
,
APKE_PACKAGE_NOT_FOUND
,
APKE_INDEX_STALE
,
APKE_INDEX_STALE
,
APKE_FILE_INTEGRITY
,
APKE_FILE_INTEGRITY
,
APKE_UVOL
APKE_CACHE_NOT_AVAILABLE
,
APKE_UVOL
,
};
};
static
inline
void
*
ERR_PTR
(
long
error
)
{
return
(
void
*
)
error
;
}
static
inline
void
*
ERR_PTR
(
long
error
)
{
return
(
void
*
)
error
;
}
...
...
This diff is collapsed.
Click to expand it.
src/database.c
+
6
−
3
View file @
3d203e8f
...
@@ -1647,7 +1647,10 @@ int apk_db_open(struct apk_database *db, struct apk_ctx *ac)
...
@@ -1647,7 +1647,10 @@ int apk_db_open(struct apk_database *db, struct apk_ctx *ac)
mkdirat
(
db
->
root_fd
,
"var/cache"
,
0755
);
mkdirat
(
db
->
root_fd
,
"var/cache"
,
0755
);
mkdirat
(
db
->
root_fd
,
"var/cache/apk"
,
0755
);
mkdirat
(
db
->
root_fd
,
"var/cache/apk"
,
0755
);
db
->
cache_fd
=
openat
(
db
->
root_fd
,
db
->
cache_dir
,
O_RDONLY
|
O_CLOEXEC
);
db
->
cache_fd
=
openat
(
db
->
root_fd
,
db
->
cache_dir
,
O_RDONLY
|
O_CLOEXEC
);
if
(
db
->
cache_fd
<
0
)
goto
ret_errno
;
if
(
db
->
cache_fd
<
0
)
{
if
(
ac
->
open_flags
&
APK_OPENF_WRITE
)
goto
ret_errno
;
db
->
cache_fd
=
-
APKE_CACHE_NOT_AVAILABLE
;
}
}
}
}
}
...
@@ -1814,8 +1817,8 @@ void apk_db_close(struct apk_database *db)
...
@@ -1814,8 +1817,8 @@ void apk_db_close(struct apk_database *db)
db
->
cache_remount_dir
=
NULL
;
db
->
cache_remount_dir
=
NULL
;
}
}
if
(
db
->
cache_fd
)
close
(
db
->
cache_fd
);
if
(
db
->
cache_fd
>
0
)
close
(
db
->
cache_fd
);
if
(
db
->
lock_fd
)
close
(
db
->
lock_fd
);
if
(
db
->
lock_fd
>
0
)
close
(
db
->
lock_fd
);
}
}
int
apk_db_get_tag_id
(
struct
apk_database
*
db
,
apk_blob_t
tag
)
int
apk_db_get_tag_id
(
struct
apk_database
*
db
,
apk_blob_t
tag
)
...
...
This diff is collapsed.
Click to expand it.
src/io.c
+
15
−
0
View file @
3d203e8f
...
@@ -33,6 +33,11 @@
...
@@ -33,6 +33,11 @@
size_t
apk_io_bufsize
=
128
*
1024
;
size_t
apk_io_bufsize
=
128
*
1024
;
static
inline
int
atfd_error
(
int
atfd
)
{
return
atfd
<
-
1
&&
atfd
!=
AT_FDCWD
;
}
ssize_t
apk_write_fully
(
int
fd
,
const
void
*
ptr
,
size_t
size
)
ssize_t
apk_write_fully
(
int
fd
,
const
void
*
ptr
,
size_t
size
)
{
{
ssize_t
i
=
0
,
r
;
ssize_t
i
=
0
,
r
;
...
@@ -528,6 +533,8 @@ struct apk_istream *__apk_istream_from_file(int atfd, const char *file, int try_
...
@@ -528,6 +533,8 @@ struct apk_istream *__apk_istream_from_file(int atfd, const char *file, int try_
{
{
int
fd
;
int
fd
;
if
(
atfd_error
(
atfd
))
return
ERR_PTR
(
atfd
);
fd
=
openat
(
atfd
,
file
,
O_RDONLY
|
O_CLOEXEC
);
fd
=
openat
(
atfd
,
file
,
O_RDONLY
|
O_CLOEXEC
);
if
(
fd
<
0
)
return
ERR_PTR
(
-
errno
);
if
(
fd
<
0
)
return
ERR_PTR
(
-
errno
);
...
@@ -588,6 +595,8 @@ apk_blob_t apk_blob_from_file(int atfd, const char *file)
...
@@ -588,6 +595,8 @@ apk_blob_t apk_blob_from_file(int atfd, const char *file)
struct
stat
st
;
struct
stat
st
;
char
*
buf
;
char
*
buf
;
if
(
atfd_error
(
atfd
))
return
APK_BLOB_NULL
;
fd
=
openat
(
atfd
,
file
,
O_RDONLY
|
O_CLOEXEC
);
fd
=
openat
(
atfd
,
file
,
O_RDONLY
|
O_CLOEXEC
);
if
(
fd
<
0
)
if
(
fd
<
0
)
return
APK_BLOB_NULL
;
return
APK_BLOB_NULL
;
...
@@ -615,6 +624,8 @@ int apk_blob_to_file(int atfd, const char *file, apk_blob_t b, unsigned int flag
...
@@ -615,6 +624,8 @@ int apk_blob_to_file(int atfd, const char *file, apk_blob_t b, unsigned int flag
{
{
int
fd
,
r
,
len
;
int
fd
,
r
,
len
;
if
(
atfd_error
(
atfd
))
return
atfd
;
fd
=
openat
(
atfd
,
file
,
O_CREAT
|
O_WRONLY
|
O_CLOEXEC
,
0644
);
fd
=
openat
(
atfd
,
file
,
O_CREAT
|
O_WRONLY
|
O_CLOEXEC
,
0644
);
if
(
fd
<
0
)
if
(
fd
<
0
)
return
-
errno
;
return
-
errno
;
...
@@ -685,6 +696,8 @@ int apk_fileinfo_get(int atfd, const char *filename, unsigned int flags,
...
@@ -685,6 +696,8 @@ int apk_fileinfo_get(int atfd, const char *filename, unsigned int flags,
unsigned
int
xattr_hash_alg
=
(
flags
>>
8
)
&
0xff
;
unsigned
int
xattr_hash_alg
=
(
flags
>>
8
)
&
0xff
;
int
atflags
=
0
;
int
atflags
=
0
;
if
(
atfd_error
(
atfd
))
return
atfd
;
memset
(
fi
,
0
,
sizeof
*
fi
);
memset
(
fi
,
0
,
sizeof
*
fi
);
if
(
flags
&
APK_FI_NOFOLLOW
)
if
(
flags
&
APK_FI_NOFOLLOW
)
atflags
|=
AT_SYMLINK_NOFOLLOW
;
atflags
|=
AT_SYMLINK_NOFOLLOW
;
...
@@ -918,6 +931,8 @@ struct apk_ostream *apk_ostream_to_file(int atfd, const char *file, mode_t mode)
...
@@ -918,6 +931,8 @@ struct apk_ostream *apk_ostream_to_file(int atfd, const char *file, mode_t mode)
struct
apk_ostream
*
os
;
struct
apk_ostream
*
os
;
int
fd
;
int
fd
;
if
(
atfd_error
(
atfd
))
return
ERR_PTR
(
atfd
);
if
(
snprintf
(
tmpname
,
sizeof
tmpname
,
"%s.tmp"
,
file
)
>=
sizeof
tmpname
)
if
(
snprintf
(
tmpname
,
sizeof
tmpname
,
"%s.tmp"
,
file
)
>=
sizeof
tmpname
)
return
ERR_PTR
(
-
ENAMETOOLONG
);
return
ERR_PTR
(
-
ENAMETOOLONG
);
...
...
This diff is collapsed.
Click to expand it.
src/print.c
+
1
−
0
View file @
3d203e8f
...
@@ -56,6 +56,7 @@ const char *apk_error_str(int error)
...
@@ -56,6 +56,7 @@ const char *apk_error_str(int error)
case
APKE_PACKAGE_NOT_FOUND
:
return
"could not find a repo which provides this package (check repositories file and run 'apk update')"
;
case
APKE_PACKAGE_NOT_FOUND
:
return
"could not find a repo which provides this package (check repositories file and run 'apk update')"
;
case
APKE_INDEX_STALE
:
return
"package mentioned in index not found (try 'apk update')"
;
case
APKE_INDEX_STALE
:
return
"package mentioned in index not found (try 'apk update')"
;
case
APKE_FILE_INTEGRITY
:
return
"file integrity error"
;
case
APKE_FILE_INTEGRITY
:
return
"file integrity error"
;
case
APKE_CACHE_NOT_AVAILABLE
:
return
"cache not available"
;
case
APKE_UVOL
:
return
"uvol error"
;
case
APKE_UVOL
:
return
"uvol error"
;
default:
default:
return
strerror
(
error
);
return
strerror
(
error
);
...
...
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