L4Re/departure

libe2access/host/op_make_dirs.c

391:bc65615a8fed
2022-06-30 Paul Boddie Added missing structure members. mmap-region-flags
     1 /*     2  * Make directories in a filesystem.     3  *     4  * Copyright (C) 2019, 2022 Paul Boddie <paul@boddie.org.uk>     5  *     6  * This program is free software; you can redistribute it and/or     7  * modify it under the terms of the GNU General Public License as     8  * published by the Free Software Foundation; either version 2 of     9  * the License, or (at your option) any later version.    10  *    11  * This program is distributed in the hope that it will be useful,    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    14  * GNU General Public License for more details.    15  *    16  * You should have received a copy of the GNU General Public License    17  * along with this program; if not, write to the Free Software    18  * Foundation, Inc., 51 Franklin Street, Fifth Floor,    19  * Boston, MA  02110-1301, USA    20  */    21     22 #include <stdio.h>    23     24 #include <ext2fs/ext2fs.h>    25     26 #include "image.h"    27 #include "session.h"    28     29     30     31 /* Alternative metadata set by options. */    32     33 extern struct metadata md;    34     35     36     37 /* Make directories in the filesystem image. */    38     39 int make_dirs(ext2_filsys fs, int argc, char *argv[])    40 {    41     int i;    42     const char *path;    43     ext2_ino_t ino;    44     45     /* Make each directory component in the given pathname. */    46     47     for (i = 0; i < argc; i++)    48     {    49         path = argv[i];    50     51         /* Search for the remaining components. */    52     53         if ((!*path) || !image_resolve_by_path(fs, &path, &ino))    54         {    55             fprintf(stderr, "Path exists: %s\n", argv[i]);    56             return 1;    57         }    58     59         /* From the first unrecognised component, make the remaining    60            directories. */    61     62         if (image_make_dirs(fs, &path, ino,    63                             0777 & ~md.mask,    64                             md.have_uid ? md.uid : 0,    65                             md.have_gid ? md.gid : 0))    66         {    67             fprintf(stderr, "Failed to make directory: %s\n", argv[i]);    68             return 1;    69         }    70     }    71     72     return 0;    73 }    74     75 /* vim: tabstop=4 expandtab shiftwidth=4    76 */