eval 'sub OBD_EXT2_RUNIT () { &_IOC(3, ord(\'f\'), 61, 4);}' unless
defined(&OBD_EXT2_RUNIT);
-eval 'sub ATTR_MODE () {1;}' unless defined(&ATTR_MODE);
-eval 'sub ATTR_UID () {2;}' unless defined(&ATTR_UID);
-eval 'sub ATTR_GID () {4;}' unless defined(&ATTR_GID);
-eval 'sub ATTR_SIZE () {8;}' unless defined(&ATTR_SIZE);
-eval 'sub ATTR_ATIME () {16;}' unless defined(&ATTR_ATIME);
-eval 'sub ATTR_MTIME () {32;}' unless defined(&ATTR_MTIME);
-eval 'sub ATTR_CTIME () {64;}' unless defined(&ATTR_CTIME);
+eval 'sub OBD_MD_FLALL () {~0;}' unless defined(&OBD_MD_FLALL);
+eval 'sub OBD_MD_FLATIME () {1<<1;}' unless defined(&OBD_MD_FLATIME);
+eval 'sub OBD_MD_FLMTIME () {1<<2;}' unless defined(&OBD_MD_FLMTIME);
+eval 'sub OBD_MD_FLCTIME () {1<<3;}' unless defined(&OBD_MD_FLCTIME);
+eval 'sub OBD_MD_FLSIZE () {1<<4;}' unless defined(&OBD_MD_FLSIZE);
+eval 'sub OBD_MD_FLMODE () {1<<7;}' unless defined(&OBD_MD_FLMODE);
+eval 'sub OBD_MD_FLUID () {1<<8;}' unless defined(&OBD_MD_FLUID);
+eval 'sub OBD_MD_FLGID () {1<<9;}' unless defined(&OBD_MD_FLGID);
use Getopt::Long;
use File::stat;
use IO::Handle;
-# NOTE long long are layed out in memory as follows:
+# NOTE long long are layed out in ia32 memory as follows:
# u = 0xaaaabbbbccccdddd has ccccdddd at &u and aaaabbbb 4 bytes on
# this may be different on other architectures
-# we use 32 bit integers for all 64 quantities in this program
-# #define OBD_INLINESZ 60
+# we use 32-bit integers for all 64-bit quantities in this program
+# #define OBD_INLINESZ 64
# #define OBD_OBDMDSZ 64
# /* Note: 64-bit types are 64-bit aligned in structure */
# struct obdo {
sub obdo_pack {
my $obdo = shift;
- pack "LL LL LL LL LL LL LL L L L L L L L L 60c 64c L L L",
+ pack "LL LL LL LL LL LL LL L L L L L L L L a60 a64 L L L",
$obdo->{id}, 0,
$obdo->{gr}, 0,
$obdo->{atime}, 0,
$obdo->{mode},
$obdo->{uid},
$obdo->{gid},
- $obdo->{flag},
- $obdo->{obdoflags},
+ $obdo->{flags},
+ $obdo->{obdflags},
$obdo->{nlink},
$obdo->{valid},
$obdo->{inline},
$obdo->{mode},
$obdo->{uid},
$obdo->{gid},
- $obdo->{flag},
- $obdo->{obdoflags},
+ $obdo->{flags},
+ $obdo->{obdflags},
$obdo->{nlink},
$obdo->{valid},
$obdo->{inline},
- $obdo->{obdmd}) = unpack $offset . "xL4x L4x L4x L4x L4x L4x L4x L L L L L L L L 60c 64c", $buf;
+ $obdo->{obdmd}) = unpack "x${offset}Lx4 Lx4 Lx4 Lx4 Lx4 Lx4 Lx4 L L L L L L L L a60 a64", $buf;
+ $obdo;
}
sub obdo_print {
- printf "id: %d\ngrp: %d\natime: %s\natime: %s\nmtime: %s\nctime: %s\nsize: %d\nblocks: %d\nblksize: %d\nmode: %x\nuid: %d\ngid: %d\nflag: %x\nobdflag: %x\nnlink: %d\nvalid: %x\ninline: %s\obdmd: %s\n",
- $obdo->{id},
+ my $obdo = shift;
+
+ printf "id: %d\ngrp: %d\natime: %s\nmtime: %s\nctime: %s\nsize: %d\nblocks: %d\nblksize: %d\nmode: %o\nuid: %d\ngid: %d\nflags: %x\nobdflags: %x\nnlink: %d\nvalid: %x\ninline: %s\nobdmd: %s\n",
+ $obdo->{id},
$obdo->{gr},
$obdo->{atime},
$obdo->{mtime},
$obdo->{mode},
$obdo->{uid},
$obdo->{gid},
- $obdo->{flag},
- $obdo->{obdoflags},
- $obdo->{nlink},
- $obdo->{valid},
+ $obdo->{flags},
+ $obdo->{obdflags},
+ $obdo->{nlink},
+ $obdo->{valid},
$obdo->{inline},
$obdo->{obdmd};
}
-# XXXXXXXXXXXXXXXXXX
-# test here
-
- $obdo->{id}= 1;
- $obdo->{gr}= 2;
- $obdo->{atime}= 3;
- $obdo->{mtime}= 4;
- $obdo->{ctime}= 5;
- $obdo->{size}= 6;
- $obdo->{blocks}= 7;
- $obdo->{blksize}= 8;
- $obdo->{mode}= 9;
- $obdo->{uid}= 10;
- $obdo->{gid}= 11;
- $obdo->{flag}= 12;
- $obdo->{obdoflags}= ;
- $obdo->{nlink}= ;
- $obdo->{valid}= ;
- $obdo->{inline}= ;
- $obdo->{obdmd};
-
-# print, pack and unpack and print
-
-print "XXXXXXXX testing done\n";
-exit;
-
-
my ($file);
GetOptions("f!" => \$file, "device=s" => \$::device, ) || die "Getoptions";
$data = pack("iii", $snapdev, $snapidx, $tableno);
$datalen = 3 * 4;
} elsif ($type eq "ext2_obd") {
- 1;
+ $data = pack("i", 4711); # bogus data
+ $datalen = 0;
} else {
print "error: unknown attach type $type\n";
goto usage;
print "Creating 1 object...\n";
$rc = ioctl(DEV_OBD, &OBD_IOC_CREATE, $packed);
if (!defined($quiet)) {
- my $ino = unpack("L", $packed);
- print "Created object #$ino.\n";
+ my $obdo = obdo_unpack($packed, 4);
+ print "Created object #$obdo->{id}.\n";
}
} else {
my $i;
my $arg = shift;
if (!defined($arg) || scalar($arg) < 1) {
- print "destroy requires the object number to destroy.\n";
+ print "usage: destroy <object number>\n";
return;
}
# see Setattr
my $obdo;
$obdo->{id} = $inode;
+ $obdo->{valid} = &OBD_MD_FLALL;
my $packed = pack("L", $::client_id) . obdo_pack($obdo);
my $rc = ioctl(DEV_OBD, &OBD_IOC_GETATTR, $packed);
}
my $inode = shift;
- my $valid = 0;
- my $mode = oct(shift);
- my $uid = shift;
- my $gid = shift;
- my $size = shift;
- my $atime = shift;
- my $mtime = shift;
- my $ctime = shift;
- if (defined($uid)) {
- $valid |= &ATTR_UID;
+ if (!defined($inode) || scalar($inode) < 1) {
+ print "invalid arguments; type \"help setattr\" for a synopsis\n";
+ return;
}
- if (defined($gid)) {
- $valid |= &ATTR_GID;
+
+ # XXX we do not currently set all of the fields in the obdo
+ my $obdo;
+ $obdo->{id} = $inode;
+ $obdo->{mode} = oct(shift);
+ $obdo->{uid} = shift;
+ $obdo->{gid} = shift;
+ $obdo->{size} = shift;
+ $obdo->{atime} = shift;
+ $obdo->{mtime} = shift;
+ $obdo->{ctime} = shift;
+ $obdo->{valid} = 0;
+
+ if (defined($obdo->{atime})) {
+ $obdo->{valid} |= &OBD_MD_FLATIME;
}
- if (defined($size)) {
- $valid |= &ATTR_SIZE;
+ if (defined($obdo->{mtime})) {
+ $obdo->{valid} |= &OBD_MD_FLMTIME;
}
- if (defined($atime)) {
- $valid |= &ATTR_ATIME;
+ if (defined($obdo->{ctime})) {
+ $obdo->{valid} |= &OBD_MD_FLCTIME;
}
- if (defined($mtime)) {
- $valid |= &ATTR_MTIME;
+ if (defined($obdo->{size})) {
+ $obdo->{valid} |= &OBD_MD_FLSIZE;
}
- if (defined($ctime)) {
- $valid |= &ATTR_CTIME;
+ if (defined($obdo->{mode})) {
+ $obdo->{valid} |= &OBD_MD_FLMODE;
}
- if (defined($mode)) {
- $valid |= &ATTR_MODE;
+ if (defined($obdo->{uid})) {
+ $obdo->{valid} |= &OBD_MD_FLUID;
}
-
- if (!defined($inode) || scalar($inode) < 1) {
- print "invalid arguments; type \"help setattr\" for a synopsis\n";
- return;
+ if (defined($obdo->{gid})) {
+ $obdo->{valid} |= &OBD_MD_FLGID;
}
- #struct iattr {
- # unsigned int ia_valid; (32)
- # umode_t ia_mode; (16)
- # uid_t ia_uid; (16)
- # gid_t ia_gid; (16)
- # -- 16 bit alignment here! --
- # off_t ia_size; (32)
- # time_t ia_atime; (32)
- # time_t ia_mtime; (32)
- # time_t ia_ctime; (32)
- # unsigned int ia_attr_flags; (32)
- #};
-
- printf "valid is %x, mode is %o\n", $valid, $mode;
- my $packed = pack("ILLSssx2ILLLL", $::client_id, $inode, $valid, $mode,
- $uid, $gid, $size, $atime, $mtime, $ctime, 0);
+ printf "valid is %x, mode is %o\n", $obdo->{valid}, $obdo->{mode};
+ my $packed = pack("L", $::client_id) . obdo_pack($obdo);
my $rc = ioctl(DEV_OBD, &OBD_IOC_SETATTR, $packed);
if (!defined $rc) {