chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
82d115d
)
core: timer - switch to touch_file()
author
Kay Sievers
<kay@vrfy.org>
Sat, 24 May 2014 03:39:47 +0000
(11:39 +0800)
committer
Kay Sievers
<kay@vrfy.org>
Sat, 24 May 2014 03:39:47 +0000
(11:39 +0800)
src/core/timer.c
patch
|
blob
|
history
src/shared/util.c
patch
|
blob
|
history
diff --git
a/src/core/timer.c
b/src/core/timer.c
index b0a9023bb00debc4fc5e5e827ba6e423aa759ed8..6f2deda21f60f97fd3ddf9c7e00ffb1d9153ac71 100644
(file)
--- a/
src/core/timer.c
+++ b/
src/core/timer.c
@@
-111,23
+111,6
@@
static int timer_add_default_dependencies(Timer *t) {
return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
}
return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
}
-static void update_stampfile(Timer *t, usec_t timestamp) {
- _cleanup_close_ int fd = -1;
-
- mkdir_parents_label(t->stamp_path, 0755);
-
- /* Update the file atime + mtime, if we can */
- fd = open(t->stamp_path, O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0644);
- if (fd >= 0) {
- struct timespec ts[2];
-
- timespec_store(&ts[0], timestamp);
- ts[1] = ts[0];
-
- futimens(fd, ts);
- }
-}
-
static int timer_setup_persistent(Timer *t) {
int r;
static int timer_setup_persistent(Timer *t) {
int r;
@@
-514,7
+497,7
@@
static void timer_enter_running(Timer *t) {
dual_timestamp_get(&t->last_trigger);
if (t->stamp_path)
dual_timestamp_get(&t->last_trigger);
if (t->stamp_path)
-
update_stampfile(t, t->last_trigger.realtime
);
+
touch_file(t->stamp_path, true, t->last_trigger.realtime, (uid_t) -1, (gid_t) -1, 0
);
timer_set_state(t, TIMER_RUNNING);
return;
timer_set_state(t, TIMER_RUNNING);
return;
@@
-546,7
+529,7
@@
static int timer_start(Unit *u) {
/* The timer has never run before,
* make sure a stamp file exists.
*/
/* The timer has never run before,
* make sure a stamp file exists.
*/
-
update_stampfile(t, now(CLOCK_REALTIME)
);
+
touch_file(t->stamp_path, true, (usec_t) -1, (uid_t) -1, (gid_t) -1, 0
);
}
t->result = TIMER_SUCCESS;
}
t->result = TIMER_SUCCESS;
diff --git
a/src/shared/util.c
b/src/shared/util.c
index 83a674aa8b16ba5e141f1d5aa97cdc145d497c6d..0c273943e7e671d20439dd7f7962e5c382d50032 100644
(file)
--- a/
src/shared/util.c
+++ b/
src/shared/util.c
@@
-3364,17
+3364,17
@@
int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gi
return -errno;
}
return -errno;
}
- if (uid != (uid_t)
-1 || gid != (gid_t)
-1) {
+ if (uid != (uid_t)
-1 || gid != (gid_t)
-1) {
r = fchown(fd, uid, gid);
if (r < 0)
return -errno;
}
r = fchown(fd, uid, gid);
if (r < 0)
return -errno;
}
- if (stamp != (usec_t)-1) {
+ if (stamp != (usec_t)
-1) {
struct timespec ts[2];
timespec_store(&ts[0], stamp);
struct timespec ts[2];
timespec_store(&ts[0], stamp);
- t
imespec_store(&ts[1], stamp)
;
+ t
s[1] = ts[0]
;
r = futimens(fd, ts);
} else
r = futimens(fd, NULL);
r = futimens(fd, ts);
} else
r = futimens(fd, NULL);
@@
-3385,7
+3385,7
@@
int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gi
}
int touch(const char *path) {
}
int touch(const char *path) {
- return touch_file(path, false,
-1, -1,
-1, 0);
+ return touch_file(path, false,
(usec_t) -1, (uid_t) -1, (gid_t)
-1, 0);
}
char *unquote(const char *s, const char* quotes) {
}
char *unquote(const char *s, const char* quotes) {