mirror of
https://github.com/troglobit/finit.git
synced 2026-09-30 13:02:37 +07:00
Relocate ln() helper function
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -110,12 +110,6 @@ static void clean(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
static void ln(const char *target, const char *linkpath)
|
||||
{
|
||||
if (symlink(target, linkpath) && errno != EEXIST)
|
||||
err(1, "Failed creating %s -> %s symlink", target, linkpath);
|
||||
}
|
||||
|
||||
/* Kernel defines the following compulsory and recommended links
|
||||
* https://github.com/torvalds/linux/blob/v5.18/Documentation/admin-guide/devices.rst#compulsory-links
|
||||
*/
|
||||
|
||||
@@ -125,6 +125,21 @@ static inline int create(char *path, mode_t mode, char *user, char *group)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int ln(const char *target, const char *linkpath)
|
||||
{
|
||||
if (!target || !linkpath) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (symlink(target, linkpath)) {
|
||||
if (errno != EEXIST)
|
||||
warn("Failed creating %s -> %s symlink", target, linkpath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
static inline int dprint(int fd, const char *s, size_t len)
|
||||
{
|
||||
size_t loop = 3;
|
||||
|
||||
Reference in New Issue
Block a user