From patchwork Wed Jan 11 00:45:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 135342 X-Patchwork-Delegate: vapier@gentoo.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id D935BB6EE8 for ; Wed, 11 Jan 2012 11:47:07 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C541428758; Wed, 11 Jan 2012 01:46:43 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3VhW4D4k169r; Wed, 11 Jan 2012 01:46:43 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BFAA328759; Wed, 11 Jan 2012 01:46:21 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4813D28715 for ; Wed, 11 Jan 2012 01:46:15 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6bFosX75FlO1 for ; Wed, 11 Jan 2012 01:46:14 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-bk0-f74.google.com (mail-bk0-f74.google.com [209.85.214.74]) by theia.denx.de (Postfix) with ESMTPS id D3C632872B for ; Wed, 11 Jan 2012 01:46:13 +0100 (CET) Received: by bkcje16 with SMTP id je16so3998bkc.3 for ; Tue, 10 Jan 2012 16:46:12 -0800 (PST) Received: by 10.213.108.73 with SMTP id e9mr257713ebp.1.1326242772711; Tue, 10 Jan 2012 16:46:12 -0800 (PST) Received: by 10.213.108.73 with SMTP id e9mr257702ebp.1.1326242772493; Tue, 10 Jan 2012 16:46:12 -0800 (PST) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id u47si80323eei.2.2012.01.10.16.46.12 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 10 Jan 2012 16:46:12 -0800 (PST) Received: from sglass.mtv.corp.google.com (sglass.mtv.corp.google.com [172.22.72.144]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id 4A6C7200128; Tue, 10 Jan 2012 16:46:12 -0800 (PST) Received: by sglass.mtv.corp.google.com (Postfix, from userid 121222) id A6C38140A90; Tue, 10 Jan 2012 16:46:11 -0800 (PST) From: Simon Glass To: u-boot@lists.denx.de Date: Tue, 10 Jan 2012 16:45:51 -0800 Message-Id: <1326242752-9981-7-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1326242752-9981-1-git-send-email-sjg@chromium.org> References: <1326242752-9981-1-git-send-email-sjg@chromium.org> Subject: [U-Boot] [PATCH v2 7/8] sandbox: Add flags for open() call X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This provides a way for callers to create files for writing. We define flags which mirror the POSIX values. Another approach would be to translate the flags at runtime. Perhaps we can leave to whoever wants to port this to another OS? Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c | 2 +- include/os.h | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 093e7dc..9f93f83 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -47,7 +47,7 @@ ssize_t os_write(int fd, const void *buf, size_t count) int os_open(const char *pathname, int flags) { - return open(pathname, flags); + return open(pathname, flags, 0777); } int os_close(int fd) diff --git a/include/os.h b/include/os.h index f3af4f0..66e60f8 100644 --- a/include/os.h +++ b/include/os.h @@ -1,4 +1,9 @@ /* + * Operating System Interface + * + * This provides access to useful OS routines for the sandbox architecture. + * They are kept in a separate file so we can include system headers. + * * Copyright (c) 2011 The Chromium OS Authors. * See file CREDITS for list of people who contributed to this * project. @@ -19,11 +24,7 @@ * MA 02111-1307 USA */ -/* - * Operating System Interface - * - * This provides access to useful OS routines from the sandbox architecture - */ +struct sandbox_state; /** * Access to the OS read() system call @@ -45,6 +46,13 @@ ssize_t os_read(int fd, void *buf, size_t count); */ ssize_t os_write(int fd, const void *buf, size_t count); +enum { + OS_O_RDONLY, + OS_O_WRONLY, + OS_O_RDWR, + OS_O_CREAT = 0100, +}; + /** * Access to the OS open() system call *