summaryrefslogtreecommitdiffstats
path: root/libmount
diff options
context:
space:
mode:
authorSami Kerola2013-08-29 16:50:17 +0200
committerSami Kerola2013-08-29 19:14:08 +0200
commit199e939d88333162f440ea50b83415dac625c89c (patch)
tree33b50feb3b2a065311e3c1477971e728e1fffccc /libmount
parentlib/time-util: copy time parsing functions from systemd (diff)
downloadkernel-qcow2-util-linux-199e939d88333162f440ea50b83415dac625c89c.tar.gz
kernel-qcow2-util-linux-199e939d88333162f440ea50b83415dac625c89c.tar.xz
kernel-qcow2-util-linux-199e939d88333162f440ea50b83415dac625c89c.zip
lib/strutils: move *swith() functions to private library
Avoid code dublication in libmount and time-util. Proposed-by: Karel Zak <kzak@redhat.com> Reference: http://markmail.org/message/h7zexvqsieqngtmx Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'libmount')
-rw-r--r--libmount/src/context_mount.c1
-rw-r--r--libmount/src/mountP.h5
-rw-r--r--libmount/src/optmap.c1
-rw-r--r--libmount/src/utils.c31
4 files changed, 2 insertions, 36 deletions
diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c
index 94db1acda..4f376e4dd 100644
--- a/libmount/src/context_mount.c
+++ b/libmount/src/context_mount.c
@@ -21,6 +21,7 @@
#include "linux_version.h"
#include "mountP.h"
+#include "strutils.h"
/*
* Kernel supports only one MS_PROPAGATION flag change by one mount(2) syscall,
diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h
index 9e6f4bd28..9362c0042 100644
--- a/libmount/src/mountP.h
+++ b/libmount/src/mountP.h
@@ -137,11 +137,6 @@ extern int mnt_run_test(struct libmnt_test *tests, int argc, char *argv[]);
#endif
/* utils.c */
-extern int endswith(const char *s, const char *sx)
- __attribute__((nonnull));
-extern int startswith(const char *s, const char *sx)
- __attribute__((nonnull));
-
extern char *stripoff_last_component(char *path);
extern int mnt_valid_tagname(const char *tagname);
diff --git a/libmount/src/optmap.c b/libmount/src/optmap.c
index 504a5cf85..5b25b8f29 100644
--- a/libmount/src/optmap.c
+++ b/libmount/src/optmap.c
@@ -58,6 +58,7 @@
* mount/mount.h.
*/
#include "mountP.h"
+#include "strutils.h"
/*
* fs-independent mount flags (built-in MNT_LINUX_MAP)
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index 4e6a13148..9f992412f 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -23,37 +23,6 @@
#include "env.h"
#include "match.h"
-int endswith(const char *s, const char *sx)
-{
- ssize_t off;
-
- assert(s);
- assert(sx);
-
- off = strlen(s);
- if (!off)
- return 0;
- off -= strlen(sx);
- if (off < 0)
- return 0;
-
- return !strcmp(s + off, sx);
-}
-
-int startswith(const char *s, const char *sx)
-{
- size_t off;
-
- assert(s);
- assert(sx);
-
- off = strlen(sx);
- if (!off)
- return 0;
-
- return !strncmp(s, sx, off);
-}
-
int append_string(char **a, const char *b)
{
size_t al, bl;