GlusterFS-GFAPI-FFI

 view release on metacpan or  search on metacpan

lib/GlusterFS/GFAPI/FFI/Volume.pm  view on Meta::CPAN


        $self->_set_log_file($args{log_file});
        $self->_set_log_level($args{log_level});
    }

    return $retval;
}

sub access
{
    my $self = shift;
    my %args = @_;

    my $retval = GlusterFS::GFAPI::FFI::glfs_success(
                    $self->fs,
                    $args{path},
                    $args{mode});

    return $retval ? 0 : 1;
}

sub chdir
{
    my $self = shift;
    my %args = @_;

    my $retval = GlusterFS::GFAPI::FFI::glfs_chdir($self->fs, $args{path});

    if ($retval < 0)
    {
        confess('glfs_chdir(%s, %s) failed: %s'
            , $self->fs, $args{path}, $!);
    }

    return $retval;
}

sub chmod
{
    my $self = shift;
    my %args = @_;

    my $retval = GlusterFS::GFAPI::FFI::glfs_chmod(
                    $self->fs,
                    $args{path},
                    $args{mode});

    if ($retval < 0)
    {
        confess(
            sprintf('glfs_chmod(%s, %s, %s) failed: %s'
                , $self->fs // 'undef'
                , $args{path} // 'undef'
                , $args{mode} ? sprintf('0%o', $args{mode}) : 'undef'
                , $!));
    }

    return $retval;
}

sub chown
{
    my $self = shift;
    my %args = @_;

    my $retval = GlusterFS::GFAPI::FFI::glfs_chown(
                    $self->fs,
                    $args{path},
                    $args{uid},
                    $args{gid});

    if ($retval < 0)
    {
        confess(
            sprintf('glfs_chown(%s, %s, %s, %s) failed: %s'
                , $self->fs // 'undef'
                , $args{path} // 'undef'
                , $args{uid} // 'undef'
                , $args{gid} // 'undef'
                , $!));
    }

    return $retval;
}

sub exists
{
    my $self = shift;
    my %args = @_;

    return try
    {
        $self->stat(path => $args{path}) ? 1 : 0;
    }
    catch
    {
        return 0;
    };
}

sub getatime
{
    my $self = shift;
    my %args = @_;

    return $self->stat(path => $args{path})->st_atime;
}

sub getctime
{
    my $self = shift;
    my %args = @_;

    return $self->stat(path => $args{path})->st_atime;
}

sub getcwd
{
    my $self = shift;
    my %args = @_;

    my $buf    = "\0" x PATH_MAX;
    my $ptr    = pack('P', $buf);
    my $retval = GlusterFS::GFAPI::FFI::glfs_getcwd(
                    $self->fs,
                    unpack('L!', $ptr),
                    PATH_MAX);

    if ($retval < 0)
    {
        confess(sprintf('glfs_getcwd(%s, %s, %d) failed: %s'
                        , $self->fs, 'buf', PATH_MAX, $!));
    }

    return $buf;

lib/GlusterFS/GFAPI/FFI/Volume.pm  view on Meta::CPAN

=back

=head2 C<get_volume_id>

Returns the volume ID (of type UUID) for the currently mounted volume.

=head2 C<access>

Use the real uid/gid to test for access to path.

=head3 parameters

=over

=item C<path>

Path to be checked.

=item C<mode>

mode should be C<F_OK> to test the existence of path, or it can be the inclusive OR of one or more of C<R_OK>, C<W_OK>, and C<X_OK> to test permissions

=back

=head3 returns

True if access is allowed, False if not

=head2 C<chdir>

Change the current working directory to the given path.

=head3 parameters

=over

=item C<path>

Path to change current working directory to

=back

=head2 C<chmod>

Change mode of path

=head3 parameters

=over

=item C<path>

the item to be modified

=item C<mode>

new mode

=back

=head2 C<chown>

Change owner and group id of path

=head3 parameters

=over

=item C<path>

the path to be modified

=item C<uid>

new user id for path

=item C<gid>

new group id for path

=head2 C<exists>

Returns True if path refers to an existing path.

Returns False for broken symbolic links.

This function may return False if permission is not granted to execute C<stat()> on the requested file, even if the path physically exists.

=head2 C<getatime>

Returns the last access time as reported by C<stat()>

=head2 C<getctime>

Returns the time when changes were made to the path as reported by C<stat()>.
This time is updated when changes are made to the file or dir's inode or the contents of the file.

=head2 C<getcwd>

Returns current working directory.

=head2 C<getmtime>

Returns the time when changes were made to the content of the path as reported by C<stat()>.

=head2 C<getsize>

Return the size of a file in bytes, reported by stat()

=head2 C<getxattr>

Retrieve the value of the extended attribute identified by key for path specified.

=head3 parameters

=over

=item C<path>

Path to file or directory



( run in 1.558 second using v1.01-cache-2.11-cpan-71847e10f99 )