From patchwork Thu Mar 11 11:41:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1451091 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::239; helo=mail-lj1-x239.google.com; envelope-from=swupdate+bncbcxploxj6ikrbv4dvcbamgqeksl73hq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=sIjkS8fG; dkim-atps=neutral Received: from mail-lj1-x239.google.com (mail-lj1-x239.google.com [IPv6:2a00:1450:4864:20::239]) (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 ozlabs.org (Postfix) with ESMTPS id 4Dx6Tl2vLnz9sWb for ; Thu, 11 Mar 2021 22:41:15 +1100 (AEDT) Received: by mail-lj1-x239.google.com with SMTP id 74sf8401330ljj.3 for ; Thu, 11 Mar 2021 03:41:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1615462871; cv=pass; d=google.com; s=arc-20160816; b=jx1amXeQKkOssZn78hlNt4tOvkdVYWmCEdpM1JcxP6fofZbiDgKmIL8I+MJIhMjXu/ K8swigyyI1TqoMfVqzVd4SsGQHcnddgz4oQsYwGvVuPvNJy7E2DmmmGqRW3Y2USyGq/c TQu2w6B/YR449DoKh+IOvzK3kmi13KGz6lseXQHWHt/19DTEoM03ALEFZ4ZZgwwaXWYn my8k327dH1ZVhrLVp4Z+tBIjTEds2VZcXxjFfYo9Vvvyy4ssuN5/lTjeS1dC1dr+/NTH B81YhdX4QVd+rN3H29qro3VMsd0uaMNXP1GwRE+JLWOeDDNMfNLm276LVfc2GibOlYmS a2Ng== 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:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=VCoTL44TSz/kFRmTzBHBOcQtVudOoTvqfWina7kIPtU=; b=ryjifbdpvAlf8qSq3LFQRTDoBK9BbwlXMHFC6WQFVBTN+xu8nm7NFeO5KPj0aLnA4N MjFameSogWGyE5WJNZYLtXtDj2oDP0NkmxujfoS49ged+zWWqbkSornY3gsTZxSM0Qnv qjaM2aNrq3hFy9jkJ9VYx57wX0xvEme2GJy0YOWaXSJk7gnS2ke2XqdS23YTaSa8Y0fQ Pjc2fQChmVFgDTF/2wGbLsDN7CElr0sZzv7zwZOyttM5QQqgS4YLMXJFuJS6LLk9TE5g tTxQ271M070SbCMVyzfvUXLMihS3MPV+CmFjwDXeq1oxaQqju42lAeXD9xmbsLJo6sx2 9Vvg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id: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=VCoTL44TSz/kFRmTzBHBOcQtVudOoTvqfWina7kIPtU=; b=sIjkS8fGo3HLprZojk4V1ee3jfIgz8lEgqK23BzWNp6nSg+xymdESCn156Bzy/SNff qQbTLYN7PB28Vt4ftR47GPrtQSznw4y9u845DSpdTXI6qvHP8uE3lOYTd6DxOnqFS+Cu q6dCUHzegozTp/sjs4L1JlBonMt43Kxw5fYwL4zZ2b+8twv+6bhvPuzErIHfQfFCxn9N 5agvyKGQfJA66b25D/jVf4wFmEYf3g4A8GOVeXCIEPPVgIE71Q4/8VI3jmVfwghhfkJu O2tbwK84O6QQVXVIl22X+bnCNPts3IYeLTCoFY3BVYTViqVzX9WZ5wRUlJk6NI/2xHLi 3Qtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :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=VCoTL44TSz/kFRmTzBHBOcQtVudOoTvqfWina7kIPtU=; b=ImGkPPdlWYDkifaoooPZCXvziC4OqVLkFTMu9wC2TBDaDI3/79qsvOF8g9d/cn+c8T m86NepnjoCjYrhlQtIh7oQCBdYvJeOgu83mlRh8jEKJyjTopVMyO9bwmO4ZD3kCBJtCb r2soL7VBtN5Bkm5234+8rhENRut96tHh3UReglV3auW+TbHaxFT+AQxyyEmuIctJ9PD2 W5Mep+XK4wrShaFIHXQL9pgNIVcpLYkYUpyECOsKGyJcVVDjIYbCqF8tYiwym5GMOiup xhJBrR1yi0Ih0RmyWny0A1OXlH3KJHoQPX/y/xPx/vKdQHjU+fcozpnrwkWY+bOFsdsA Vo+A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530d9UOMq/oj0S7d2Cgbm8pAOrnjUXZRohPKxk1KOuAy0Kn7b0Dy qOxqukt42FYh3XOJm692Yu4= X-Google-Smtp-Source: ABdhPJzd9UIN9ClWOUTNfs/J1zh3+HaGzpci9DN91VJ/V/XtQJ453somfvIabr2N9LO1Hx6kSUW9Qg== X-Received: by 2002:a2e:9143:: with SMTP id q3mr4697364ljg.283.1615462871638; Thu, 11 Mar 2021 03:41:11 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:8915:: with SMTP id d21ls1213336lji.1.gmail; Thu, 11 Mar 2021 03:41:10 -0800 (PST) X-Received: by 2002:a2e:864d:: with SMTP id i13mr4465711ljj.48.1615462870704; Thu, 11 Mar 2021 03:41:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615462870; cv=none; d=google.com; s=arc-20160816; b=L2kjdsmB6vF4GaZdz3HEribzmKClELr9hvWATjJFYNoE0kHUO2fm/cJQx6qTMpU+61 2gFJ6sXprFwz3Qh0GFwfJ6/sAl2hn7D9IVsP8NtSAOXsr9ju1DoSfa4Qm5fe6O7XHRQs 4ywRjTN5Z55hUHhqFERuaU1mrucb3iRBPr4kKMdvs1+xzChGzwr9jWRiURXkDcvWcyXa 1g/Ylcja2Y9AqoFPw1UIAVwabarygzJdgwaxDFx+jDtoMPFpSGFIitFxPUZgtNRqS1CA SnB6J46r8zIbyAXDePUBpCaubaRkY0402xvQPYZllPluWV+83jLoaLM900yN1o/1WeVf rwLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=xU7wbnVfOShAz8vkvkm9V8Ws+3NWVqIQ5+MTmRZ8B6g=; b=p9LlS5Xr6no8fLrm17xHkxnGfOegOIlOYBBUdvhPOzc0nqRGJhM9MQBxaD6nnMeF1I EmrsN1yvFWfguGExo0zXzJfB0TGyJ76jZyqbNs6+2v74rxA7vMfScVsU7wEzMO6DVK+D L6Fr6YVO08PQMbaGY7omPIg+Gq+1ukzwiEzSKz9TUFJAZrOrqXAUn7glxZNF2iJStCy/ rCKlpxCS/HjWXxNjUsHYBCblVApUov4BvUijQZMENUWMGZMUqpIZBdlhfXJMU5PuZ93T r26Eanz8hmXhZDG9pIba8ySFzF1OKM4z9UJ2KpcR/fPYud+4rHQy3c5bnUo6Zruuy2pY cSSg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for 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 i30si93176lfj.6.2021.03.11.03.41.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Mar 2021 03:41:10 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for 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 4Dx6Tf1lP3z1qsjl; Thu, 11 Mar 2021 12:41:10 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Dx6Tf1X2Vz1qr4j; Thu, 11 Mar 2021 12:41:10 +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 XWFDLWVQciQG; Thu, 11 Mar 2021 12:41:09 +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; Thu, 11 Mar 2021 12:41:09 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id D02084542848; Thu, 11 Mar 2021 12:41:08 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Fc6hLUFcSa8s; Thu, 11 Mar 2021 12:41:06 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 421BB454016E; Thu, 11 Mar 2021 12:41:06 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 1/2] util: add function to retrieve root device Date: Thu, 11 Mar 2021 12:41:03 +0100 Message-Id: <20210311114104.71593-1-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 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 best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , get_find_root() is a utility function that returns the device mounted as rootfs. Signed-off-by: Stefano Babic --- core/util.c | 35 +++++++++++++++++++++++++++++++++++ include/util.h | 1 + 2 files changed, 36 insertions(+) diff --git a/core/util.c b/core/util.c index 2025276..7c82c2a 100644 --- a/core/util.c +++ b/core/util.c @@ -842,3 +842,38 @@ size_t snescape(char *dst, size_t n, const char *src) return len; } + +/* + * This returns the device name where rootfs is mounted + */ +char *get_root_device(void) +{ + struct stat info; + FILE *fp; + char *devname = NULL; + unsigned long major, minor, nblocks; + char buf[256]; + int ret; + + if (stat("/", &info) < 0) + return NULL; + + fp = fopen("/proc/partitions", "r"); + if (!fp) + return NULL; + + while (fgets(buf, sizeof(buf), fp)) { + ret = sscanf(buf, "%ld %ld %ld %ms", + &major, &minor, &nblocks, &devname); + if (ret != 4) + continue; + if ((major == info.st_dev / 256) && (minor == info.st_dev % 256)) { + fclose(fp); + return devname; + } + free(devname); + } + + fclose(fp); + return NULL; +} diff --git a/include/util.h b/include/util.h index 2987203..8447ab6 100644 --- a/include/util.h +++ b/include/util.h @@ -229,6 +229,7 @@ int set_aes_ivt(const char *ivt); int get_install_info(sourcetype *source, char *buf, size_t len); void get_install_swset(char *buf, size_t len); void get_install_running_mode(char *buf, size_t len); +char *get_root_device(void); /* Setting global information */ void set_version_range(const char *minversion, From patchwork Thu Mar 11 11:41:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1451090 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::239; helo=mail-lj1-x239.google.com; envelope-from=swupdate+bncbcxploxj6ikrbv4dvcbamgqeksl73hq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=TDL1LUQZ; dkim-atps=neutral Received: from mail-lj1-x239.google.com (mail-lj1-x239.google.com [IPv6:2a00:1450:4864:20::239]) (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 ozlabs.org (Postfix) with ESMTPS id 4Dx6Tm0Hyyz9sWj for ; Thu, 11 Mar 2021 22:41:15 +1100 (AEDT) Received: by mail-lj1-x239.google.com with SMTP id d15sf8396233ljl.17 for ; Thu, 11 Mar 2021 03:41:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1615462872; cv=pass; d=google.com; s=arc-20160816; b=Yr/cEqjgF7v48FG+MIr1CNgaHaxiYtzQ+jcvu6tP7FTy4/aK59HuAmJ+i6B003GXtA cZtWiUMur2z0oEnKbWw3Efcu97URjih1B5Ts5GX3FBWeVLANBJnwI6Iy6S+qtErQr+y4 XKjybjvSHxUsw+5q+h99/NZk4FK3GAMe12VrvD6AGTJQcG8NmOTgdAVghraNY714B5mw 8VRRU2DItWC47ewRKyeJdiTHhldCTHRv0R/R8DAym3zxILDPFOtMfLMIEunIF2SBMYND PZBpLMLTCwz2iniGhNGEBrsMed6Cbr2J+bIt6NUr9+gFvUHgol9/yELfLM2tQHokKAxo XXWQ== 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=1OyP252GeeTsdDEwUSvfQpKABHU29EfYBaywfUmrNGA=; b=ufEfg0MpDPlldY3koOxa4CPmwxTGjW9e5DGliOsJ7U+Rhu7Dh5Enzb+zKJBmc/u3nL njJtr3NFXasMnfevzSjfkk9tkW7TwQBBhLkluIc60emQTsMu1FDX6OyBmuZUHLqHZ4KV iQnEvHMqAl3Q1hs9dygeq6frbG3+jP7CGc5hMixnkD3sB48KgtX9s/iQw1pTEc2vQlFD f57FWUhLjG29p6OA7Iw6lWIy4O4XK1NTlJ67Eh2Yu6PhJsd/v7bWiA1aPDdNU6Zx/czu egoOHaGc2H5JJnuCcoWI9RvSRGV+2DnnGnhpjr0nDklQwX3KVQC/7Fg4X6t99J5HR791 n3Uw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; 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=1OyP252GeeTsdDEwUSvfQpKABHU29EfYBaywfUmrNGA=; b=TDL1LUQZ5Nr1ZeaiNCLzibmk+C/T0mJDkr/W1g9YivjYiUS9YX6+mBdE4SPPCSdyR0 vuFT748wnq7HepmVDLo2kbtCQ0Ue1M+/xt53WY7v0VieIHyP16BwtB3J9QummfWiLcV+ vuqfATrJeO6UUeEXKo1mtoisqMGQ4LxcYSf45ZkvpFzMroSS0zBD3UN4PZ0xXKKv/jJ1 p3IvdKc2q4dzqojZgBPmcd3ajWCf+dGpvR+7DRprOYZt4poeblr1dy6j1Fy57z+FpuW3 DLSCpyMMbtR2xy4NZOAPbTzD+qVtdtdyyiJmq2Za3fkS611qVwIFDIlSEuC2s+HqbO6p BmqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=1OyP252GeeTsdDEwUSvfQpKABHU29EfYBaywfUmrNGA=; b=Xl5rO6LTDPRZ+Ci5ZrfNAOZc2FGWVDkRRRM1qJnic3nGV3ZSlT0QLs9bUUSFX0Cd0i 5OdOgtffR9KHORxLaFKY+M6YEDe919l9CTjJEDxxmS7deTCRm25wWRYorQv5VKwbMxoS BFdhKahxo05R8+DePnuFKWWzOVxZhTB3VZTUeTds7oiYp2Z2xNq6fHBwt16yZx//5rvF PR9dhZLEstP5F+ukxvTOgVx6VYDMV2o0k+VWlHHulik/M2TcwkAOYx5Ws1cwDiaDdJs/ YBTIo/YSE57Dxt1TsU6TMh1JXc4gF4HQ5+GCNTIPuWCYsat4TncW57fcdKP3F6vjcrU6 SIuQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533GyNyp1AXWoLXrt+zjj1hEx8tPZx3xyuAKzT8HDsbp+wZopw2F rE25l9GvMc95J75NUoZhQsA= X-Google-Smtp-Source: ABdhPJykvXxV2IZdwCNFbYy7mR/JZjNaql/T2C1eO4+wb11djwCSWZaoO3fMZpbQYCZWKdlrf5pvvw== X-Received: by 2002:a2e:7d03:: with SMTP id y3mr4714491ljc.0.1615462871899; Thu, 11 Mar 2021 03:41:11 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:8915:: with SMTP id d21ls1213338lji.1.gmail; Thu, 11 Mar 2021 03:41:11 -0800 (PST) X-Received: by 2002:a2e:9f54:: with SMTP id v20mr4551976ljk.261.1615462871115; Thu, 11 Mar 2021 03:41:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615462871; cv=none; d=google.com; s=arc-20160816; b=P4nLC5eySclBc89/qfalwP3eyFcCL8zt6rKUSFxgoOzUvjqu0JVmRfP8HTRasYQONc yZgz5pC8raWeZGFh0via9XWlbNfD3IU/ktpc1tO1dMii8NuBJ0tzU66gB+dyPmfSPIfy tlItVpn0yQQO9kMqKakpoasz4fIClRl3eUk1dWJxBs/89rj85DbADzgOUoqSbdd1eJRK WWsyzNAchI89evKqMYdbSTeDh6KfyTsuUhiYIbDJOvgUkuxLrlbUYA/GokBFIY02ul7x 3ANdnuezZjiETNjcU+47FDmHdoEQcjOnMnfYMgFK3fP2oBLxt/H3QpJmCDFz75SQjm0F WmzA== 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=b3D2+i26m1Wkejx/3ENf1092DKGTnAj7x7OjLRu2Pe4=; b=sSPNspGV/QhctjrD5utlA6hXb9MrRw2D32bM6bw7Zwq/CnO24Aasa9FAjA6uklAiYX 67c8u86iFv5w+ZMINU4BpKN53NllWP0oN9wJQO/drWt9iUVxJPZD4Nn20TStrRdxmfqo 5WVX4t97Iq9AGz8EJqBX8c7/61ez2qFCuMRpWoLPnCGFiwR1KwvbAwbJqFAnvOKB8Hox e+V4ch8W/TYlJu4DFt92R8mF73T9elOrvRKiujOYpvfJoT2SOWNugAlquvQETrGuXBPm 9biK4zvDVDa5Ee4SM7oNgmPyXp7zXUcrekI47TQp4GINAsqnvVj71HCsoBamNeXSaDDO ANWw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for 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.10]) by gmr-mx.google.com with ESMTPS id j12si73028lfg.8.2021.03.11.03.41.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Mar 2021 03:41:11 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.10; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Dx6Tf4fDfz1rx8j; Thu, 11 Mar 2021 12:41:10 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Dx6Tf4Qmhz1qr4l; Thu, 11 Mar 2021 12:41:10 +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 RQyLTfNNy_0w; Thu, 11 Mar 2021 12:41:10 +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; Thu, 11 Mar 2021 12:41:10 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id AFC99454016E; Thu, 11 Mar 2021 12:41:09 +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 Lcz5QBszj2ik; Thu, 11 Mar 2021 12:41:06 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 4E3E645407C8; Thu, 11 Mar 2021 12:41:06 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 2/2] Lua: add getroot function Date: Thu, 11 Mar 2021 12:41:04 +0100 Message-Id: <20210311114104.71593-2-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311114104.71593-1-sbabic@denx.de> References: <20210311114104.71593-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.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Stefano Babic --- corelib/lua_interface.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index f9900e4..14a50ce 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -808,6 +808,13 @@ l_umount_exit: return 1; } +static int l_getroot(lua_State *L) { + char *rootdev = get_root_device(); + lua_pushstring(L, rootdev); + free(rootdev); + return 1; +} + static int l_get_bootenv(lua_State *L) { const char *name = luaL_checkstring(L, 1); char *value = NULL; @@ -881,6 +888,7 @@ static const luaL_Reg l_swupdate[] = { { "debug", lua_notify_debug }, { "mount", l_mount }, { "umount", l_umount }, + { "getroot", l_getroot }, { NULL, NULL } };