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);
int make_path(const char *path, mode_t mode)
{
char *dir, *delim;
- struct stat sbuf;
int rc = -1;
delim = dir = strdup(path);
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)
if (nl)
*nl = '\0';
- strncpy(comm, name, len - 1);
- comm[len - 1] = '\0';
+ strlcpy(comm, name, len);
break;
}