diff options
-rw-r--r-- | include/fileutils.h | 1 | ||||
-rw-r--r-- | lib/fileutils.c | 12 | ||||
-rw-r--r-- | lib/sysfs.c | 12 | ||||
-rw-r--r-- | libmount/src/mountP.h | 4 | ||||
-rw-r--r-- | libmount/src/tab.c | 1 | ||||
-rw-r--r-- | libmount/src/utils.c | 12 |
6 files changed, 15 insertions, 27 deletions
diff --git a/include/fileutils.h b/include/fileutils.h index 99a71edbc..2144e5e5d 100644 --- a/include/fileutils.h +++ b/include/fileutils.h @@ -21,5 +21,6 @@ static inline FILE *xfmkstemp(char **tmpname, char *dir) extern int get_fd_tabsize(void); extern int mkdir_p(const char *path, mode_t mode); +extern char *stripoff_last_component(char *path); #endif /* UTIL_LINUX_FILEUTILS */ diff --git a/lib/fileutils.c b/lib/fileutils.c index 3d4553179..a1b475757 100644 --- a/lib/fileutils.c +++ b/lib/fileutils.c @@ -117,3 +117,15 @@ int mkdir_p(const char *path, mode_t mode) free(dir); return rc; } + +/* returns basename and keeps dirname in the @path, if @path is "/" (root) + * then returns empty string */ +char *stripoff_last_component(char *path) +{ + char *p = path ? strrchr(path, '/') : NULL; + + if (!p) + return NULL; + *p = '\0'; + return p + 1; +} diff --git a/lib/sysfs.c b/lib/sysfs.c index eee082753..b51a4ff26 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -10,6 +10,7 @@ #include "at.h" #include "pathnames.h" #include "sysfs.h" +#include "fileutils.h" char *sysfs_devno_attribute_path(dev_t devno, char *buf, size_t bufsiz, const char *attr) @@ -510,17 +511,6 @@ char *sysfs_get_devname(struct sysfs_cxt *cxt, char *buf, size_t bufsiz) return buf; } -/* returns basename and keeps dirname in the @path */ -static char *stripoff_last_component(char *path) -{ - char *p = strrchr(path, '/'); - - if (!p) - return NULL; - *p = '\0'; - return ++p; -} - static int get_dm_wholedisk(struct sysfs_cxt *cxt, char *diskname, size_t len, dev_t *diskdevno) { diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h index eaaffa281..d85a078de 100644 --- a/libmount/src/mountP.h +++ b/libmount/src/mountP.h @@ -79,16 +79,12 @@ extern int mnt_run_test(struct libmnt_test *tests, int argc, char *argv[]); #endif /* utils.c */ -extern char *stripoff_last_component(char *path); - extern int mnt_valid_tagname(const char *tagname); extern int append_string(char **a, const char *b); extern const char *mnt_statfs_get_fstype(struct statfs *vfs); extern int is_file_empty(const char *name); -extern int mkdir_p(const char *path, mode_t mode); - extern int mnt_is_readonly(const char *path) __attribute__((nonnull)); diff --git a/libmount/src/tab.c b/libmount/src/tab.c index 86d682a0f..77260ab96 100644 --- a/libmount/src/tab.c +++ b/libmount/src/tab.c @@ -46,6 +46,7 @@ #include "mountP.h" #include "strutils.h" #include "loopdev.h" +#include "fileutils.h" static int is_mountinfo(struct libmnt_table *tb) { diff --git a/libmount/src/utils.c b/libmount/src/utils.c index 7700d805a..d97390e94 100644 --- a/libmount/src/utils.c +++ b/libmount/src/utils.c @@ -117,18 +117,6 @@ static int fstype_cmp(const void *v1, const void *v2) return strcmp(s1, s2); } -/* returns basename and keeps dirname in the @path, if @path is "/" (root) - * then returns empty string */ -char *stripoff_last_component(char *path) -{ - char *p = path ? strrchr(path, '/') : NULL; - - if (!p) - return NULL; - *p = '\0'; - return p + 1; -} - /* * Note that the @target has to be an absolute path (so at least "/"). The * @filename returns an allocated buffer with the last path component, for example: |