[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH v2] storage: List directory volumes for dir/fs/netfs pools



On 05/26/2011 01:34 PM, Cole Robinson wrote:
> Since directories can be used for <filesystem> passthrough, they are
> basically storage volumes.
> 
> v2:
>     Skip ., .., lost+found dirs
> 
> Signed-off-by: Cole Robinson <crobinso redhat com>
> ---
>  src/storage/storage_backend.c    |   44 +++++++++++++++++++++++++++++++------
>  src/storage/storage_backend.h    |    7 +++++-
>  src/storage/storage_backend_fs.c |   14 ++++++++---
>  src/util/storage_file.c          |   30 +++++++++++++++++++++++++-
>  4 files changed, 82 insertions(+), 13 deletions(-)

Almost there.

> 
> diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
> index 02e455f..77095f2 100644
> --- a/src/storage/storage_backend.c
> +++ b/src/storage/storage_backend.c
> @@ -994,6 +994,7 @@ virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
>  {
>      int fd, mode = 0;
>      struct stat sb;
> +    char *base = basename(path);

basename() is not portable (some, but not all, implementations modify
the string in place, and it is not required to be threadsafe).  Instead,
use "dirname.h" from gnulib (we already have it imported) and the
function base_name() (which malloc's the result) or last_component()
(which returns a pointer into the middle of path).

> +    else if (S_ISDIR(sb.st_mode)) {
> +        mode = VIR_STORAGE_VOL_OPEN_DIR;
> +
> +        if (STREQ(base, ".") ||
> +            STREQ(base, "..") ||
> +            STREQ(base, "lost+found")) {

Given your usage, I think last_component() is the better fit.

ACK with that fixed.

-- 
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]