On 4/13/22 09:22, Tarun Sahu wrote:
Following to the previous patch in this series,
once the namespace info has been collected in ns_info,
while writing to the infoblock for sector mode, it can be
written with original infoblock values except the ones that
have been provided by parameter arguments to write-infoblock command.

<snip>

  }
+static int write_btt_sb(const int fd, unsigned long long size, struct ns_info *ns_info)
+{
+       int rc = 0;
+       uuid_t uuid, parent_uuid;
+
+       // updating the original values which are asked to change,
+       // rest will be unchanged
+       if (param.uuid) {
+               rc = uuid_parse(param.uuid, uuid);
+               if (rc) {
+                       pr_verbose("Failed to parse UUID");

Use error("Failed ... instead

+                       return rc;
+               }
+               memcpy(((struct btt_sb *)(ns_info->ns_sb_buf + 
ns_info->offset))->uuid,
+                               uuid, sizeof(uuid_t));
+       }
+       if (param.parent_uuid) {
+               rc = uuid_parse(param.parent_uuid, parent_uuid);
+               if (rc) {
+                       pr_verbose("Failed to parse UUID");

Same here

+                       return rc;
+               }
+               memcpy(((struct btt_sb *)(ns_info->ns_sb_buf + 
ns_info->offset))->parent_uuid,
+                               parent_uuid, sizeof(uuid_t));
+       }
+
+       if (pwrite(fd, ns_info->ns_sb_buf + ns_info->offset, sizeof(struct 
btt_sb),
+                              ns_info->offset) < 0) {
+               pr_verbose("Unable to write the info block: %s\n",
+                               strerror(errno));

Same here
+               rc = -errno;
+       }
+
+       if (pwrite(fd, ns_info->ns_sb_buf + ns_info->offset, sizeof(struct 
btt_sb),
+                               size - sizeof(struct btt_sb)) < 0) {
+               pr_verbose("Unable to write the info block: %s\n",
+                       strerror(errno));

Same here

Thanks,
Shivaprasad

Reply via email to