Filesys-POSIX
view release on metacpan or search on metacpan
internal current working directory pointer will be updated with the directory
inode found; this same inode will also be returned.
- `$fs->fchdir($fd)`
When passed a file descriptor for a directory, update the internal pointer to
the current working directory to that directory resolved from the file
descriptor table, and return the same directory inode. If the inode is not a
directory, an ENOTDIR will be thrown.
- `$fs->chown($path, $uid, $gid)`
Using `$fs->stat()` to locate the inode of the path specified, update that
inode object's 'uid' and 'gid' fields with the values specified. The inode of
the file modified will be returned.
- `$fs->fchown($fd, $uid, $gid)`
Using `$fs->fstat()` to locate the inode of the file descriptor specified,
update that inode object's 'uid' and 'gid' fields with the values specified. A
reference to the affected inode will be returned.
- `$fs->chmod($path, $mode)`
Using `$fs->stat()` to locate the inode of the path specified, update that
inode object's 'mode' field with the value specified. A reference to the
affected inode will be returned.
lib/Filesys/POSIX.pm view on Meta::CPAN
my ( $self, $fd ) = @_;
my $inode = $self->fstat($fd);
$! = 0;
throw &Errno::ENOTDIR unless $inode->dir;
return $self->{'cwd'} = $inode;
}
=item C<$fs-E<gt>chown($path, $uid, $gid)>
Using C<$fs-E<gt>stat()> to locate the inode of the path specified, update that
inode object's 'uid' and 'gid' fields with the values specified. The inode of
the file modified will be returned.
=cut
sub chown {
my ( $self, $path, $uid, $gid ) = @_;
my $inode = $self->stat($path);
$inode->chown( $uid, $gid );
return $inode;
}
=item C<$fs-E<gt>fchown($fd, $uid, $gid)>
Using C<$fs-E<gt>fstat()> to locate the inode of the file descriptor specified,
update that inode object's 'uid' and 'gid' fields with the values specified. A
reference to the affected inode will be returned.
=cut
sub fchown {
my ( $self, $fd, $uid, $gid ) = @_;
my $inode = $self->fstat($fd);
$inode->chown( $uid, $gid );
return $inode;
}
=item C<$fs-E<gt>chmod($path, $mode)>
Using C<$fs-E<gt>stat()> to locate the inode of the path specified, update that
inode object's 'mode' field with the value specified. A reference to the
affected inode will be returned.
lib/Filesys/POSIX/Mem/Inode.pm view on Meta::CPAN
'mode' => $mode,
'dev' => $self->{'dev'},
'parent' => $directory->get('.')
);
$directory->set( $name, $child );
return $child;
}
sub chown {
my ( $self, $uid, $gid ) = @_;
@{$self}{qw(uid gid)} = ( $uid, $gid );
}
sub chmod {
my ( $self, $mode ) = @_;
my $format = $self->{'mode'} & $S_IFMT;
my $perm = $mode & ( $S_IPERM | $S_IPROT );
$self->{'mode'} = $format | $perm;
lib/Filesys/POSIX/Real.pm view on Meta::CPAN
=item C<sticky>
When set to a value evaluating to true, any updates to certain attributes of any
inode brought to life by this module are not committed to disk. When this flag
is used, the following calls only affect the inode in memory, but not on disk:
=over
=item C<$fs-E<gt>chmod>
=item C<$fs-E<gt>chown>
=item C<$fs-E<gt>symlink>
=back
Furthermore, only the following attributes are synced from disk onto their
corresponding memory inodes:
=over
lib/Filesys/POSIX/Real/Inode.pm view on Meta::CPAN
my ( $self, $flags ) = @_;
sysopen(
my $fh, $self->{'path'},
Filesys::POSIX::Bits::System::convertFlagsToSystem($flags)
) or Carp::confess("$!");
return Filesys::POSIX::IO::Handle->new($fh);
}
sub chown {
my ( $self, $uid, $gid ) = @_;
unless ( $self->{'sticky'} ) {
CORE::chown( $uid, $gid, $self->{'path'} ) or Carp::confess("$!");
}
@{$self}{qw(uid gid)} = ( $uid, $gid );
return $self->taint;
}
sub chmod {
my ( $self, $mode ) = @_;
my $format = $self->{'mode'} & $S_IFMT;
lib/Filesys/POSIX/ReducedPrivileges/Inode.pm view on Meta::CPAN
$opts{dev}->exit_filesystem();
# Fix the class of the directory object
bless $self->{directory}, 'Filesys::POSIX::ReducedPrivileges::Directory' if ( ref $self->{directory} );
return $self;
}
# Wrap the normal Inode methods that do actual filesystem activity with privilege dropping and restoring.
BEGIN {
foreach my $method (qw(open chown chmod readlink symlink child)) {
my $super_method = "SUPER::$method";
no strict 'refs';
*{ __PACKAGE__ . "::$method" } = sub {
my ( $self, @args ) = @_;
$self->{dev}->enter_filesystem();
my $context = wantarray();
my @result;
try {
if ($context) {
@result = $self->$super_method(@args);
my $fs = Filesys::POSIX->new( Filesys::POSIX::Mem->new );
my $fd = $fs->open( '/foo', $O_CREAT, $S_IFDIR | 0755 );
my $inode = $fs->fstat($fd);
$fs->fchdir($fd);
ok(
$fs->getcwd eq '/foo',
"Filesys::POSIX->fchdir() changes current directory when passed a directory fd"
);
$fs->fchown( $fd, 500, 500 );
ok(
$inode->{'uid'} == 500,
"Filesys::POSIX->fchown() updates inode's uid properly"
);
ok(
$inode->{'gid'} == 500,
"Filesys::POSIX->fchown() updates inode's gid properly"
);
$fs->fchmod( $fd, 0700 );
ok(
( $inode->{'mode'} & $S_IPERM ) == 0700,
"Filesys::POSIX->fchmod() updates inode's permissions properly"
);
}
{
t/mount_flags.t view on Meta::CPAN
);
#
# Note: These tests take advantage of an internal implementation detail in
# which the inode data is stored in a hash blessed into an Inode package.
#
# Since all inodes are held in their directory entries by reference,
# simply updating the reference returned by stat() suffices.
#
$fs->mkdir( 'foo', 04755 );
$fs->chown( 'foo', 500, 500 );
my $inode = $fs->stat('foo');
$inode->{'atime'} = 1234;
#
# This is the crucial part that would cause an atime update if 'noatime' were
# not specified.
#
$inode = $fs->stat('foo');
( run in 1.654 second using v1.01-cache-2.11-cpan-71847e10f99 )