]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: make __buffer_append_option() usable in entire lib
authorKarel Zak <kzak@redhat.com>
Fri, 24 Jun 2022 14:52:46 +0000 (16:52 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Jan 2023 11:53:12 +0000 (12:53 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/mountP.h
libmount/src/optstr.c

index 0fc972753aa1029600c2fd9a2502397086afa7f4..49bcdd0b7288cc8ab710d2251fb4796392d1ee82 100644 (file)
@@ -27,6 +27,7 @@
 #include "c.h"
 #include "list.h"
 #include "debug.h"
+#include "buffer.h"
 #include "libmount.h"
 
 /*
@@ -470,6 +471,10 @@ extern int mnt_optstr_fix_uid(char **optstr, char *value, size_t valsz, char **n
 extern int mnt_optstr_fix_secontext(char **optstr, char *value, size_t valsz, char **next);
 extern int mnt_optstr_fix_user(char **optstr);
 
+extern int mnt_buffer_append_option(struct ul_buffer *buf,
+                        const char *name, size_t namesz,
+                        const char *val, size_t valsz);
+
 /* fs.c */
 extern struct libmnt_fs *mnt_copy_mtab_fs(const struct libmnt_fs *fs);
 extern int __mnt_fs_set_source_ptr(struct libmnt_fs *fs, char *source)
index 0ad5bfdc6d4a3331fc1e78f74f23b37b76f29a7c..4b3ccca996d1b8ce46594ef5d98d29282a24faa9 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "strutils.h"
 #include "mountP.h"
-#include "buffer.h"
 
 /*
  * Option location
@@ -104,7 +103,7 @@ int mnt_optstr_next_option(char **optstr, char **name, size_t *namesz,
        return ul_optstr_next(optstr, name, namesz, value, valuesz);
 }
 
-static int __buffer_append_option(struct ul_buffer *buf,
+int mnt_buffer_append_option(struct ul_buffer *buf,
                        const char *name, size_t namesz,
                        const char *val, size_t valsz)
 {
@@ -151,7 +150,7 @@ int mnt_optstr_append_option(char **optstr, const char *name, const char *value)
        ul_buffer_refer_string(&buf, *optstr);
        ul_buffer_set_chunksize(&buf, osz + nsz + vsz + 3);     /* to call realloc() only once */
 
-       rc = __buffer_append_option(&buf, name, nsz, value, vsz);
+       rc = mnt_buffer_append_option(&buf, name, nsz, value, vsz);
 
        *optstr = ul_buffer_get_data(&buf, NULL, NULL);
        return rc;
@@ -182,7 +181,7 @@ int mnt_optstr_prepend_option(char **optstr, const char *name, const char *value
 
        ul_buffer_set_chunksize(&buf, osz + nsz + vsz + 3);   /* to call realloc() only once */
 
-       rc = __buffer_append_option(&buf, name, nsz, value, vsz);
+       rc = mnt_buffer_append_option(&buf, name, nsz, value, vsz);
        if (*optstr && !rc) {
                rc = ul_buffer_append_data(&buf, ",", 1);
                if (!rc)
@@ -480,7 +479,7 @@ int mnt_split_optstr(const char *optstr, char **user, char **vfs,
                if (buf) {
                        if (ul_buffer_is_empty(buf))
                                ul_buffer_set_chunksize(buf, chunsz);
-                       rc = __buffer_append_option(buf, name, namesz, val, valsz);
+                       rc = mnt_buffer_append_option(buf, name, namesz, val, valsz);
                }
                if (rc)
                        break;
@@ -550,7 +549,7 @@ int mnt_optstr_get_options(const char *optstr, char **subset,
                if (valsz && mnt_optmap_entry_novalue(ent))
                        continue;
 
-               rc = __buffer_append_option(&buf, name, namesz, val, valsz);
+               rc = mnt_buffer_append_option(&buf, name, namesz, val, valsz);
                if (rc)
                        break;
        }
@@ -765,7 +764,7 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
                        } else
                                sz = strlen(ent->name);
 
-                       rc = __buffer_append_option(&buf, ent->name, sz, NULL, 0);
+                       rc = mnt_buffer_append_option(&buf, ent->name, sz, NULL, 0);
                        if (rc)
                                goto err;
                }