Commit da6e455f authored by Timo Teräs's avatar Timo Teräs

rename file info related functions for consistency

parent be8e133c
...@@ -148,9 +148,9 @@ apk_blob_t apk_blob_from_file(int atfd, const char *file); ...@@ -148,9 +148,9 @@ apk_blob_t apk_blob_from_file(int atfd, const char *file);
int apk_blob_to_file(int atfd, const char *file, apk_blob_t b, unsigned int flags); int apk_blob_to_file(int atfd, const char *file, apk_blob_t b, unsigned int flags);
#define APK_FI_NOFOLLOW 0x80000000 #define APK_FI_NOFOLLOW 0x80000000
int apk_file_get_info(int atfd, const char *filename, unsigned int flags, int apk_fileinfo_get(int atfd, const char *filename, unsigned int flags,
struct apk_file_info *fi); struct apk_file_info *fi);
void apk_file_info_free(struct apk_file_info *fi); void apk_fileinfo_free(struct apk_file_info *fi);
typedef int apk_dir_file_cb(void *ctx, int dirfd, const char *entry); typedef int apk_dir_file_cb(void *ctx, int dirfd, const char *entry);
int apk_dir_foreach_file(int dirfd, apk_dir_file_cb cb, void *ctx); int apk_dir_foreach_file(int dirfd, apk_dir_file_cb cb, void *ctx);
......
...@@ -314,7 +314,7 @@ err: ...@@ -314,7 +314,7 @@ err:
EVP_MD_CTX_cleanup(&teis.mdctx); EVP_MD_CTX_cleanup(&teis.mdctx);
free(pax.ptr); free(pax.ptr);
free(longname.ptr); free(longname.ptr);
apk_file_info_free(&entry); apk_fileinfo_free(&entry);
return r; return r;
err_nomem: err_nomem:
...@@ -480,7 +480,7 @@ int apk_archive_entry_extract(int atfd, const struct apk_file_info *ae, ...@@ -480,7 +480,7 @@ int apk_archive_entry_extract(int atfd, const struct apk_file_info *ae,
} else { } else {
r = errno; r = errno;
} }
if (r < 0) { if (r) {
apk_error("Failed to set xattrs on %s: %s", apk_error("Failed to set xattrs on %s: %s",
fn, strerror(r)); fn, strerror(r));
return -r; return -r;
......
...@@ -99,7 +99,7 @@ static int audit_file(struct audit_ctx *actx, ...@@ -99,7 +99,7 @@ static int audit_file(struct audit_ctx *actx,
dbf->audited = 1; dbf->audited = 1;
if (apk_file_get_info(dirfd, name, APK_FI_NOFOLLOW | dbf->csum.type, &fi) != 0) if (apk_fileinfo_get(dirfd, name, APK_FI_NOFOLLOW | dbf->csum.type, &fi) != 0)
return -EPERM; return -EPERM;
if (dbf->csum.type != APK_CHECKSUM_NONE && if (dbf->csum.type != APK_CHECKSUM_NONE &&
...@@ -175,7 +175,7 @@ static int audit_directory_tree_item(void *ctx, int dirfd, const char *name) ...@@ -175,7 +175,7 @@ static int audit_directory_tree_item(void *ctx, int dirfd, const char *name)
if (bdir.len + bent.len + 1 >= sizeof(atctx->path)) if (bdir.len + bent.len + 1 >= sizeof(atctx->path))
return -ENOMEM; return -ENOMEM;
if (apk_file_get_info(dirfd, name, APK_FI_NOFOLLOW, &fi) < 0) if (apk_fileinfo_get(dirfd, name, APK_FI_NOFOLLOW, &fi) < 0)
return -EPERM; return -EPERM;
memcpy(&atctx->path[atctx->pathlen], bent.ptr, bent.len); memcpy(&atctx->path[atctx->pathlen], bent.ptr, bent.len);
......
...@@ -2425,7 +2425,7 @@ static void apk_db_purge_pkg(struct apk_database *db, ...@@ -2425,7 +2425,7 @@ static void apk_db_purge_pkg(struct apk_database *db,
if ((diri->dir->protect_mode == APK_PROTECT_NONE) || if ((diri->dir->protect_mode == APK_PROTECT_NONE) ||
(apk_flags & APK_PURGE) || (apk_flags & APK_PURGE) ||
(file->csum.type != APK_CHECKSUM_NONE && (file->csum.type != APK_CHECKSUM_NONE &&
apk_file_get_info(db->root_fd, name, APK_FI_NOFOLLOW | file->csum.type, &fi) == 0 && apk_fileinfo_get(db->root_fd, name, APK_FI_NOFOLLOW | file->csum.type, &fi) == 0 &&
apk_checksum_compare(&file->csum, &fi.csum) == 0)) apk_checksum_compare(&file->csum, &fi.csum) == 0))
unlinkat(db->root_fd, name, 0); unlinkat(db->root_fd, name, 0);
if (apk_verbosity >= 3) if (apk_verbosity >= 3)
...@@ -2483,7 +2483,7 @@ static void apk_db_migrate_files(struct apk_database *db, ...@@ -2483,7 +2483,7 @@ static void apk_db_migrate_files(struct apk_database *db,
cstype = ofile->csum.type; cstype = ofile->csum.type;
cstype |= APK_FI_NOFOLLOW; cstype |= APK_FI_NOFOLLOW;
r = apk_file_get_info(db->root_fd, name, cstype, &fi); r = apk_fileinfo_get(db->root_fd, name, cstype, &fi);
if (ofile && ofile->diri->pkg->name == NULL) { if (ofile && ofile->diri->pkg->name == NULL) {
/* File was from overlay, delete the /* File was from overlay, delete the
* packages version */ * packages version */
...@@ -2500,7 +2500,7 @@ static void apk_db_migrate_files(struct apk_database *db, ...@@ -2500,7 +2500,7 @@ static void apk_db_migrate_files(struct apk_database *db,
* existing file */ * existing file */
if (ofile == NULL || if (ofile == NULL ||
ofile->csum.type != file->csum.type) ofile->csum.type != file->csum.type)
apk_file_get_info(db->root_fd, name, apk_fileinfo_get(db->root_fd, name,
APK_FI_NOFOLLOW | file->csum.type, &fi); APK_FI_NOFOLLOW | file->csum.type, &fi);
if ((apk_flags & APK_CLEAN_PROTECTED) || if ((apk_flags & APK_CLEAN_PROTECTED) ||
(file->csum.type != APK_CHECKSUM_NONE && (file->csum.type != APK_CHECKSUM_NONE &&
......
...@@ -138,7 +138,7 @@ static int fetch_package(apk_hash_item item, void *pctx) ...@@ -138,7 +138,7 @@ static int fetch_package(apk_hash_item item, void *pctx)
} }
if (!(ctx->flags & FETCH_STDOUT)) { if (!(ctx->flags & FETCH_STDOUT)) {
if (apk_file_get_info(ctx->outdir_fd, filename, APK_CHECKSUM_NONE, &fi) == 0 && if (apk_fileinfo_get(ctx->outdir_fd, filename, APK_CHECKSUM_NONE, &fi) == 0 &&
fi.size == pkg->size) fi.size == pkg->size)
return 0; return 0;
} }
......
...@@ -81,7 +81,7 @@ static int index_read_file(struct apk_database *db, struct index_ctx *ictx) ...@@ -81,7 +81,7 @@ static int index_read_file(struct apk_database *db, struct index_ctx *ictx)
if (ictx->index == NULL) if (ictx->index == NULL)
return 0; return 0;
if (apk_file_get_info(AT_FDCWD, ictx->index, APK_CHECKSUM_NONE, &fi) < 0) if (apk_fileinfo_get(AT_FDCWD, ictx->index, APK_CHECKSUM_NONE, &fi) < 0)
return -EIO; return -EIO;
ictx->index_mtime = fi.mtime; ictx->index_mtime = fi.mtime;
...@@ -133,7 +133,7 @@ static int index_main(void *ctx, struct apk_database *db, struct apk_string_arra ...@@ -133,7 +133,7 @@ static int index_main(void *ctx, struct apk_database *db, struct apk_string_arra
} }
foreach_array_item(parg, args) { foreach_array_item(parg, args) {
if (apk_file_get_info(AT_FDCWD, *parg, APK_CHECKSUM_NONE, &fi) < 0) { if (apk_fileinfo_get(AT_FDCWD, *parg, APK_CHECKSUM_NONE, &fi) < 0) {
apk_warning("File '%s' is unaccessible", *parg); apk_warning("File '%s' is unaccessible", *parg);
continue; continue;
} }
......
...@@ -529,8 +529,8 @@ int apk_blob_to_file(int atfd, const char *file, apk_blob_t b, unsigned int flag ...@@ -529,8 +529,8 @@ int apk_blob_to_file(int atfd, const char *file, apk_blob_t b, unsigned int flag
return r; return r;
} }
int apk_file_get_info(int atfd, const char *filename, unsigned int flags, int apk_fileinfo_get(int atfd, const char *filename, unsigned int flags,
struct apk_file_info *fi) struct apk_file_info *fi)
{ {
struct stat64 st; struct stat64 st;
struct apk_bstream *bs; struct apk_bstream *bs;
...@@ -586,7 +586,7 @@ int apk_file_get_info(int atfd, const char *filename, unsigned int flags, ...@@ -586,7 +586,7 @@ int apk_file_get_info(int atfd, const char *filename, unsigned int flags,
return 0; return 0;
} }
void apk_file_info_free(struct apk_file_info *fi) void apk_fileinfo_free(struct apk_file_info *fi)
{ {
apk_xattr_array_free(&fi->xattrs); apk_xattr_array_free(&fi->xattrs);
} }
......
...@@ -892,7 +892,7 @@ int apk_pkg_read(struct apk_database *db, const char *file, ...@@ -892,7 +892,7 @@ int apk_pkg_read(struct apk_database *db, const char *file,
struct apk_istream *tar; struct apk_istream *tar;
int r; int r;
r = apk_file_get_info(AT_FDCWD, file, APK_CHECKSUM_NONE, &fi); r = apk_fileinfo_get(AT_FDCWD, file, APK_CHECKSUM_NONE, &fi);
if (r != 0) if (r != 0)
return r; return r;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment