#############################################################################*/
#include <errno.h>
+#include <stdlib.h>
#include <pakfire/ctx.h>
#include <pakfire/elf.h>
+#include <pakfire/string.h>
// libelf
#include <gelf.h>
struct pakfire_ctx* ctx;
int nrefs;
+ // Path
+ char path[PATH_MAX];
+
// File Descriptor
int fd;
free(self);
}
-int pakfire_elf_open(struct pakfire_elf** elf, struct pakfire_ctx* ctx, int fd) {
+int pakfire_elf_open(struct pakfire_elf** elf,
+ struct pakfire_ctx* ctx, const char* path, int fd) {
struct pakfire_elf* self = NULL;
int r;
// Initialize the reference counter
self->nrefs = 1;
+ // Store the path
+ r = pakfire_string_set(self->path, path);
+ if (r < 0)
+ goto ERROR;
+
// Store the file descriptor
self->fd = dup(fd);
if (self->fd < 0) {
pakfire_elf_free(self);
return NULL;
}
+
+const char* pakfire_elf_path(struct pakfire_elf* self) {
+ return self->path;
+}
#include <pakfire/ctx.h>
-int pakfire_elf_open(struct pakfire_elf** elf, struct pakfire_ctx* ctx, int fd);
+int pakfire_elf_open(struct pakfire_elf** elf,
+ struct pakfire_ctx* ctx, const char* path, int fd);
struct pakfire_elf* pakfire_elf_ref(struct pakfire_elf* self);
struct pakfire_elf* pakfire_elf_unref(struct pakfire_elf* self);
+const char* pakfire_elf_path(struct pakfire_elf* self);
+
#endif /* PAKFIRE_PRIVATE */
#endif /* PAKFIRE_ELF_H */