[sheepdog] [PATCH v2 1/7] md: add dummy md proper

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Mar 12 01:44:14 CET 2013


At Mon, 11 Mar 2013 16:19:27 +0800,
Liu Yuan wrote:
> 
> diff --git a/sheep/md.c b/sheep/md.c
> new file mode 100644
> index 0000000..1aad8f0
> --- /dev/null
> +++ b/sheep/md.c
> @@ -0,0 +1,180 @@
> +/*
> + * Copyright (C) 2013 Taobao Inc.
> + *
> + * Liu Yuan <namei.unix at gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License version
> + * 2 as published by the Free Software Foundation.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program. If not, see <http://www.gnu.org/licenses/>.
> + */
> +#include <linux/limits.h>
> +#include <sys/types.h>
> +#include <sys/statvfs.h>
> +#include <sys/stat.h>
> +#include <stdint.h>
> +#include <unistd.h>
> +#include <errno.h>
> +#include <math.h>
> +#include <sys/xattr.h>
> +
> +#include "sheep_priv.h"
> +
> +#define SD_DEFAULT_RAID_VDISKS 128

Should be SD_DEFAULT_MD_VDISKS.

> +
> +int md_init_disk(char *path)
> +{
> +	md_nr_disks++;
> +
> +	if (mkdir(path, def_dmode) < 0)
> +		if (errno != EEXIST)
> +			panic("%s, %m", path);
> +	sd_dprintf("%s added to md, nr %d", path, md_nr_disks);
> +	memcpy(md_disks[md_nr_disks - 1].path, path, PATH_MAX);

There is no guarantee that path has enough buffer size for this
operation.  Use pstrcpy instead.

Thanks,

Kazutaka



More information about the sheepdog mailing list