]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - lib/fs.c
Tree wide: Drop sockaddr_nl arg
[mirror_iproute2.git] / lib / fs.c
index c59ac564581d0ba9157867d0b5c57ecf1846ec45..86efd4ed2ed8084ad147b5d53e62ac2458ccf289 100644 (file)
--- a/lib/fs.c
+++ b/lib/fs.c
@@ -45,7 +45,7 @@ static char *find_fs_mount(const char *fs_to_find)
                return NULL;
        }
 
-       while (fscanf(fp, "%*s %4096s %127s %*s %*d %*d\n",
+       while (fscanf(fp, "%*s %4095s %127s %*s %*d %*d\n",
                      path, fstype) == 2) {
                if (strcmp(fstype, fs_to_find) == 0) {
                        mnt = strdup(path);
@@ -102,7 +102,6 @@ out:
 int make_path(const char *path, mode_t mode)
 {
        char *dir, *delim;
-       struct stat sbuf;
        int rc = -1;
 
        delim = dir = strdup(path);
@@ -120,20 +119,11 @@ int make_path(const char *path, mode_t mode)
                if (delim)
                        *delim = '\0';
 
-               if (stat(dir, &sbuf) != 0) {
-                       if (errno != ENOENT) {
-                               fprintf(stderr,
-                                       "stat failed for %s: %s\n",
-                                       dir, strerror(errno));
-                               goto out;
-                       }
-
-                       if (mkdir(dir, mode) != 0) {
-                               fprintf(stderr,
-                                       "mkdir failed for %s: %s\n",
-                                       dir, strerror(errno));
-                               goto out;
-                       }
+               rc = mkdir(dir, mode);
+               if (mkdir(dir, mode) != 0 && errno != EEXIST) {
+                       fprintf(stderr, "mkdir failed for %s: %s\n",
+                               dir, strerror(errno));
+                       goto out;
                }
 
                if (delim == NULL)
@@ -182,8 +172,7 @@ int get_command_name(const char *pid, char *comm, size_t len)
                if (nl)
                        *nl = '\0';
 
-               strncpy(comm, name, len - 1);
-               comm[len - 1] = '\0';
+               strlcpy(comm, name, len);
                break;
        }