diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-06-16 01:56:00 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-06-16 01:56:00 +0200 |
commit | 2c7108c40abfb1f175391aa59cf1b07ab203e690 (patch) | |
tree | a9c2d8ddd55b3ad212c4e5c4b998bf3e7a4bb4f0 /src/util.c | |
parent | b08a35509c1e09ac3ec2de37a259ff0fbbe69928 (diff) |
util: introduce readlink_and_make_absolute()
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index 7664df59d0..2bc90da3d2 100644 --- a/src/util.c +++ b/src/util.c @@ -582,6 +582,26 @@ int readlink_malloc(const char *p, char **r) { } } +int readlink_and_make_absolute(const char *p, char **r) { + char *target, *k; + int j; + + assert(p); + assert(r); + + if ((j = readlink_malloc(p, &target)) < 0) + return j; + + k = file_in_same_dir(p, target); + free(target); + + if (!k) + return -ENOMEM; + + *r = k; + return 0; +} + char *file_name_from_path(const char *p) { char *r; |