Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use uint64 for blockdevice and partition sizes. #43

Merged
merged 1 commit into from
Apr 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions blockdevice.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ type blockdevice struct {
usedFor string
tags []string

blockSize int
usedSize int
size int
blockSize uint64
usedSize uint64
size uint64

partitions []*partition
}
Expand Down Expand Up @@ -57,17 +57,17 @@ func (b *blockdevice) Tags() []string {
}

// BlockSize implements BlockDevice.
func (b *blockdevice) BlockSize() int {
func (b *blockdevice) BlockSize() uint64 {
return b.blockSize
}

// UsedSize implements BlockDevice.
func (b *blockdevice) UsedSize() int {
func (b *blockdevice) UsedSize() uint64 {
return b.usedSize
}

// Size implements BlockDevice.
func (b *blockdevice) Size() int {
func (b *blockdevice) Size() uint64 {
return b.size
}

Expand Down Expand Up @@ -135,9 +135,9 @@ func blockdevice_2_0(source map[string]interface{}) (*blockdevice, error) {
"used_for": schema.String(),
"tags": schema.List(schema.String()),

"block_size": schema.ForceInt(),
"used_size": schema.ForceInt(),
"size": schema.ForceInt(),
"block_size": schema.ForceUint(),
"used_size": schema.ForceUint(),
"size": schema.ForceUint(),

"partitions": schema.List(schema.StringMap(schema.Any())),
}
Expand Down Expand Up @@ -165,9 +165,9 @@ func blockdevice_2_0(source map[string]interface{}) (*blockdevice, error) {
usedFor: valid["used_for"].(string),
tags: convertToStringSlice(valid["tags"]),

blockSize: valid["block_size"].(int),
usedSize: valid["used_size"].(int),
size: valid["size"].(int),
blockSize: valid["block_size"].(uint64),
usedSize: valid["used_size"].(uint64),
size: valid["size"].(uint64),

partitions: partitions,
}
Expand Down
6 changes: 3 additions & 3 deletions blockdevice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ func (*blockdeviceSuite) TestReadBlockDevices(c *gc.C) {
c.Check(blockdevice.Path(), gc.Equals, "/dev/disk/by-dname/sda")
c.Check(blockdevice.UsedFor(), gc.Equals, "MBR partitioned with 1 partition")
c.Check(blockdevice.Tags(), jc.DeepEquals, []string{"rotary"})
c.Check(blockdevice.BlockSize(), gc.Equals, 4096)
c.Check(blockdevice.UsedSize(), gc.Equals, 8586788864)
c.Check(blockdevice.Size(), gc.Equals, 8589934592)
c.Check(blockdevice.BlockSize(), gc.Equals, uint64(4096))
c.Check(blockdevice.UsedSize(), gc.Equals, uint64(8586788864))
c.Check(blockdevice.Size(), gc.Equals, uint64(8589934592))

partitions := blockdevice.Partitions()
c.Assert(partitions, gc.HasLen, 1)
Expand Down
2 changes: 1 addition & 1 deletion dependencies.tsv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/juju/errors git 1b5e39b83d1835fa480e0c2ddefb040ee82d58b3 2015-09-16T12:56:42Z
github.com/juju/loggo git 8477fc936adf0e382d680310047ca27e128a309a 2015-05-27T03:58:39Z
github.com/juju/names git 8a0aa0963bbacdc790914892e9ff942e94d6f795 2016-03-30T15:05:33Z
github.com/juju/schema git 1e25943f8c6fd6815282d6f1ac87091d21e14e19 2016-03-01T11:16:46Z
github.com/juju/schema git 075de04f9b7d7580d60a1e12a0b3f50bb18e6998 2016-04-20T04:42:03Z
github.com/juju/testing git 162fafccebf20a4207ab93d63b986c230e3f4d2e 2016-04-04T09:43:17Z
github.com/juju/utils git eb6cb958762135bb61aed1e0951f657c674d427f 2016-04-11T02:40:59Z
github.com/juju/version git ef897ad7f130870348ce306f61332f5335355063 2015-11-27T20:34:00Z
Expand Down
8 changes: 4 additions & 4 deletions interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ type Partition interface {
// UsedFor is a human readable string.
UsedFor() string
// Size is the number of bytes in the partition.
Size() int
Size() uint64
}

// BlockDevice represents an entire block device on the machine.
Expand All @@ -334,9 +334,9 @@ type BlockDevice interface {
UsedFor() string
Tags() []string

BlockSize() int
UsedSize() int
Size() int
BlockSize() uint64
UsedSize() uint64
Size() uint64

Partitions() []Partition

Expand Down
8 changes: 4 additions & 4 deletions partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type partition struct {
uuid string

usedFor string
size int
size uint64

filesystem *filesystem
}
Expand Down Expand Up @@ -48,7 +48,7 @@ func (p *partition) UsedFor() string {
}

// Size implements Partition.
func (p *partition) Size() int {
func (p *partition) Size() uint64 {
return p.size
}

Expand Down Expand Up @@ -105,7 +105,7 @@ func partition_2_0(source map[string]interface{}) (*partition, error) {
"uuid": schema.String(),

"used_for": schema.String(),
"size": schema.ForceInt(),
"size": schema.ForceUint(),

"filesystem": schema.OneOf(schema.Nil(""), schema.StringMap(schema.Any())),
}
Expand All @@ -132,7 +132,7 @@ func partition_2_0(source map[string]interface{}) (*partition, error) {
path: valid["path"].(string),
uuid: valid["uuid"].(string),
usedFor: valid["used_for"].(string),
size: valid["size"].(int),
size: valid["size"].(uint64),
filesystem: filesystem,
}
return result, nil
Expand Down
2 changes: 1 addition & 1 deletion partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (*partitionSuite) TestReadPartitions(c *gc.C) {
c.Check(partition.Path(), gc.Equals, "/dev/disk/by-dname/sda-part1")
c.Check(partition.UUID(), gc.Equals, "6199b7c9-b66f-40f6-a238-a938a58a0adf")
c.Check(partition.UsedFor(), gc.Equals, "ext4 formatted filesystem mounted at /")
c.Check(partition.Size(), gc.Equals, 8581545984)
c.Check(partition.Size(), gc.Equals, uint64(8581545984))

fs := partition.FileSystem()
c.Assert(fs, gc.NotNil)
Expand Down