On Mon, Sep 13, 2010 at 12:24 PM, Goffredo Baroncelli
<kreij...@gmail.com> wrote:
> +int get_label(char *btrfs_dev)
> +{
> +
> +       int ret;
> +       ret = check_mounted(btrfs_dev);
> +       if (ret < 0)
> +       {
> +              fprintf(stderr, "FATAL: error checking %s mount status\n",
> btrfs_dev);
> +              return -1;
> +       }
> +
> +       if(ret != 0)
> +       {
> +              fprintf(stderr, "FATAL: the filesystem has to be
> unmounted\n");
> +              return -2;
> +       }
> +       get_label_unmounted(btrfs_dev);
> +       return 0;
> +}
> +
> +

Why can't the label be read while the fs is mounted?  It shouldn't
hurt anything.  I can read the superblock on my ext3 fs while it's
mounted...  This is what people have come to expect.

> --- a/utils.c
> +++ b/utils.c
> @@ -638,6 +638,39 @@ int check_mounted(char *file)
>        return ret;
>  }
>
> +/* Gets the mount point of btrfs filesystem that is using the specified
> device.
> + * Returns 0 is everything is good, <0 if we have an error.
> + * TODO: Fix this fucntion and check_mounted to work with multiple drive
> BTRFS
> + * setups.
> + */

Typo: s/fucntion/function/g


> +int get_mountpt(char *dev, char *mntpt, size_t size)
> +{
> +       struct mntent *mnt;
> +       FILE *f;
> +       int ret = 0;
> +
> +       f = setmntent("/proc/mounts", "r");
> +       if (f == NULL)
> +               return -errno;
> +
> +       while ((mnt = getmntent(f)) != NULL )
> +       {
> +               if (strcmp(dev, mnt->mnt_fsname) == 0)
> +               {
> +                       strncpy(mntpt, mnt->mnt_dir, size);
> +                       break;
> +               }
> +       }
> +
> +       if (mnt == NULL)
> +       {
> +               /* We didn't find an entry so lets report an error */
> +               ret = -1;
> +       }
> +
> +       return ret;
> +}
> +
>  struct pending_dir {
>        struct list_head list;
>        char name[256];
> @@ -820,3 +853,27 @@ char *pretty_sizes(u64 size)
>        return pretty;
>  }
>
> +/*
> + * Checks to make sure that the label matches our requirements.
> + * Returns:
> +       0    if everything is safe and usable
> +      -1    if the label is too long
> +      -2    if the label contains an invalid character
> + */
> +int check_label(char *input)
> +{
> +       int i;
> +       int len = strlen(input);
> +
> +       if (len > BTRFS_LABEL_SIZE) {
> +               return -1;
> +       }
> +
> +       for (i = 0; i < len; i++) {
> +               if (input[i] == '/' || input[i] == '\\') {
> +                       return -2;
> +               }
> +       }
> +
> +       return 0;
> +}

How can one char equal two chars?

input[i] == '\\'

This should never be able to happen.  Right?
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to