From 73105a3ac172afff9d749fa0af9276de0cf111e7 Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Mon, 19 Oct 2009 12:13:56 +0200 Subject: [PATCH] osd-target: Process attributes in OSD_FORNAT Set/Get attributes are perfectly valid while formatting an osd-lun, directed to the osd root object. Call attribute processing also in OSD_FORMAT. Print to log output that osd_name was changed. This is an important global attribute that identifies the osd-device on the network. Fix the attribute-page name. Signed-off-by: Boaz Harrosh --- osd-target/cdb.c | 5 ++++- osd-target/osd.c | 21 +++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/osd-target/cdb.c b/osd-target/cdb.c index 52022a9..227376e 100644 --- a/osd-target/cdb.c +++ b/osd-target/cdb.c @@ -1397,7 +1397,10 @@ static void exec_service_action(struct command *cmd) case OSD_FORMAT_OSD: { uint64_t capacity = get_ntohll(&cdb[32]); ret = osd_format_osd(osd, capacity, cdb_cont_len, sense); - /* TODO: what is corresponding get/set attr? */ + + if (ret == OSD_OK) + ret = std_get_set_attr(cmd, 0, 0, cdb_cont_len); + break; } case OSD_GET_ATTRIBUTES: { diff --git a/osd-target/osd.c b/osd-target/osd.c index 5b2472f..e1e47e9 100644 --- a/osd-target/osd.c +++ b/osd-target/osd.c @@ -40,6 +40,12 @@ #include "osd-util/osd-sense.h" #include "list-entry.h" +#define min(x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x < _y ? _x : _y; }) + #ifdef __MAKE_BSD_BUILD__ static int os_sync_file_range(int fd, __off64_t offset, __off64_t bytes, unsigned int flags) @@ -691,7 +697,7 @@ static int get_riap(struct osd_device *osd, uint64_t pid, uint64_t oid, case 0: /*{ROOT_PG + 1, 0, "INCITS T10 Root Information"},*/ len = ATTR_PAGE_ID_LEN; - sprintf(name, "INCITS T10 User Object Information"); + sprintf(name, "INCITS T10 Root Information"); val = name; break; case RIAP_OSD_SYSTEM_ID: @@ -787,10 +793,17 @@ static int set_riap(struct osd_device *osd, uint64_t pid, uint64_t oid, default: return OSD_ERROR; - case RIAP_OSD_NAME: - return attr_set_attr(osd->dbc, pid, oid, ROOT_INFO_PG, - RIAP_OSD_NAME, val, len); + case RIAP_OSD_NAME: { + char osdname[64]; + + snprintf(osdname, min((uint16_t)64U, len), "%s", + (const char *)val); + osd_info("RIAP_OSD_NAME [%s]\n", osdname); + + return attr_set_attr(osd->dbc, 0, 0, ROOT_INFO_PG, + RIAP_OSD_NAME, val, len); + } case RIAP_CLOCK: /* FIXME: Save an offset from current time. return time + offset */