Skip to content

Commit

Permalink
fixed some get_uiap() bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
joc02012 authored and Chandy committed Oct 18, 2011
1 parent 1b79cc6 commit 116948f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions osd-target/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ static int get_uiap(struct osd_device *osd, uint64_t pid, uint64_t oid,
struct statfs sfs;
uint8_t ll[8];
off_t sz = 0;
uint64_t value;

switch (number) {
case 0:
Expand All @@ -595,12 +596,12 @@ static int get_uiap(struct osd_device *osd, uint64_t pid, uint64_t oid,
val = name;
break;
case UIAP_PID:
set_htonll(ll, pid);
value = pid;
len = UIAP_PID_LEN;
val = ll;
break;
case UIAP_OID:
set_htonll(ll, pid);
value = oid;
len = UIAP_OID_LEN;
val = ll;
break;
Expand All @@ -620,7 +621,7 @@ static int get_uiap(struct osd_device *osd, uint64_t pid, uint64_t oid,

sz = sb.st_blocks*BLOCK_SZ;
}
set_htonll(ll, sz);
value = sz;
val = ll;
break;
case UIAP_LOGICAL_LEN:
Expand All @@ -629,7 +630,7 @@ static int get_uiap(struct osd_device *osd, uint64_t pid, uint64_t oid,
ret = stat(path, &sb);
if (ret != 0)
return OSD_ERROR;
set_htonll(ll, sb.st_size);
value = sb.st_size;
val = ll;
break;
case PARTITION_CAPACITY_QUOTA:
Expand All @@ -640,8 +641,7 @@ static int get_uiap(struct osd_device *osd, uint64_t pid, uint64_t oid,
path, ret, llu(sfs.f_blocks));
if (ret != 0)
return OSD_ERROR;
sz = sfs.f_blocks * BLOCK_SZ;
set_htonll(ll, sz);
value = sfs.f_blocks * BLOCK_SZ;
val = ll;
break;
case UIAP_USERNAME:
Expand All @@ -652,6 +652,8 @@ static int get_uiap(struct osd_device *osd, uint64_t pid, uint64_t oid,
return OSD_ERROR;
}

if (val == ll)
set_htonll(ll, value);
if (listfmt == RTRVD_SET_ATTR_LIST)
ret = le_pack_attr(outbuf, outlen, page, number, len, val);
else if (listfmt == RTRVD_CREATE_MULTIOBJ_LIST)
Expand Down Expand Up @@ -701,7 +703,7 @@ static int set_uiap(struct osd_device *osd, uint64_t pid, uint64_t oid,
}
}

static struct init_attr root_info[] = {
static const struct init_attr root_info[] = {
{ROOT_PG + 0, 0, "INCITS T10 Root Directory "},
{ROOT_PG + 0, ROOT_PG + 1, "INCITS T10 Root Information "},
{ROOT_PG + 0, ROOT_PG + 2, "INCITS T10 Root Quotas "},
Expand All @@ -712,7 +714,7 @@ static struct init_attr root_info[] = {
{ROOT_PG + 5, 0, "INCITS T10 Root Policy/Security "}
};

static struct init_attr partition_info[] = {
static const struct init_attr partition_info[] = {
{PARTITION_PG + 0, 0, "INCITS T10 Partition Directory"},
{PARTITION_PG + 0, PARTITION_PG + 1,
"INCITS T10 Partition Information"},
Expand Down

0 comments on commit 116948f

Please sign in to comment.