Files
shadow/debian/patches/userns/03_userns_implement_commonio_append
T

111 lines
4.2 KiB
Plaintext

From ebiederm@xmission.com Tue Jan 22 09:15:19 2013
Return-Path: <ebiederm@xmission.com>
X-Original-To: serge@hallyn.com
Delivered-To: serge@hallyn.com
Received: by mail.hallyn.com (Postfix, from userid 5001)
id CAFA8C80F6; Tue, 22 Jan 2013 09:15:19 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail
X-Spam-Level:
X-Spam-Status: No, score=0.1 required=8.0 tests=BAD_ENC_HEADER,BAYES_00
autolearn=no version=3.3.1
Received: from out02.mta.xmission.com (out02.mta.xmission.com [166.70.13.232])
(using TLSv1 with cipher AES256-SHA (256/256 bits))
(No client certificate requested)
by mail.hallyn.com (Postfix) with ESMTPS id 43FAEC80D1
for <serge@hallyn.com>; Tue, 22 Jan 2013 09:15:15 +0000 (UTC)
Received: from in02.mta.xmission.com ([166.70.13.52])
by out02.mta.xmission.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
(Exim 4.76)
(envelope-from <ebiederm@xmission.com>)
id 1TxZvA-0006sA-Pq; Tue, 22 Jan 2013 02:13:32 -0700
Received: from c-98-207-153-68.hsd1.ca.comcast.net ([98.207.153.68] helo=eric-ThinkPad-X220.xmission.com)
by in02.mta.xmission.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
(Exim 4.76)
(envelope-from <ebiederm@xmission.com>)
id 1TxZv8-0004VI-Fi; Tue, 22 Jan 2013 02:13:32 -0700
From: ebiederm@xmission.com (Eric W. Biederman)
To: Nicolas =?utf-8?Q?Fran=C3=A7ois?= <nicolas.francois@centraliens.net>
Cc: <Pkg-shadow-devel@lists.alioth.debian.org>, Linux Containers <containers@lists.linux-foundation.org>, "Michael Kerrisk \(man-pages\)" <mtk.manpages@gmail.com>, "Serge E. Hallyn" <serge@hallyn.com>
References: <87d2wxshu0.fsf@xmission.com>
Date: Tue, 22 Jan 2013 01:13:26 -0800
In-Reply-To: <87d2wxshu0.fsf@xmission.com> (Eric W. Biederman's message of
"Tue, 22 Jan 2013 01:11:19 -0800")
Message-ID: <87vcapr361.fsf@xmission.com>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-XM-AID: U2FsdGVkX1++0A/mQBimfZkeNedO095IfnCYGQfIolI=
X-SA-Exim-Connect-IP: 98.207.153.68
X-SA-Exim-Mail-From: ebiederm@xmission.com
Subject: [PATCH 03/11] Implement commonio_append.
X-SA-Exim-Version: 4.2.1 (built Wed, 14 Nov 2012 14:26:46 -0700)
X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com)
X-UID: 2073
Status: RO
Content-Length: 1874
Lines: 65
To support files that do not have a simple unique key implement
commonio_append to allow new entries to be added.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
lib/commonio.c | 30 ++++++++++++++++++++++++++++++
lib/commonio.h | 1 +
2 files changed, 31 insertions(+), 0 deletions(-)
Index: shadow/lib/commonio.c
===================================================================
--- shadow.orig/lib/commonio.c 2013-02-01 15:27:51.376080384 -0600
+++ shadow/lib/commonio.c 2013-02-01 15:27:51.368080384 -0600
@@ -1121,6 +1121,36 @@
return 1;
}
+int commonio_append (struct commonio_db *db, const void *eptr)
+{
+ struct commonio_entry *p;
+ void *nentry;
+
+ if (!db->isopen || db->readonly) {
+ errno = EINVAL;
+ return 0;
+ }
+ nentry = db->ops->dup (eptr);
+ if (NULL == nentry) {
+ errno = ENOMEM;
+ return 0;
+ }
+ /* new entry */
+ p = (struct commonio_entry *) malloc (sizeof *p);
+ if (NULL == p) {
+ db->ops->free (nentry);
+ errno = ENOMEM;
+ return 0;
+ }
+
+ p->eptr = nentry;
+ p->line = NULL;
+ p->changed = true;
+ add_one_entry (db, p);
+
+ db->changed = true;
+ return 1;
+}
void commonio_del_entry (struct commonio_db *db, const struct commonio_entry *p)
{
Index: shadow/lib/commonio.h
===================================================================
--- shadow.orig/lib/commonio.h 2013-02-01 15:27:51.376080384 -0600
+++ shadow/lib/commonio.h 2013-02-01 15:27:51.368080384 -0600
@@ -146,6 +146,7 @@
extern int commonio_open (struct commonio_db *, int);
extern /*@observer@*/ /*@null@*/const void *commonio_locate (struct commonio_db *, const char *);
extern int commonio_update (struct commonio_db *, const void *);
+extern int commonio_append (struct commonio_db *, const void *);
extern int commonio_remove (struct commonio_db *, const char *);
extern int commonio_rewind (struct commonio_db *);
extern /*@observer@*/ /*@null@*/const void *commonio_next (struct commonio_db *);