From patchwork Wed Dec 23 09:51:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1420061 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::13f; helo=mail-lf1-x13f.google.com; envelope-from=swupdate+bncbcxploxj6ikrbk5grt7qkgqeapw2m3a@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de 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=l4hKPkB+; dkim-atps=neutral Received: from mail-lf1-x13f.google.com (mail-lf1-x13f.google.com [IPv6:2a00:1450:4864:20::13f]) (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 4D17lQ0nb6z9sVH for ; Wed, 23 Dec 2020 20:51:44 +1100 (AEDT) Received: by mail-lf1-x13f.google.com with SMTP id 7sf17643904lfz.12 for ; Wed, 23 Dec 2020 01:51:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1608717099; cv=pass; d=google.com; s=arc-20160816; b=b42RyelahyDdsOzZCMxnFPk9S3jX8sCFmjcbJPSXhcIUH2DOTPMxaA6UkOy5qhBOU0 9iKsbXqTvuFvgwoY8wknkIOc+YntHHDC4ehXX2DYqNsTOZtA92wqRZ81k8zoHlx6cTaq fVgQRuiJITf12iDMgB1PRgBLhaOyLcUCDCrlInPRdr6oaj1L0sooTUJDnpgtiXz2/kIn 8jY5u1FmtbAffHZQUxalHUIZIDnkHMBBlbTwE3R7VsQRTiR3DXa4uAYPslF0FFHR/jxm SaGuTl5pii1zM/KTnSzhe7MDSOKZ3xxB0HalGWgrMbolZIypBt/zXAjHag4hOWDQ7SKQ 8sLg== 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=QMvn12HvCMSnyjSz2v9U/GlNKBJfEhHZct1fzoaoTSY=; b=JzNMtulA0K+wJx9jJ/P4O6b2liq9dKS9MF4rMYuM/r6MykQZ+rYwavCqtYCb5R1u1Q WlrkeUGAf2DJ17LohRoQloNXgGTakL4Y0qHylVUnE7r/6Itandmz4thEdqaN/SsLdf+x cgq01BIvXNGD1sPTzAaY38W/U12Jt5l48pqDtQqtFnq+cjQ/+gHYO5knbaCsA+3/e5UF OEREc9M2S0nX2VW/xbysYFOYcCYy7kqd2ui5rFB6mLd54KUXsKfwqZ7dqatb+g+zpQ6r StmEzRITr8zDN1cMg8yXCZHi2PEDaPXLLP3g/VYmO0Np3Kxkcg2gTTodwHXtHxnGVEy+ sGGA== 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=QMvn12HvCMSnyjSz2v9U/GlNKBJfEhHZct1fzoaoTSY=; b=l4hKPkB+CuIcwCrm837FELxChQpwfyHEUqhxzjh4HCuf6o7Dx+tE860VpYA5n9sGKZ 1nNEtXhBNsmsSsXBqzs3HdoPevAGUFzl8Rr1wSBzfp6bV0g2nBd9wyg6LrMnSKnDRYfl 5ZcDn9VgwMUvhruVLqkH0KBtTReuuZkR85gdzpHfhOgrv2p4dPj28KrKaHO4DAComiGp mcg6wE2a7LkclZ0U5be4IrHArIL4ZbLtti+dbvOuLCPRw4s0m87tzRG9jnDZlGyMoviV gjR4aYzfFmzHdFAUyd+kczSj6pN5HWtsHu6cR9PMdVkWF7qyGd45B/lJv6HMYljRvJuG Ysbg== 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=QMvn12HvCMSnyjSz2v9U/GlNKBJfEhHZct1fzoaoTSY=; b=jihOPAeaCRkVoRcQVQrqplcW9dpw07NmsbSAcGYC2m5USPXa1IMv4LPt4LpL++lzCS I5I9NvQBzne0upEJ2ykhxDSX8QqyHPe+8fGXhM1C6qJvHSDoIxRBhjGltTfT0U4H85ZX jYQCuNtMz98+v41geyzU8RBm+qR6FHZFL7fVGUuJt3eL7mKfdzFK2Libt4kUeOSScebT llxeegoaPMIyNbuVUh20uxjuxurrve3cyadtD9wLPuZiULmYopoBoI4KTzRbSvz7hsEL VF9NmqOwsH3aoTZonHdnx8qz5LZ1uGRVl1yWnWcqHZKsSoICv2xj5yoI1DsoktAJ0jBz fjpw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531sjI3/m7S8Al7j1XUSPXBnEUGt25LxrvJJALvis8zkYEBTKd1E +8I0wFElH9MAb+TxqWB4OL0= X-Google-Smtp-Source: ABdhPJwIwv+8uW2A/oyq+rqxPQ3k86ts7jkPJVKAV8WoETepmxSBjenN155ef/YARexZzmXHoqn+ZQ== X-Received: by 2002:a05:651c:3db:: with SMTP id f27mr12030154ljp.494.1608717099557; Wed, 23 Dec 2020 01:51:39 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:7806:: with SMTP id t6ls6295328ljc.8.gmail; Wed, 23 Dec 2020 01:51:38 -0800 (PST) X-Received: by 2002:a2e:b8d3:: with SMTP id s19mr11169290ljp.35.1608717098264; Wed, 23 Dec 2020 01:51:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608717098; cv=none; d=google.com; s=arc-20160816; b=y3G1Omu2cvSUajGjjeI4y7TKWWZNdJDyNsADdxy1ucI5c+P21Mnz/EUvWZDnHs9vzv wD54waqINKdMgqt+GrCYWR8VIE15kCzOWnOw9aHS9Z36ssxX4Ba8Kz2zEhcnYUzU8qDc WkL+pvgahKr4mVB0WOTYMJ8vNZYDm7Ni30Q28BxL3vbZokPtSkE3c9COM+tVQphaqu0J f3xDAhEgwgXpHBIex0sd4MwPXQN308APg2AYueAfoKgLk59JEKAC1HijBDP6e1FDUsFy dGAc72x1eC/AcG9b10JYSro9ValmTv8Yf0prwDJnoo6x/8gdo7Z/t+ZrS6OUEx3rW4Ug a/Fg== 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=+gxmqL4REzvMcrlFogXyXJWbMzIUpY7X5WNHVNRox10=; b=HemZuL2QYCZdorHlF0hL5AThJZl7z7J9vuw1XtCy+WzdoxGh8+GHrSr3HVgpFwlcpT 0MpDovw3NrRN8ZNbgOzloN6u9ksyBm4WKLqieb1gvqWNZ6Bf/q2EwVchxkmdK2NwVes8 0gD/XUbG8CtqO20X6dcxbD+mGRktZYgeNUtFfNYvXsEapAE1YFt+hXFsG9LRQfp+EdZ+ mbgJDPjlWZFbs+l04Vv1lCA6laTn0Xo7yqtCj9oown0c4hHdLIencCJvOz/Qsilh6flj hA+c0pj8MaIA24z8Bb2fV5rGYYGTWDQ+W9lvewgLRNqpqloM/jKO+CZRmSGL7kt40HNU mCJg== 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 i22si344190ljj.8.2020.12.23.01.51.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Dec 2020 01:51:38 -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 4D17lF52QMz1qs3T; Wed, 23 Dec 2020 10:51:37 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4D17lF4hWyz1tSQb; Wed, 23 Dec 2020 10:51:37 +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 ymLwDQeBOnBB; Wed, 23 Dec 2020 10:51:36 +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; Wed, 23 Dec 2020 10:51:36 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 1DF084540644; Wed, 23 Dec 2020 10:51:36 +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 hMsUuViSpuI7; Wed, 23 Dec 2020 10:51:33 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id 6F1794540559; Wed, 23 Dec 2020 10:51:33 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH] Create output directory for -o option Date: Wed, 23 Dec 2020 10:51:32 +0100 Message-Id: <20201223095132.580761-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: , Try to create destination directory when -o parameter is given. Signed-off-by: Stefano Babic --- core/stream_interface.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/stream_interface.c b/core/stream_interface.c index 6d32998..d85a533 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -455,8 +455,16 @@ static int save_stream(int fdin, struct swupdate_cfg *software) lseek(tmpfd, 0, SEEK_SET); fdout = openfileoutput(software->output); - if (fdout < 0) - return -1; + /* + * Try to create directory if file cannot be opened + */ + if (fdout < 0) { + if (mkpath(software->output, 0755)) + return -1; + fdout = openfileoutput(software->output); + if (fdout < 0) + return -1; + } ret = cpfiles(tmpfd, fdout, 0); if (ret < 0)