struct pakfire* p = calloc(1, sizeof(*p));
if (!p)
- return 1;
+ return -errno;
p->nrefs = 1;
p->flags = flags;
// Check if the architecture is supported
if (!pakfire_arch_supported(arch)) {
ERROR(p, "Unsupported architecture: %s\n", arch);
- errno = EINVAL;
+ r = -EINVAL;
goto ERROR;
}
// Path must be absolute
if (path && !pakfire_string_startswith(path, "/")) {
ERROR(p, "Invalid path: %s\n", path);
- errno = EINVAL;
+ r = -EINVAL;
goto ERROR;
}
if (!path) {
path = pakfire_mkdtemp(tempdir);
if (!path) {
- r = 1;
+ r = -errno;
goto ERROR;
}
// Check if the lock is already held
if (pakfire->lock) {
ERROR(pakfire, "Lock is already been acquired by this process\n");
- errno = ENOLCK;
- return 1;
+ return -ENOLCK;
}
DEBUG(pakfire, "Acquire lock...\n");
pakfire->lock = fopen(pakfire->lock_path, "w");
if (!pakfire->lock) {
ERROR(pakfire, "Could not open lock file %s: %m\n", pakfire->lock_path);
- return 1;
+ return -errno;
}
// Attempt to lock the file exclusively