Message ID | 20211114172733.71602-4-sbabic@denx.de |
---|---|
State | Changes Requested |
Headers | show
Return-Path: <swupdate+bncBCXPLOXJ6IKRBGUOYWGAMGQEM5QDDXY@googlegroups.com> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=aO7R52Nd; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::43c; helo=mail-wr1-x43c.google.com; envelope-from=swupdate+bncbcxploxj6ikrbguoywgamgqem5qddxy@googlegroups.com; receiver=<UNKNOWN>) Received: from mail-wr1-x43c.google.com (mail-wr1-x43c.google.com [IPv6:2a00:1450:4864:20::43c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HsfRN0mLtz9ssD for <incoming@patchwork.ozlabs.org>; Mon, 15 Nov 2021 04:27:58 +1100 (AEDT) Received: by mail-wr1-x43c.google.com with SMTP id y4-20020adfd084000000b00186b16950f3sf2576004wrh.14 for <incoming@patchwork.ozlabs.org>; Sun, 14 Nov 2021 09:27:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910875; cv=pass; d=google.com; s=arc-20160816; b=VQYUO3Xs5I2gpD+UorvTeV7FgSSvVKAOpkYEnPKOMUS0oqK3GYovh9NU5l8vz52U+e bGm5qhI7zjnbDSXWMEWbpH+DPw30l5fB5FAdf9uivNK/wx9wTh23KtWYXuwCg5zJYPDF raKG919FqvQwkhqgqW+oHsb86E8mectBBw51GxR4dXNqVQ7fERD+BpRbxiFHpai7M2ij gwvlY/k3X+Lng3/UhucOG6p1f/oEsBTlVs6Y52YK5F/h5nb2D8mQMXbuRcT3FK1K1YfJ N7HsM5zNElFJNVpvxULtDXB/6U+23M17w5geyj1S6dD/gjEfeJXYuBWYVlropP1Nelvh RBmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=Up/DUWe+LQf3OCfsWDg0/vxD9e7pfdC1wJhMAMXLB5s=; b=jfqvIr6gRpw514DLkQdTBht7EA1fBm/DbooWII4N5/LI7SlUGFNz/Cs1QlTuIOBzh2 skioFtL11w1whAq48bad/KcuyWPcpXkRw7ehFciWq1elUyZlCur2R4oqKbAfs3VLJeL9 II00GmABwWzCyI5cnZRgMTO04R7BNA/NOvqM5AM95SUBMI1RqXmCkseItwo40TXJLoaO nEFXhxnGFqJ7PV8SYbHXUyTtjsa0FVog647bMeYUUnKIU2L9MDUXtefZLkwkyYozGmMa tCz+Hj2vFeMfK+5e/ELOLZ1QqUiW5wB+Hs0l3OjwAN/FgY3bZ/yKwXpnRK0mCgsZdwTi RLWA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Up/DUWe+LQf3OCfsWDg0/vxD9e7pfdC1wJhMAMXLB5s=; b=aO7R52Nd6Bm5WEFATTi2kcpMF8Db5P/lmEGfMayGAwHIHer+vo1J5rIVe0Tg5xXqPf P3eircGtg+cDakOlBMFzURZhmI2L0BPGukMtmKxS5kUV5evbQaVsF394XwNGGES4Sxca HgOiz/n7H+3/ApfJYKO5WZ2xxER3QQ4yKqc7fAS/pCjd0iK/yso5lABIBdC1omdOxkIG u3AnC1KaOV6iMzAls5H6BgYxntxmFny/UrBJ/GadzFALdvdZMnxAaNiO2jWcsvsM6f+/ Z0YdgsQ2S9mvtmmz+8ZUK8JrVugVRDhArODKP4oYgElYu3kEIfyFncnHeotSFd+Cy04p GU4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Up/DUWe+LQf3OCfsWDg0/vxD9e7pfdC1wJhMAMXLB5s=; b=YUnoX5DcLt4t3Web5kmrKlaBvnTcTYQn9NDThs77diYA3x8fTDhs0v2ASBvWgM9nKj IEW8Nyzp72HWxccg79tn9wFHEFnKlK9MpgzONxWMIE4JtVHZhDmLFTfy1fgXgqdFPzw7 6rHJFxv+aiv1ImXUZYESeQyxanS3GO5wG7asWHofu5YHC4iTCO2iqZ1vCj2wQxrRiYdZ /XFq3cdezMsE/uT7UagkJ5Cz7ljkJUQmYreJa+rSMhgL2JbA8iRJHaujBtKpedEFHF2h A3V7odegkPANouNSWu6f0TzqqMZ/HvKcY1gUiXy6O+qxHNnsTrjzwZZs4tW4YP4eCXPJ kKcg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531b5ZBYiSkIphT5baBIcmT/CuY8Zj+zEuCd8WjiPzRwakftsyV4 /t2JzC4CdZKo/VVAswolWMk= X-Google-Smtp-Source: ABdhPJyzU00M2LcutXAgcIR0V+McDtYmkwiYvl3NyrteYLkSuGbEYWCynJMxNHvYQtqZI29JWLkWHA== X-Received: by 2002:a05:600c:22c7:: with SMTP id 7mr35132178wmg.58.1636910875025; Sun, 14 Nov 2021 09:27:55 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a5d:6a05:: with SMTP id m5ls7200138wru.3.gmail; Sun, 14 Nov 2021 09:27:54 -0800 (PST) X-Received: by 2002:a5d:58f9:: with SMTP id f25mr40387122wrd.206.1636910874323; Sun, 14 Nov 2021 09:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910874; cv=none; d=google.com; s=arc-20160816; b=udrhfcl0uvHpeCVCBcDZt45Mz2LcResjhR+dKuQJPxVadEP3lQ+gCKV+PC2qbBXU77 jC8ISp2p85X2HgDz2er5nn3lZDheiDJ4agNRRvoZ2gDPPtB/3vKIuQEeyd2xHcpz7d40 tnNxKGebuGBU/MLhejrEfs38gTmIS6vFEZeMHqj5XkWqmzbLLPBMwL3/2Pv+OchGcLnk brszaqcQttAY81wd2A8PXKc7uIA0gFs0XHD6CxpRXO8190oSXuDmC534a3GCbGpTFHpW MQNZn2xjOBF2kGxUy0yT3D2SReRiY0rC53pq1cNYFIjQy5EDSeCbO4ss/VtKVl0tbVyt DYyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Va7yFAnmv10dXQ2s5THX6ohh3bimkD64AqcXr5z7TUM=; b=odXo88p8RmvESm1tHJzeRNn3lq8Ah3BEsdzW5uQY8+W/CraUPlQsH9H5fLSUngC+Kf 0JNdUt90jlWIH/HDP1fdNyPL99sA5aef/WpyzzIGIH81T/PXXobJ63tj3cDYHrgzK+T+ xtn0hvjro043zVPUiMQs2l5YHJuWHoitMBcbl1lbQk/jbmcW03hX/kriI6jeId3tt716 rYCpGByN5XAjITaK6kwQZPczAM10j63m9pzygokXGOmR2bglXuxr5wV/RWB3Q70olSNC pgjHLhUjzyGUfysMQHkzl4u5PH5QwKiLHXJKHWqtGDq6IOpLt2ahfUU20IwjaXFKuF4l hG/w== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id c2si1225322wmq.2.2021.11.14.09.27.54 for <swupdate@googlegroups.com> (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:27:54 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRG0pCMz1qwdZ; Sun, 14 Nov 2021 18:27:54 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRG0hs5z1qqkB; Sun, 14 Nov 2021 18:27:54 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id r0NpPvMKja5j; Sun, 14 Nov 2021 18:27:53 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Sun, 14 Nov 2021 18:27:53 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id DDE0345408E4; Sun, 14 Nov 2021 18:27:52 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nWFXCUPCQIvz; Sun, 14 Nov 2021 18:27:48 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 0072C4541B62; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic <sbabic@denx.de> To: swupdate@googlegroups.com Cc: Stefano Babic <sbabic@denx.de> Subject: [swupdate] [PATCH V2 03/36] Add utility function to detect filesystem Date: Sun, 14 Nov 2021 18:27:00 +0100 Message-Id: <20211114172733.71602-4-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: <swupdate.googlegroups.com> X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: <https://groups.google.com/group/swupdate/post>, <mailto:swupdate@googlegroups.com> List-Help: <https://groups.google.com/support/>, <mailto:swupdate+help@googlegroups.com> List-Archive: <https://groups.google.com/group/swupdate List-Subscribe: <https://groups.google.com/group/swupdate/subscribe>, <mailto:swupdate+subscribe@googlegroups.com> List-Unsubscribe: <mailto:googlegroups-manage+605343134186+unsubscribe@googlegroups.com>, <https://groups.google.com/group/swupdate/subscribe> |
Series |
DELTA Update
|
expand
|
diff --git a/fs/diskformat.c b/fs/diskformat.c index 0841f0b..8d58fc3 100644 --- a/fs/diskformat.c +++ b/fs/diskformat.c @@ -39,36 +39,48 @@ static struct supported_filesystems fs[] = { * Checks if file system fstype already exists on device. * return 0 if not exists, 1 if exists, negative values on failure */ -int diskformat_fs_exists(char *device, char *fstype) + +char *diskformat_fs_detect(char *device) { - char buf[10]; - const char *value = buf; + const char *value; + char *s = NULL; size_t len; blkid_probe pr; - int ret = 0; pr = blkid_new_probe_from_filename(device); if (!pr) { ERROR("%s: failed to create libblkid probe", device); - return -EFAULT; + return NULL; } while (blkid_do_probe(pr) == 0) { if (blkid_probe_lookup_value(pr, "TYPE", &value, &len)) { ERROR("blkid_probe_lookup_value failed"); - ret = -EFAULT; break; } - if (!strncmp(value, fstype, sizeof(buf))) { - ret = 1; + if (len > 0) { + s = strndup(value, len); break; } } blkid_free_probe(pr); + return s; +} + +int diskformat_fs_exists(char *device, char *fstype) +{ + int ret = 0; + char *filesystem = diskformat_fs_detect(device); + + if (filesystem) { + ret = !strcmp(fstype, filesystem); + } + + free(filesystem); return ret; } diff --git a/include/fs_interface.h b/include/fs_interface.h index 25c22e5..581f02a 100644 --- a/include/fs_interface.h +++ b/include/fs_interface.h @@ -7,6 +7,7 @@ #ifndef _FS_INTERFACE_H #define _FS_INTERFACE_H +char *diskformat_fs_detect(char *device); int diskformat_fs_exists(char *device, char *fstype); int diskformat_mkfs(char *device, char *fstype);
This can be used to detect a filesystem from a device instead of specify the expected filesystem. Signed-off-by: Stefano Babic <sbabic@denx.de> --- fs/diskformat.c | 28 ++++++++++++++++++++-------- include/fs_interface.h | 1 + 2 files changed, 21 insertions(+), 8 deletions(-)