The following reply was made to PR bin/146254; it has been noted by GNATS.

From: Jeremie Le Hen <[email protected]>
To: [email protected]
Cc:  
Subject: Re: bin/146254: [PATCH] mdmfs(8): Add -k option to specify a
 skeldir
Date: Wed, 5 May 2010 18:09:33 +0200

 --huq684BweRXVnRxX
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Patch properly attached.
 
 -- 
 Jeremie Le Hen
 
 --huq684BweRXVnRxX
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="mdmfs-k.diff"
 
 Index: mdmfs.8
 ===================================================================
 RCS file: /mnt/repos/freebsd-cvsroot/src/sbin/mdmfs/mdmfs.8,v
 retrieving revision 1.22
 diff -u -p -u -r1.22 mdmfs.8
 --- mdmfs.8    16 Feb 2006 21:28:54 -0000      1.22
 +++ mdmfs.8    2 May 2010 20:43:06 -0000
 @@ -46,6 +46,7 @@ driver
  .Op Fl F Ar file
  .Op Fl f Ar frag-size
  .Op Fl i Ar bytes
 +.Op Fl k Ar skel
  .Op Fl m Ar percent-free
  .Op Fl n Ar rotational-positions
  .Op Fl O Ar optimization
 @@ -170,6 +171,11 @@ memory disk backed by
  The fragment size of the file system in bytes.
  .It Fl i Ar bytes
  Number of bytes per inode.
 +.It Fl k Ar skel
 +Copy the content of directory
 +.Ar skel
 +into
 +.Ar mount-point .
  .It Fl l
  Enable multilabel MAC on the new file system.
  .It Fl L
 Index: mdmfs.c
 ===================================================================
 RCS file: /mnt/repos/freebsd-cvsroot/src/sbin/mdmfs/mdmfs.c,v
 retrieving revision 1.27
 diff -u -p -u -r1.27 mdmfs.c
 --- mdmfs.c    16 Feb 2006 21:28:54 -0000      1.27
 +++ mdmfs.c    2 May 2010 20:50:03 -0000
 @@ -78,6 +78,7 @@ static void   do_mdconfig_detach(void);
  static void    do_mount(const char *, const char *);
  static void    do_mtptsetup(const char *, struct mtpt_info *);
  static void    do_newfs(const char *);
 +static void    do_copy(const char *, const char *);
  static void    extract_ugid(const char *, struct mtpt_info *);
  static int     run(int *, const char *, ...) __printflike(2, 3);
  static void    usage(void);
 @@ -91,7 +92,7 @@ main(int argc, char **argv)
        enum md_types mdtype;           /* The type of our memory disk. */
        bool have_mdtype;
        bool detach, softdep, autounit, newfs;
 -      char *mtpoint, *unitstr;
 +      char *mtpoint, *unitstr, *skel;
        char *p;
        int ch;
        void *set;
 @@ -104,6 +105,7 @@ main(int argc, char **argv)
        autounit = false;
        newfs = true;
        have_mdtype = false;
 +      skel = NULL;
        mdtype = MD_SWAP;
        mdname = MD_NAME;
        mdnamelen = strlen(mdname);
 @@ -123,7 +125,7 @@ main(int argc, char **argv)
                compat = true;
  
        while ((ch = getopt(argc, argv,
 -          "a:b:Cc:Dd:E:e:F:f:hi:LlMm:Nn:O:o:Pp:Ss:t:Uv:w:X")) != -1)
 +          "a:b:Cc:Dd:E:e:F:f:hi:k:LlMm:Nn:O:o:Pp:Ss:t:Uv:w:X")) != -1)
                switch (ch) {
                case 'a':
                        argappend(&newfs_arg, "-a %s", optarg);
 @@ -169,6 +171,9 @@ main(int argc, char **argv)
                case 'i':
                        argappend(&newfs_arg, "-i %s", optarg);
                        break;
 +              case 'k':
 +                      skel = optarg;
 +                      break;
                case 'L':
                        if (compat)
                                usage();
 @@ -287,6 +292,8 @@ main(int argc, char **argv)
                do_newfs(newfs_arg);
        do_mount(mount_arg, mtpoint);
        do_mtptsetup(mtpoint, &mi);
 +      if (skel)
 +              do_copy(mtpoint, skel);
  
        return (0);
  }
 @@ -501,6 +508,23 @@ do_newfs(const char *args)
                errx(1, "newfs exited with error code %d", rv);
  }
  
 +
 +/*
 + * Copy skel into the mountpoint.
 + */
 +static void
 +do_copy(const char *mtpoint, const char *skel)
 +{
 +      int rv;
 +
 +      rv = chdir(skel);
 +      if (rv)
 +              err(1, "chdir to %s", skel);
 +      rv = run(NULL, "/bin/pax -rw -pe . %s", mtpoint);
 +      if (rv)
 +              errx(1, "skel copy failed");
 +}
 +
  /*
   * 'str' should be a user and group name similar to the last argument
   * to chown(1); i.e., a user, followed by a colon, followed by a
 @@ -681,9 +705,9 @@ usage(void)
                fprintf(stderr,
  "usage: %s [-DLlMNPSUX] [-a maxcontig] [-b block-size] [-c cylinders]\n"
  "\t[-d rotdelay] [-E path-mdconfig] [-e maxbpg] [-F file] [-f frag-size]\n"
 -"\t[-i bytes] [-m percent-free] [-n rotational-positions] [-O optimization]\n"
 -"\t[-o mount-options] [-p permissions] [-s size] [-v version]\n"
 -"\t[-w user:group] md-device mount-point\n", name);
 +"\t[-i bytes] [-k skel] [-m percent-free] [-n rotational-positions]\n"
 +"\t[-O optimization] [-o mount-options] [-p permissions] [-s size]\n"
 +"\t[-v version] [-w user:group] md-device mount-point\n", name);
        fprintf(stderr,
  "usage: %s -C [-lNU] [-a maxcontig] [-b block-size] [-c cylinders]\n"
  "\t[-d rotdelay] [-E path-mdconfig] [-e maxbpg] [-F file] [-f frag-size]\n"
 
 --huq684BweRXVnRxX--
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to