|
@@ -4,6 +4,7 @@
|
|
|
*
|
|
*
|
|
|
* Copyright © 2007 Canonical Ltd
|
|
* Copyright © 2007 Canonical Ltd
|
|
|
* written by Ian Jackson <ian@chiark.greenend.org.uk>
|
|
* written by Ian Jackson <ian@chiark.greenend.org.uk>
|
|
|
|
|
+ * Copyright © 2008-2014 Guillem Jover <guillem@debian.org>
|
|
|
*
|
|
*
|
|
|
* This is free software; you can redistribute it and/or modify
|
|
* This is free software; you can redistribute it and/or modify
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
* it under the terms of the GNU General Public License as published by
|
|
@@ -111,28 +112,28 @@ constructfn(struct varbuf *vb, const char *dir, const char *tail)
|
|
|
* Start processing of the triggers deferred file.
|
|
* Start processing of the triggers deferred file.
|
|
|
*
|
|
*
|
|
|
* @retval -1 Lock ENOENT with O_CREAT (directory does not exist).
|
|
* @retval -1 Lock ENOENT with O_CREAT (directory does not exist).
|
|
|
- * @retval -2 Unincorp empty, tduf_writeifempty unset.
|
|
|
|
|
- * @retval -3 Unincorp ENOENT, tduf_writeifenoent unset.
|
|
|
|
|
- * @retval 1 Unincorp ENOENT, tduf_writeifenoent set.
|
|
|
|
|
|
|
+ * @retval -2 Unincorp empty, TDUF_WRITE_IF_EMPTY unset.
|
|
|
|
|
+ * @retval -3 Unincorp ENOENT, TDUF_WRITE_IF_ENOENT unset.
|
|
|
|
|
+ * @retval 1 Unincorp ENOENT, TDUF_WRITE_IF_ENOENT set.
|
|
|
* @retval 2 Ok.
|
|
* @retval 2 Ok.
|
|
|
*
|
|
*
|
|
|
* For positive return values the caller must call trigdef_update_done!
|
|
* For positive return values the caller must call trigdef_update_done!
|
|
|
*/
|
|
*/
|
|
|
enum trigdef_update_status
|
|
enum trigdef_update_status
|
|
|
-trigdef_update_start(enum trigdef_updateflags uf)
|
|
|
|
|
|
|
+trigdef_update_start(enum trigdef_update_flags uf)
|
|
|
{
|
|
{
|
|
|
triggersdir = dpkg_db_get_path(TRIGGERSDIR);
|
|
triggersdir = dpkg_db_get_path(TRIGGERSDIR);
|
|
|
|
|
|
|
|
- if (uf & tduf_write) {
|
|
|
|
|
|
|
+ if (uf & TDUF_WRITE) {
|
|
|
constructfn(&fn, triggersdir, TRIGGERSLOCKFILE);
|
|
constructfn(&fn, triggersdir, TRIGGERSLOCKFILE);
|
|
|
if (lock_fd == -1) {
|
|
if (lock_fd == -1) {
|
|
|
lock_fd = open(fn.buf, O_RDWR | O_CREAT | O_TRUNC, 0600);
|
|
lock_fd = open(fn.buf, O_RDWR | O_CREAT | O_TRUNC, 0600);
|
|
|
if (lock_fd == -1) {
|
|
if (lock_fd == -1) {
|
|
|
- if (!(errno == ENOENT && (uf & tduf_nolockok)))
|
|
|
|
|
|
|
+ if (!(errno == ENOENT && (uf & TDUF_NO_LOCK_OK)))
|
|
|
ohshite(_("unable to open/create "
|
|
ohshite(_("unable to open/create "
|
|
|
"triggers lockfile `%.250s'"),
|
|
"triggers lockfile `%.250s'"),
|
|
|
fn.buf);
|
|
fn.buf);
|
|
|
- return tdus_error_no_dir;
|
|
|
|
|
|
|
+ return TDUS_ERROR_NO_DIR;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -151,9 +152,9 @@ trigdef_update_start(enum trigdef_updateflags uf)
|
|
|
if (errno != ENOENT)
|
|
if (errno != ENOENT)
|
|
|
ohshite(_("unable to open triggers deferred file `%.250s'"),
|
|
ohshite(_("unable to open triggers deferred file `%.250s'"),
|
|
|
fn.buf);
|
|
fn.buf);
|
|
|
- if (!(uf & tduf_writeifenoent)) {
|
|
|
|
|
|
|
+ if (!(uf & TDUF_WRITE_IF_ENOENT)) {
|
|
|
pop_cleanup(ehflag_normaltidy);
|
|
pop_cleanup(ehflag_normaltidy);
|
|
|
- return tdus_error_no_deferred;
|
|
|
|
|
|
|
+ return TDUS_ERROR_NO_DEFERRED;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
struct stat stab;
|
|
struct stat stab;
|
|
@@ -164,13 +165,13 @@ trigdef_update_start(enum trigdef_updateflags uf)
|
|
|
ohshite(_("unable to stat triggers deferred file `%.250s'"),
|
|
ohshite(_("unable to stat triggers deferred file `%.250s'"),
|
|
|
fn.buf);
|
|
fn.buf);
|
|
|
|
|
|
|
|
- if (stab.st_size == 0 && !(uf & tduf_writeifempty)) {
|
|
|
|
|
|
|
+ if (stab.st_size == 0 && !(uf & TDUF_WRITE_IF_EMPTY)) {
|
|
|
pop_cleanup(ehflag_normaltidy);
|
|
pop_cleanup(ehflag_normaltidy);
|
|
|
- return tdus_error_empty_deferred;
|
|
|
|
|
|
|
+ return TDUS_ERROR_EMPTY_DEFERRED;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (uf & tduf_write) {
|
|
|
|
|
|
|
+ if (uf & TDUF_WRITE) {
|
|
|
constructfn(&newfn, triggersdir, TRIGGERSDEFERREDFILE ".new");
|
|
constructfn(&newfn, triggersdir, TRIGGERSDEFERREDFILE ".new");
|
|
|
if (trig_new_deferred)
|
|
if (trig_new_deferred)
|
|
|
fclose(trig_new_deferred);
|
|
fclose(trig_new_deferred);
|
|
@@ -181,12 +182,12 @@ trigdef_update_start(enum trigdef_updateflags uf)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!old_deferred)
|
|
if (!old_deferred)
|
|
|
- return tdus_no_deferred;
|
|
|
|
|
|
|
+ return TDUS_NO_DEFERRED;
|
|
|
|
|
|
|
|
trigdef_yyrestart(old_deferred);
|
|
trigdef_yyrestart(old_deferred);
|
|
|
BEGIN(0);
|
|
BEGIN(0);
|
|
|
|
|
|
|
|
- return tdus_ok;
|
|
|
|
|
|
|
+ return TDUS_OK;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void
|
|
void
|