From patchwork Mon Dec 15 20:02:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goffredo Baroncelli X-Patchwork-Id: 5497461 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2E39F9F1D4 for ; Mon, 15 Dec 2014 20:02:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6B4C2209E5 for ; Mon, 15 Dec 2014 20:02:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A27E7209D3 for ; Mon, 15 Dec 2014 20:02:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751451AbaLOUCq (ORCPT ); Mon, 15 Dec 2014 15:02:46 -0500 Received: from mail-wg0-f43.google.com ([74.125.82.43]:51441 "EHLO mail-wg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750882AbaLOUCp (ORCPT ); Mon, 15 Dec 2014 15:02:45 -0500 Received: by mail-wg0-f43.google.com with SMTP id l18so15708406wgh.2 for ; Mon, 15 Dec 2014 12:02:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qRfPLPnjUOwEDI4oud7HUtLONKnmWRuDW7k9F8TPRyU=; b=RhTfkJ0vkxYrZ4Mm2akAwrMVHPIaXc4nuLlwKQkPBc9ZK4+cZp3boATFNykHyxnAoi ZGQSbNOTNqX2hkyK4Db11em8B0HyuOyyYKGmIs6td6E896I2QyCkgB1q2EoysU4TupvV 51oHGJLPEfeoF6S/hzrp74LRKFdIBjU8utfPSvaynrJ80gsXeSvUwhtavGSlKFrOEHQI LLjpOqGcoCAY0TGwGybPMBh4/DkSlE3pwyUVV+LsKj+U1pnyh0ltei/k6iObmFn/4h9z FU/c4v7L1i3PUQCSXNZ7w50LwQRCb2f+vHigkdzVzKm6+3e1BV7/q6zT1fPa/mvjuXIq SGwQ== X-Received: by 10.181.13.106 with SMTP id ex10mr34091637wid.36.1418673764218; Mon, 15 Dec 2014 12:02:44 -0800 (PST) Received: from venice.bhome (ppp-222-126.24-151.libero.it. [151.24.126.222]) by mx.google.com with ESMTPSA id kn5sm14212241wjb.48.2014.12.15.12.02.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Dec 2014 12:02:43 -0800 (PST) From: Goffredo Baroncelli X-Google-Original-From: Goffredo Baroncelli To: linux-btrfs@vger.kernel.org Cc: Goffredo Baroncelli Subject: [PATCH 5/7] Return the fsid from make_btrfs() Date: Mon, 15 Dec 2014 21:02:58 +0100 Message-Id: <1418673780-22000-6-git-send-email-kreijack@inwind.it> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1418673780-22000-1-git-send-email-kreijack@inwind.it> References: <1418673780-22000-1-git-send-email-kreijack@inwind.it> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The function make_btrfs() has as argument the fsid of the filesystem. If this fsid is empty or null make_btrfs() generates a new fsid. However If the buffer is valid (but the string is empty) the generated fsid is copied back to the caller. Signed-off-by: Goffredo Baroncelli --- utils.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils.c b/utils.c index 3f50e4d..15127db 100644 --- a/utils.c +++ b/utils.c @@ -203,7 +203,7 @@ int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid, memset(&super, 0, sizeof(super)); num_bytes = (num_bytes / sectorsize) * sectorsize; - if (fs_uuid) { + if (fs_uuid && *fs_uuid) { if (uuid_parse(fs_uuid, super.fsid) != 0) { fprintf(stderr, "could not parse UUID: %s\n", fs_uuid); ret = -EINVAL; @@ -216,6 +216,11 @@ int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid, } } else { uuid_generate(super.fsid); + /* + * if the fs_uuid is a valid pointer, return the generated uuid + */ + if (fs_uuid) + uuid_unparse(super.fsid, fs_uuid); } uuid_generate(super.dev_item.uuid); uuid_generate(chunk_tree_uuid);