From minios-devel-bounces@lists.xenproject.org Thu Jan 06 11:58:01 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 11:58:01 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253907.435219 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RP6-0005Yr-TF; Thu, 06 Jan 2022 11:58:00 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253907.435219; Thu, 06 Jan 2022 11:58:00 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RP6-0005Xx-JW; Thu, 06 Jan 2022 11:58:00 +0000
Received: by outflank-mailman (input) for mailman id 253907;
 Thu, 06 Jan 2022 11:57:59 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RP5-0005Uf-2N
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:57:59 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id e33f3c66-6ee7-11ec-9ce5-af14b9085ebd;
 Thu, 06 Jan 2022 12:57:57 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id EDC5B1F3A7;
 Thu,  6 Jan 2022 11:57:56 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C5E4E13C0D;
 Thu,  6 Jan 2022 11:57:56 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id KPwkL0TZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:56 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e33f3c66-6ee7-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470276; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=pmQsTeEAO2F2JehoSUAYba8Y3ffpdoax96zqkTw3H6w=;
	b=SIUb5DfRwcn7TS4qWmIGSdd7G6qhQ/XrhDETu7o7sN0SC7IQBPp4/22hBxBXw10PqAnY9h
	P28ZPsi+nfl6AnKztBteqgLZ1OlxkDu1UPeDHwIfmUXRKyVzq4DEpZSVD8r37fY872FJEg
	7ywrBQ4TCoVf91mYmkMlD3GkklXXA7M=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 09/15] mini-os: eliminate kbdfront union member in struct file
Date: Thu,  6 Jan 2022 12:57:35 +0100
Message-Id: <20220106115741.3219-10-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the kbdfront specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 fbfront.c     | 2 +-
 include/lib.h | 3 ---
 lib/sys.c     | 4 ++--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fbfront.c b/fbfront.c
index c8410af..1e055fb 100644
--- a/fbfront.c
+++ b/fbfront.c
@@ -302,7 +302,7 @@ int kbdfront_open(struct kbdfront_dev *dev)
 {
     dev->fd = alloc_fd(FTYPE_KBD);
     printk("kbd_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].kbd.dev = dev;
+    files[dev->fd].dev = dev;
     return dev->fd;
 }
 #endif
diff --git a/include/lib.h b/include/lib.h
index 2a9a01c..5201ed7 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -196,9 +196,6 @@ struct file {
 	struct {
 	    struct netfront_dev *dev;
 	} tap;
-	struct {
-	    struct kbdfront_dev *dev;
-	} kbd;
 #ifdef CONFIG_TPMFRONT
 	struct {
 	   struct tpmfront_dev *dev;
diff --git a/lib/sys.c b/lib/sys.c
index 2d48657..8c7ea3c 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -275,7 +275,7 @@ int read(int fd, void *buf, size_t nbytes)
         case FTYPE_KBD: {
             int ret, n;
             n = nbytes / sizeof(union xenkbd_in_event);
-            ret = kbdfront_receive(files[fd].kbd.dev, buf, n);
+            ret = kbdfront_receive(files[fd].dev, buf, n);
 	    if (ret <= 0) {
 		errno = EAGAIN;
 		return -1;
@@ -474,7 +474,7 @@ int close(int fd)
 #endif
 #ifdef CONFIG_KBDFRONT
 	case FTYPE_KBD:
-            shutdown_kbdfront(files[fd].kbd.dev);
+            shutdown_kbdfront(files[fd].dev);
             files[fd].type = FTYPE_NONE;
             return 0;
 #endif
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 11:58:02 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 11:58:02 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253909.435228 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RP7-0005fS-AB; Thu, 06 Jan 2022 11:58:01 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253909.435228; Thu, 06 Jan 2022 11:58:01 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RP7-0005cs-1N; Thu, 06 Jan 2022 11:58:01 +0000
Received: by outflank-mailman (input) for mailman id 253909;
 Thu, 06 Jan 2022 11:57:59 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RP5-0005UX-TM
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:57:59 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e2cc6d54-6ee7-11ec-81c0-a30af7de8005;
 Thu, 06 Jan 2022 12:57:57 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 366F4212CC;
 Thu,  6 Jan 2022 11:57:56 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0300413C4A;
 Thu,  6 Jan 2022 11:57:55 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id EOQ0O0PZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:55 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e2cc6d54-6ee7-11ec-81c0-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470276; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=tru95lucHl6eXrRSEYruYf0s6MYSR/EyxinHg1pggO4=;
	b=fmz1LjyfMYD45R5dtM/5FppITveTaKMBnCxcp5u+H90M+u/rLZ2qgn5y/Q1sGv+gqgantT
	zDfi7S/BqLf1DvsOm6Hs7kDtIoet8QicZZBKW/TZVHUa23mV3cjYkcGOiK/JojiXXY0VMu
	MKhmsH0TsZytENYwJWvROX3ruUOcx5g=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 05/15] mini-os: introduce a common dev pointer in struct file
Date: Thu,  6 Jan 2022 12:57:31 +0100
Message-Id: <20220106115741.3219-6-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

There are many dev pointers in a union in struct file. Prepare to
switch to a single one by introducing a new common one.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/lib.h b/include/lib.h
index dc56f52..60aaf1c 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -188,6 +188,7 @@ struct file {
     off_t offset;
     union {
         int fd; /* Any fd from an upper layer. */
+        void *dev;
 	struct {
 	    struct evtchn_port_list ports;
 	} evtchn;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 11:58:02 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 11:58:02 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253910.435244 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RP8-00064H-Br; Thu, 06 Jan 2022 11:58:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253910.435244; Thu, 06 Jan 2022 11:58:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RP8-000644-3h; Thu, 06 Jan 2022 11:58:02 +0000
Received: by outflank-mailman (input) for mailman id 253910;
 Thu, 06 Jan 2022 11:58:00 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RP6-0005Uf-Hb
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:00 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id e38d72f9-6ee7-11ec-9ce5-af14b9085ebd;
 Thu, 06 Jan 2022 12:57:57 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 65C0B212FE;
 Thu,  6 Jan 2022 11:57:56 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3BE7213C0D;
 Thu,  6 Jan 2022 11:57:56 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id uGJfDUTZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:56 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e38d72f9-6ee7-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470276; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=bmVybJWUa0fFpI1LcBKz9xhn6xImelv7T4pQq8L9wmI=;
	b=Fs+UM/pWdDVvJXN8OAMiyiD3OkCUNAbWinIFWd/F0qaF9KZkPplY/ZsLiQrZC5bn42+yzU
	DXYYsyjqIiH0Rcz4eufKAnteQTq+nh0x3TnCxrLaV/ystB9ur0TWc/5DIhjbgmzk3M7jbW
	H9NWENjKQdu5+qgvy5/2JYb2t1p3E/s=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 06/15] mini-os: eliminate blkfront union member in struct file
Date: Thu,  6 Jan 2022 12:57:32 +0100
Message-Id: <20220106115741.3219-7-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the blkfront specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 blkfront.c    | 6 +++---
 include/lib.h | 3 ---
 lib/sys.c     | 2 +-
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/blkfront.c b/blkfront.c
index 8137106..e3f42be 100644
--- a/blkfront.c
+++ b/blkfront.c
@@ -562,13 +562,13 @@ int blkfront_open(struct blkfront_dev *dev)
     }
     dev->fd = alloc_fd(FTYPE_BLK);
     printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].blk.dev = dev;
+    files[dev->fd].dev = dev;
     return dev->fd;
 }
 
 int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
 {
-   struct blkfront_dev* dev = files[fd].blk.dev;
+   struct blkfront_dev* dev = files[fd].dev;
    off_t offset = files[fd].offset;
    struct blkfront_aiocb aiocb;
    unsigned long long disksize = dev->info.sectors * dev->info.sector_size;
@@ -718,7 +718,7 @@ int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
 
 int blkfront_posix_fstat(int fd, struct stat* buf)
 {
-   struct blkfront_dev* dev = files[fd].blk.dev;
+   struct blkfront_dev* dev = files[fd].dev;
 
    buf->st_mode = dev->info.mode;
    buf->st_uid = 0;
diff --git a/include/lib.h b/include/lib.h
index 60aaf1c..3a40634 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -196,9 +196,6 @@ struct file {
 	struct {
 	    struct netfront_dev *dev;
 	} tap;
-	struct {
-	    struct blkfront_dev *dev;
-	} blk;
 	struct {
 	    struct kbdfront_dev *dev;
 	} kbd;
diff --git a/lib/sys.c b/lib/sys.c
index 1da7401..f2fdbdf 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -456,7 +456,7 @@ int close(int fd)
 #endif
 #ifdef CONFIG_BLKFRONT
 	case FTYPE_BLK:
-            shutdown_blkfront(files[fd].blk.dev);
+            shutdown_blkfront(files[fd].dev);
 	    files[fd].type = FTYPE_NONE;
 	    return 0;
 #endif
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 11:58:03 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 11:58:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253913.435257 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RP9-0006Kl-E5; Thu, 06 Jan 2022 11:58:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253913.435257; Thu, 06 Jan 2022 11:58:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RP9-0006Ix-7e; Thu, 06 Jan 2022 11:58:03 +0000
Received: by outflank-mailman (input) for mailman id 253913;
 Thu, 06 Jan 2022 11:58:02 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RP7-0005UX-To
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:01 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e3256124-6ee7-11ec-81c0-a30af7de8005;
 Thu, 06 Jan 2022 12:57:57 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id C0B481F3A6;
 Thu,  6 Jan 2022 11:57:56 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9736213C0D;
 Thu,  6 Jan 2022 11:57:56 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id IMWmI0TZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:56 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e3256124-6ee7-11ec-81c0-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470276; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=xErc7oBdwTzw610yqw3gpLQCyn3qczdDyg0iihAjKQM=;
	b=IPtmfN6P3iEoVunr9mUcXaEj1i9fEgD3m65LtDMKgeHnVLAeEOiyoc4jqCH8r1Bd22Fs8L
	Id1HWyvbLUUr4Vpj8VUNJaAxMAN+p3bdGBePEoP2sjnWYsNTpDV1K4H/lChVa+MDcsSAki
	sLfOeG7xXhvmJIT/1PJGOH6yOstLcNU=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 08/15] mini-os: eliminate fbfront union member in struct file
Date: Thu,  6 Jan 2022 12:57:34 +0100
Message-Id: <20220106115741.3219-9-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the fbfront specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 fbfront.c     | 2 +-
 include/lib.h | 3 ---
 lib/sys.c     | 4 ++--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fbfront.c b/fbfront.c
index 6725da1..c8410af 100644
--- a/fbfront.c
+++ b/fbfront.c
@@ -703,7 +703,7 @@ int fbfront_open(struct fbfront_dev *dev)
 {
     dev->fd = alloc_fd(FTYPE_FB);
     printk("fb_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].fb.dev = dev;
+    files[dev->fd].dev = dev;
     return dev->fd;
 }
 #endif
diff --git a/include/lib.h b/include/lib.h
index 0cedae6..2a9a01c 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -199,9 +199,6 @@ struct file {
 	struct {
 	    struct kbdfront_dev *dev;
 	} kbd;
-	struct {
-	    struct fbfront_dev *dev;
-	} fb;
 #ifdef CONFIG_TPMFRONT
 	struct {
 	   struct tpmfront_dev *dev;
diff --git a/lib/sys.c b/lib/sys.c
index 62c2020..2d48657 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -287,7 +287,7 @@ int read(int fd, void *buf, size_t nbytes)
         case FTYPE_FB: {
             int ret, n;
             n = nbytes / sizeof(union xenfb_in_event);
-            ret = fbfront_receive(files[fd].fb.dev, buf, n);
+            ret = fbfront_receive(files[fd].dev, buf, n);
 	    if (ret <= 0) {
 		errno = EAGAIN;
 		return -1;
@@ -480,7 +480,7 @@ int close(int fd)
 #endif
 #ifdef CONFIG_FBFRONT
 	case FTYPE_FB:
-            shutdown_fbfront(files[fd].fb.dev);
+            shutdown_fbfront(files[fd].dev);
             files[fd].type = FTYPE_NONE;
             return 0;
 #endif
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 11:58:04 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 11:58:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253905.435208 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RP5-0005Ux-DW; Thu, 06 Jan 2022 11:57:59 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253905.435208; Thu, 06 Jan 2022 11:57:59 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RP5-0005Uq-AT; Thu, 06 Jan 2022 11:57:59 +0000
Received: by outflank-mailman (input) for mailman id 253905;
 Thu, 06 Jan 2022 11:57:58 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RP4-0005UX-4P
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:57:58 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e25b206b-6ee7-11ec-81c0-a30af7de8005;
 Thu, 06 Jan 2022 12:57:57 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 69607212C7;
 Thu,  6 Jan 2022 11:57:55 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3FA9513C4A;
 Thu,  6 Jan 2022 11:57:55 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id GIlQDkPZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:55 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e25b206b-6ee7-11ec-81c0-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=5R3ZzVCzkcurvfIiXoJfZKNipObEjTIYIL/twAPEHmg=;
	b=GYmLaoTdv9YvOlvBOvK4jAtMwhOJg02clrHMZYqdYH2gUP1tTILJ7o37Z7FQ5HO9wAmyrg
	El4HB+u1kC1aILpOQx/jAZ086aghL5uPyYeTLbrCTIPQZUnylW1T3F8KWm0rcei1XFxUvF
	l+oBSTjAAbERdNv+A6AlQQg+WbaIGrA=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 01/15] mini-os: split struct file definition from its usage
Date: Thu,  6 Jan 2022 12:57:27 +0100
Message-Id: <20220106115741.3219-2-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Make the struct file definition standalone and use it for the
declaration of the files array.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 39d6a18..a638bc9 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -181,7 +181,7 @@ struct evtchn_port_info {
         int bound;
 };
 
-extern struct file {
+struct file {
     enum fd_type type;
     union {
 	struct {
@@ -236,7 +236,9 @@ extern struct file {
 #endif
     };
     int read;	/* maybe available for read */
-} files[];
+};
+
+extern struct file files[];
 
 int alloc_fd(enum fd_type type);
 void close_all_files(void);
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 11:58:05 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 11:58:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253916.435283 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RPB-0006rb-Qp; Thu, 06 Jan 2022 11:58:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253916.435283; Thu, 06 Jan 2022 11:58:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RPB-0006qJ-Ce; Thu, 06 Jan 2022 11:58:05 +0000
Received: by outflank-mailman (input) for mailman id 253916;
 Thu, 06 Jan 2022 11:58:03 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RP9-0005Uf-Hr
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:03 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id e3b29e51-6ee7-11ec-9ce5-af14b9085ebd;
 Thu, 06 Jan 2022 12:57:57 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 848E31F3A9;
 Thu,  6 Jan 2022 11:57:57 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5D05713C0D;
 Thu,  6 Jan 2022 11:57:57 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id UFlkFUXZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:57 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e3b29e51-6ee7-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470277; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=OlUsXgmJVXs1bcrolch8AFDDMEltM2NC+VAU9LgoD0k=;
	b=lfHgdbJ6+meI0zCgqlYs1d1O3JM3OxV6m/IJ98l7HCddq4gKMv95J04jw6VHtAscXrHoLX
	QomAKyIBBAHOEqFzYEsSUk9GU/Ju7rEZ9dWchvkvyCDOqvQ073CobaOV4aQlduMxHyduQG
	kc4m6V9oqCFAeQGXoSwjiejWAfD6c6U=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 12/15] mini-os: eliminate tpmfront union member in struct file
Date: Thu,  6 Jan 2022 12:57:38 +0100
Message-Id: <20220106115741.3219-13-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the tpmfront specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h | 5 -----
 lib/sys.c     | 2 +-
 tpmfront.c    | 8 ++++----
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index d740065..2ddc076 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -193,11 +193,6 @@ struct file {
 	    struct evtchn_port_list ports;
 	} evtchn;
 	struct gntmap gntmap;
-#ifdef CONFIG_TPMFRONT
-	struct {
-	   struct tpmfront_dev *dev;
-	} tpmfront;
-#endif
 #ifdef CONFIG_TPM_TIS
 	struct {
 	   struct tpm_chip *dev;
diff --git a/lib/sys.c b/lib/sys.c
index b35e433..b042bf5 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -462,7 +462,7 @@ int close(int fd)
 #endif
 #ifdef CONFIG_TPMFRONT
 	case FTYPE_TPMFRONT:
-            shutdown_tpmfront(files[fd].tpmfront.dev);
+            shutdown_tpmfront(files[fd].dev);
 	    files[fd].type = FTYPE_NONE;
 	    return 0;
 #endif
diff --git a/tpmfront.c b/tpmfront.c
index be671c2..0a2fefc 100644
--- a/tpmfront.c
+++ b/tpmfront.c
@@ -538,7 +538,7 @@ int tpmfront_open(struct tpmfront_dev* dev)
 
    dev->fd = alloc_fd(FTYPE_TPMFRONT);
    printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
-   files[dev->fd].tpmfront.dev = dev;
+   files[dev->fd].dev = dev;
    dev->respgot = false;
    return dev->fd;
 }
@@ -547,7 +547,7 @@ int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count)
 {
    int rc;
    struct tpmfront_dev* dev;
-   dev = files[fd].tpmfront.dev;
+   dev = files[fd].dev;
 
    if(count == 0) {
       return 0;
@@ -573,7 +573,7 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
    size_t dummysz;
    struct tpmfront_dev* dev;
 
-   dev = files[fd].tpmfront.dev;
+   dev = files[fd].dev;
 
    if(count == 0) {
       return 0;
@@ -606,7 +606,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
    uint8_t* dummybuf;
    size_t dummysz;
    int rc;
-   struct tpmfront_dev* dev = files[fd].tpmfront.dev;
+   struct tpmfront_dev* dev = files[fd].dev;
 
    /* If we have a response waiting, then read it now from the backend
     * so we can get its length*/
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 11:58:06 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 11:58:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253917.435288 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RPC-0006sZ-2V; Thu, 06 Jan 2022 11:58:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253917.435288; Thu, 06 Jan 2022 11:58:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RPB-0006rO-GB; Thu, 06 Jan 2022 11:58:05 +0000
Received: by outflank-mailman (input) for mailman id 253917;
 Thu, 06 Jan 2022 11:58:04 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RP9-0005UX-Tz
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:04 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e25b2073-6ee7-11ec-81c0-a30af7de8005;
 Thu, 06 Jan 2022 12:57:57 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 3B2E01F39A;
 Thu,  6 Jan 2022 11:57:55 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0FF6913C0D;
 Thu,  6 Jan 2022 11:57:55 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 8I2WAkPZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:55 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e25b2073-6ee7-11ec-81c0-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:  content-transfer-encoding:content-transfer-encoding;
	bh=xy0k3l1xwd14agj4JvTzTc/eAjXOd11zi0LH89vg72c=;
	b=nL2YWUlrAVrsTMR8+zPMRVVXeIakeDPzfRJNC2YZXyQCuDmauWD9pTn9blgxCUG4C/POqz
	uo7xm/yw1ORxfNbjEsLgjfxn7PFGFfAVOPG7/tZEkyS+OuD18HAWMSukIjTrxVAEv9jgVJ
	gGM3Me1nVO4ouW4cNltGqL4Afm6wRYo=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 00/15] mini-os: remove struct file dependency from config
Date: Thu,  6 Jan 2022 12:57:26 +0100
Message-Id: <20220106115741.3219-1-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Today the layout of struct file is depending on the Mini-OS
configuration. This is especially bad as the layout is exported to
external users like the Xen libraries built for Mini-OS, and those
are being built only once for multiple stubdom configurations.

Today there is no direct problem resulting from this, as the main
difference between struct file layouts is a large union containing all
the device specific data for the different file types. The largest
union member is not configuration dependant, so the build is currently
not broken.

In order to avoid any future problems this patch series is eliminating
the configuration dependency by replacing most of the device specific
union members by a single pointer.

The two union members used by Xen libraries can't be replaced yet, as
those need to be switched to use the generic pointer first.

In order to hide the Mini-OS internal implementation of the files
array, the last patch is introducing a service function for obtaining
the pointer to struct file for a given file descriptor, which must be
used for that purpose by all Mini-OS external components.

Juergen Gross (15):
  mini-os: split struct file definition from its usage
  mini-os: makes file.read bool and move it ahead of device specific
    part
  mini-os: make offset a common struct file member for all types
  mini-os: replace multiple fd elements in struct file by common one
  mini-os: introduce a common dev pointer in struct file
  mini-os: eliminate blkfront union member in struct file
  mini-os: eliminate consfront union member in struct file
  mini-os: eliminate fbfront union member in struct file
  mini-os: eliminate kbdfront union member in struct file
  mini-os: eliminate netfront union member in struct file
  mini-os: move tpm respgot member of struct file to device specific
    data
  mini-os: eliminate tpmfront union member in struct file
  mini-os: eliminate tpmtis union member in struct file
  mini-os: eliminate xenbus union member in struct file
  mini-os: introduce get_file_from_fd()

 blkfront.c             |  15 +++---
 console/xencons_ring.c |   2 +-
 fbfront.c              |  16 +++----
 include/lib.h          |  59 ++++-------------------
 include/tpmfront.h     |   2 +
 lib/sys.c              | 103 ++++++++++++++++++++++-------------------
 lib/xs.c               |  13 +++---
 netfront.c             |   6 +--
 tpm_tis.c              |  23 ++++-----
 tpmfront.c             |  33 +++++++------
 10 files changed, 119 insertions(+), 153 deletions(-)

-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 11:58:08 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 11:58:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253920.435307 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RPE-0007X5-Oz; Thu, 06 Jan 2022 11:58:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253920.435307; Thu, 06 Jan 2022 11:58:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RPE-0007V0-Bs; Thu, 06 Jan 2022 11:58:08 +0000
Received: by outflank-mailman (input) for mailman id 253920;
 Thu, 06 Jan 2022 11:58:06 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RPB-0005Uf-I2
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:05 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id e2aad614-6ee7-11ec-9ce5-af14b9085ebd;
 Thu, 06 Jan 2022 12:57:57 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 02273212CB;
 Thu,  6 Jan 2022 11:57:56 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CB74C13C0D;
 Thu,  6 Jan 2022 11:57:55 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id qKd1MEPZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:55 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e2aad614-6ee7-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470276; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=51rtfDlnCwvtylJO0A+QuSOibmO2F89Q2mcJem6Kck0=;
	b=IvjSX2gexxgKdcxmktE+tINJhUGi/QHxpWqsA/JpnM5W2NBqMGPuSUjvaFJVxQeA5wmZjW
	OT3La1KL4bWX7a/BiEaFOG1LvEHxW4lWZYOk7Fp5s/0sN6CaP2Px082/dvXYmca2T+VlTK
	7CGQ19MKJH7vWWNYzP8tE+dm9LJ5g4A=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 04/15] mini-os: replace multiple fd elements in struct file by common one
Date: Thu,  6 Jan 2022 12:57:30 +0100
Message-Id: <20220106115741.3219-5-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

The type specific union in struct files contains two instances of
"int fd". Replace them by a common one.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h |  9 +--------
 lib/sys.c     | 28 ++++++++++++++--------------
 2 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 4d9b14b..dc56f52 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -187,14 +187,7 @@ struct file {
     bool read;	/* maybe available for read */
     off_t offset;
     union {
-	struct {
-            /* lwIP fd */
-	    int fd;
-	} socket;
-	struct {
-            /* FS import fd */
-	    int fd;
-	} file;
+        int fd; /* Any fd from an upper layer. */
 	struct {
 	    struct evtchn_port_list ports;
 	} evtchn;
diff --git a/lib/sys.c b/lib/sys.c
index e1cea70..1da7401 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -258,7 +258,7 @@ int read(int fd, void *buf, size_t nbytes)
         }
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
-	    return lwip_read(files[fd].socket.fd, buf, nbytes);
+	    return lwip_read(files[fd].fd, buf, nbytes);
 #endif
 #ifdef CONFIG_NETFRONT
 	case FTYPE_TAP: {
@@ -335,7 +335,7 @@ int write(int fd, const void *buf, size_t nbytes)
 	    return nbytes;
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
-	    return lwip_write(files[fd].socket.fd, (void*) buf, nbytes);
+	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
 #endif
 #ifdef CONFIG_NETFRONT
 	case FTYPE_TAP:
@@ -428,7 +428,7 @@ int close(int fd)
 #endif
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET: {
-	    int res = lwip_close(files[fd].socket.fd);
+	    int res = lwip_close(files[fd].fd);
 	    files[fd].type = FTYPE_NONE;
 	    return res;
 	}
@@ -594,7 +594,7 @@ int fcntl(int fd, int cmd, ...)
 	    if (files[fd].type == FTYPE_SOCKET && !(arg & ~O_NONBLOCK)) {
 		/* Only flag supported: non-blocking mode */
 		uint32_t nblock = !!(arg & O_NONBLOCK);
-		return lwip_ioctl(files[fd].socket.fd, FIONBIO, &nblock);
+		return lwip_ioctl(files[fd].fd, FIONBIO, &nblock);
 	    }
 	    /* Fallthrough */
 #endif
@@ -732,15 +732,15 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
     for (i = 0; i < nfds; i++) {
 	if (files[i].type == FTYPE_SOCKET) {
 	    if (FD_ISSET(i, readfds)) {
-		FD_SET(files[i].socket.fd, &sock_readfds);
+		FD_SET(files[i].fd, &sock_readfds);
 		sock_nfds = i+1;
 	    }
 	    if (FD_ISSET(i, writefds)) {
-		FD_SET(files[i].socket.fd, &sock_writefds);
+		FD_SET(files[i].fd, &sock_writefds);
 		sock_nfds = i+1;
 	    }
 	    if (FD_ISSET(i, exceptfds)) {
-		FD_SET(files[i].socket.fd, &sock_exceptfds);
+		FD_SET(files[i].fd, &sock_exceptfds);
 		sock_nfds = i+1;
 	    }
 	}
@@ -803,19 +803,19 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 	case FTYPE_SOCKET:
 	    if (FD_ISSET(i, readfds)) {
 	        /* Optimize no-network-packet case.  */
-		if (sock_n && FD_ISSET(files[i].socket.fd, &sock_readfds))
+		if (sock_n && FD_ISSET(files[i].fd, &sock_readfds))
 		    n++;
 		else
 		    FD_CLR(i, readfds);
 	    }
             if (FD_ISSET(i, writefds)) {
-		if (sock_n && FD_ISSET(files[i].socket.fd, &sock_writefds))
+		if (sock_n && FD_ISSET(files[i].fd, &sock_writefds))
 		    n++;
 		else
 		    FD_CLR(i, writefds);
             }
             if (FD_ISSET(i, exceptfds)) {
-		if (sock_n && FD_ISSET(files[i].socket.fd, &sock_exceptfds))
+		if (sock_n && FD_ISSET(files[i].fd, &sock_exceptfds))
 		    n++;
 		else
 		    FD_CLR(i, exceptfds);
@@ -1112,7 +1112,7 @@ int socket(int domain, int type, int protocol)
 	return -1;
     res = alloc_fd(FTYPE_SOCKET);
     printk("socket -> %d\n", res);
-    files[res].socket.fd = fd;
+    files[res].fd = fd;
     return res;
 }
 
@@ -1124,11 +1124,11 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
 	errno = EBADF;
 	return -1;
     }
-    fd = lwip_accept(files[s].socket.fd, addr, addrlen);
+    fd = lwip_accept(files[s].fd, addr, addrlen);
     if (fd < 0)
 	return -1;
     res = alloc_fd(FTYPE_SOCKET);
-    files[res].socket.fd = fd;
+    files[res].fd = fd;
     printk("accepted on %d -> %d\n", s, res);
     return res;
 }
@@ -1141,7 +1141,7 @@ ret name proto \
 	errno = EBADF; \
 	return -1; \
     } \
-    s = files[s].socket.fd; \
+    s = files[s].fd; \
     return lwip_##name args; \
 }
 
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 11:58:09 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 11:58:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253921.435313 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RPF-0007ZU-5x; Thu, 06 Jan 2022 11:58:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253921.435313; Thu, 06 Jan 2022 11:58:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RPE-0007X0-IA; Thu, 06 Jan 2022 11:58:08 +0000
Received: by outflank-mailman (input) for mailman id 253921;
 Thu, 06 Jan 2022 11:58:06 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RPB-0005UX-UA
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:05 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e35b35a9-6ee7-11ec-81c0-a30af7de8005;
 Thu, 06 Jan 2022 12:57:57 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 282E51F3A8;
 Thu,  6 Jan 2022 11:57:57 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F352113C0D;
 Thu,  6 Jan 2022 11:57:56 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id wIYpOkTZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:56 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e35b35a9-6ee7-11ec-81c0-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470277; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=yL3iNqERg5EulNmJK0ycoAwzGvfibMXTv4Vh1zCFUho=;
	b=G76wKbbFM05FStujvf/bF/czASQ6aHupL7jeNQeVnlWOFrqYUzFmSDKosGJMmltnA/LJJ1
	USaPHOqWwxFbc1FAgAlIiKlUdkyAmeCSIElV/7K0mSOEC9ssyWZDLzcz2jL3jI42sOvyY5
	C6hJQLbxXyqk3OonxIsIRRrHpEQI2/0=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 10/15] mini-os: eliminate netfront union member in struct file
Date: Thu,  6 Jan 2022 12:57:36 +0100
Message-Id: <20220106115741.3219-11-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the netfront specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h | 3 ---
 lib/sys.c     | 6 +++---
 netfront.c    | 2 +-
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 5201ed7..f2a124e 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -193,9 +193,6 @@ struct file {
 	    struct evtchn_port_list ports;
 	} evtchn;
 	struct gntmap gntmap;
-	struct {
-	    struct netfront_dev *dev;
-	} tap;
 #ifdef CONFIG_TPMFRONT
 	struct {
 	   struct tpmfront_dev *dev;
diff --git a/lib/sys.c b/lib/sys.c
index 8c7ea3c..b35e433 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -263,7 +263,7 @@ int read(int fd, void *buf, size_t nbytes)
 #ifdef CONFIG_NETFRONT
 	case FTYPE_TAP: {
 	    ssize_t ret;
-	    ret = netfront_receive(files[fd].tap.dev, buf, nbytes);
+	    ret = netfront_receive(files[fd].dev, buf, nbytes);
 	    if (ret <= 0) {
 		errno = EAGAIN;
 		return -1;
@@ -339,7 +339,7 @@ int write(int fd, const void *buf, size_t nbytes)
 #endif
 #ifdef CONFIG_NETFRONT
 	case FTYPE_TAP:
-	    netfront_xmit(files[fd].tap.dev, (void*) buf, nbytes);
+	    netfront_xmit(files[fd].dev, (void*) buf, nbytes);
 	    return nbytes;
 #endif
 #ifdef CONFIG_BLKFRONT
@@ -450,7 +450,7 @@ int close(int fd)
 #endif
 #ifdef CONFIG_NETFRONT
 	case FTYPE_TAP:
-	    shutdown_netfront(files[fd].tap.dev);
+	    shutdown_netfront(files[fd].dev);
 	    files[fd].type = FTYPE_NONE;
 	    return 0;
 #endif
diff --git a/netfront.c b/netfront.c
index a566e34..7696451 100644
--- a/netfront.c
+++ b/netfront.c
@@ -576,7 +576,7 @@ int netfront_tap_open(char *nodename) {
     }
     dev->fd = alloc_fd(FTYPE_TAP);
     printk("tap_open(%s) -> %d\n", nodename, dev->fd);
-    files[dev->fd].tap.dev = dev;
+    files[dev->fd].dev = dev;
     return dev->fd;
 }
 #endif
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 11:58:10 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 11:58:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253922.435324 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RPF-0007bj-VO; Thu, 06 Jan 2022 11:58:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253922.435324; Thu, 06 Jan 2022 11:58:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RPE-0007ZS-Rg; Thu, 06 Jan 2022 11:58:08 +0000
Received: by outflank-mailman (input) for mailman id 253922;
 Thu, 06 Jan 2022 11:58:06 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RPC-0005Uf-I5
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:06 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id e3c8adc9-6ee7-11ec-9ce5-af14b9085ebd;
 Thu, 06 Jan 2022 12:57:58 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id E0A1B1F39A;
 Thu,  6 Jan 2022 11:57:57 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B94E213C0D;
 Thu,  6 Jan 2022 11:57:57 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id uKQXLEXZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:57 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e3c8adc9-6ee7-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470277; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=M5iLDQMfkH8htZ3wRFumo5FkHynp/HKlFIcfl/LfGDo=;
	b=gh+DQlcESakDUkPTEJ1soZommb+igB4NL6JjGl9BJvgGVNIBS+t0hGxmsZzXWl5ejXlCDa
	r/HKGE594MTOyVJUoJU6atziAFjureSrxGbYvQ70Dyx4n6W5/nCfPX321J0E3+pHaBU9Hc
	ptRTDos2qr4ZF4LHh4aXkS2m1+1I2Sc=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 14/15] mini-os: eliminate xenbus union member in struct file
Date: Thu,  6 Jan 2022 12:57:40 +0100
Message-Id: <20220106115741.3219-15-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the xenbus specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h |  7 -------
 lib/sys.c     |  2 +-
 lib/xs.c      | 13 +++++++------
 3 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index d6a29ba..91364ba 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -193,13 +193,6 @@ struct file {
 	    struct evtchn_port_list ports;
 	} evtchn;
 	struct gntmap gntmap;
-#ifdef CONFIG_XENBUS
-        struct {
-            /* To each xenbus FD is associated a queue of watch events for this
-             * FD.  */
-            xenbus_event_queue events;
-        } xenbus;
-#endif
     };
 };
 
diff --git a/lib/sys.c b/lib/sys.c
index 96fc769..6f2b026 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -776,7 +776,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 #ifdef CONFIG_XENBUS
 	case FTYPE_XENBUS:
 	    if (FD_ISSET(i, readfds)) {
-                if (files[i].xenbus.events)
+                if (files[i].dev)
 		    n++;
 		else
 		    FD_CLR(i, readfds);
diff --git a/lib/xs.c b/lib/xs.c
index 324bd05..0459f52 100644
--- a/lib/xs.c
+++ b/lib/xs.c
@@ -21,8 +21,8 @@ static inline int _xs_fileno(struct xs_handle *h) {
 struct xs_handle *xs_daemon_open()
 {
     int fd = alloc_fd(FTYPE_XENBUS);
-    files[fd].xenbus.events = NULL;
-    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].xenbus.events);
+    files[fd].dev = NULL;
+    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].dev);
     return (void*)(intptr_t) fd;
 }
 
@@ -30,7 +30,7 @@ void xs_daemon_close(struct xs_handle *h)
 {
     int fd = _xs_fileno(h);
     struct xenbus_event *event, *next;
-    for (event = files[fd].xenbus.events; event; event = next)
+    for (event = files[fd].dev; event; event = next)
     {
         next = event->next;
         free(event);
@@ -172,15 +172,16 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)
 {
     int fd = _xs_fileno(h);
     printk("xs_watch(%s, %s)\n", path, token);
-    return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token, &files[fd].xenbus.events));
+    return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token,
+                   (xenbus_event_queue *)&files[fd].dev));
 }
 
 char **xs_read_watch(struct xs_handle *h, unsigned int *num)
 {
     int fd = _xs_fileno(h);
     struct xenbus_event *event;
-    event = files[fd].xenbus.events;
-    files[fd].xenbus.events = event->next;
+    event = files[fd].dev;
+    files[fd].dev = event->next;
     printk("xs_read_watch() -> %s %s\n", event->path, event->token);
     *num = 2;
     return (char **) &event->path;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 11:59:07 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 11:59:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253930.435372 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RQB-0003jV-3N; Thu, 06 Jan 2022 11:59:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253930.435372; Thu, 06 Jan 2022 11:59:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RQB-0003jO-0O; Thu, 06 Jan 2022 11:59:07 +0000
Received: by outflank-mailman (input) for mailman id 253930;
 Thu, 06 Jan 2022 11:59:06 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RPD-0005UX-UU
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:08 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e27cd5ea-6ee7-11ec-81c0-a30af7de8005;
 Thu, 06 Jan 2022 12:57:57 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 97BA6212C9;
 Thu,  6 Jan 2022 11:57:55 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6E1E113C0D;
 Thu,  6 Jan 2022 11:57:55 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 4EmeGUPZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:55 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e27cd5ea-6ee7-11ec-81c0-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=l6pifbgOadZ0E6Wgy90T2ZIm93BZS6I+9qz60NhwbHg=;
	b=he6FNPlM2m97aBvtYpvwfEY0RsYBMXKDCpgoUo/1sc9lUS1Jw7v153yVQr67iV30WlYYwb
	TOWWwtkX7hmthBY/Niu1bCvj74zvAk3lH5igNigLiWvhPtLizCsIjUHaznFBukOVdS5m++
	NZc6V59v90ZABblqWZQdsO9TPuHm/Zc=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 02/15] mini-os: makes file.read bool and move it ahead of device specific part
Date: Thu,  6 Jan 2022 12:57:28 +0100
Message-Id: <20220106115741.3219-3-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

The read member of struct file should be bool.

In order to have the device specific part at the end of the structure
move "read" ahead of that.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 blkfront.c             |  4 ++--
 console/xencons_ring.c |  2 +-
 fbfront.c              | 12 ++++++------
 include/lib.h          |  3 ++-
 netfront.c             |  4 ++--
 tpm_tis.c              |  2 +-
 tpmfront.c             |  6 +++---
 7 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/blkfront.c b/blkfront.c
index 834a978..7c8eb74 100644
--- a/blkfront.c
+++ b/blkfront.c
@@ -62,7 +62,7 @@ void blkfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
     int fd = dev->fd;
 
     if (fd != -1)
-        files[fd].read = 1;
+        files[fd].read = true;
 #endif
     wake_up(&blkfront_queue);
 }
@@ -484,7 +484,7 @@ int blkfront_aio_poll(struct blkfront_dev *dev)
 moretodo:
 #ifdef HAVE_LIBC
     if (dev->fd != -1) {
-        files[dev->fd].read = 0;
+        files[dev->fd].read = false;
         mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
     }
 #endif
diff --git a/console/xencons_ring.c b/console/xencons_ring.c
index b6db74e..c348f3c 100644
--- a/console/xencons_ring.c
+++ b/console/xencons_ring.c
@@ -102,7 +102,7 @@ void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data)
         int fd = dev ? dev->fd : -1;
 
         if (fd != -1)
-            files[fd].read = 1;
+            files[fd].read = true;
 
         wake_up(&console_queue);
 #else
diff --git a/fbfront.c b/fbfront.c
index d3b3848..6725da1 100644
--- a/fbfront.c
+++ b/fbfront.c
@@ -45,7 +45,7 @@ void kbdfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
     int fd = dev->fd;
 
     if (fd != -1)
-        files[fd].read = 1;
+        files[fd].read = true;
 #endif
     wake_up(&kbdfront_queue);
 }
@@ -207,7 +207,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
 
 #ifdef HAVE_LIBC
     if (dev->fd != -1) {
-        files[dev->fd].read = 0;
+        files[dev->fd].read = false;
         mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
     }
 #endif
@@ -229,7 +229,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
 #ifdef HAVE_LIBC
     if (cons != prod && dev->fd != -1)
         /* still some events to read */
-        files[dev->fd].read = 1;
+        files[dev->fd].read = true;
 #endif
 
     return i;
@@ -349,7 +349,7 @@ void fbfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
     int fd = dev->fd;
 
     if (fd != -1)
-        files[fd].read = 1;
+        files[fd].read = true;
 #endif
     wake_up(&fbfront_queue);
 }
@@ -376,7 +376,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
 
 #ifdef HAVE_LIBC
     if (dev->fd != -1) {
-        files[dev->fd].read = 0;
+        files[dev->fd].read = false;
         mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
     }
 #endif
@@ -398,7 +398,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
 #ifdef HAVE_LIBC
     if (cons != prod && dev->fd != -1)
         /* still some events to read */
-        files[dev->fd].read = 1;
+        files[dev->fd].read = true;
 #endif
 
     return i;
diff --git a/include/lib.h b/include/lib.h
index a638bc9..df2de9e 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -49,6 +49,7 @@
 #define _LIB_H_
 
 #include <stdarg.h>
+#include <stdbool.h>
 #include <stddef.h>
 #include <xen/xen.h>
 #include <xen/event_channel.h>
@@ -183,6 +184,7 @@ struct evtchn_port_info {
 
 struct file {
     enum fd_type type;
+    bool read;	/* maybe available for read */
     union {
 	struct {
             /* lwIP fd */
@@ -235,7 +237,6 @@ struct file {
         } xenbus;
 #endif
     };
-    int read;	/* maybe available for read */
 };
 
 extern struct file files[];
diff --git a/netfront.c b/netfront.c
index dfe065b..a566e34 100644
--- a/netfront.c
+++ b/netfront.c
@@ -255,7 +255,7 @@ void netfront_select_handler(evtchn_port_t port, struct pt_regs *regs, void *dat
     local_irq_restore(flags);
 
     if (fd != -1)
-        files[fd].read = 1;
+        files[fd].read = true;
     wake_up(&netfront_queue);
 }
 #endif
@@ -783,7 +783,7 @@ ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t l
     network_rx(dev);
     if (!dev->rlen && fd != -1)
         /* No data for us, make select stop returning */
-        files[fd].read = 0;
+        files[fd].read = false;
     /* Before re-enabling the interrupts, in case a packet just arrived in the
      * meanwhile. */
     local_irq_restore(flags);
diff --git a/tpm_tis.c b/tpm_tis.c
index 475ac5d..4a51027 100644
--- a/tpm_tis.c
+++ b/tpm_tis.c
@@ -845,7 +845,7 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
    }
 #ifdef HAVE_LIBC
    if(tpm->fd >= 0) {
-      files[tpm->fd].read = 0;
+      files[tpm->fd].read = false;
       files[tpm->fd].tpm_tis.respgot = 0;
       files[tpm->fd].tpm_tis.offset = 0;
    }
diff --git a/tpmfront.c b/tpmfront.c
index 6049244..d825b49 100644
--- a/tpmfront.c
+++ b/tpmfront.c
@@ -66,7 +66,7 @@ void tpmfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) {
    dev->waiting = 0;
 #ifdef HAVE_LIBC
    if(dev->fd >= 0) {
-      files[dev->fd].read = 1;
+      files[dev->fd].read = true;
    }
 #endif
    wake_up(&dev->waitq);
@@ -438,7 +438,7 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
    dev->resplen = 0;
 #ifdef HAVE_LIBC
    if(dev->fd >= 0) {
-      files[dev->fd].read = 0;
+      files[dev->fd].read = false;
       files[dev->fd].tpmfront.respgot = 0;
       files[dev->fd].tpmfront.offset = 0;
    }
@@ -611,7 +611,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
 
    /* If we have a response waiting, then read it now from the backend
     * so we can get its length*/
-   if(dev->waiting || (files[dev->fd].read == 1 && !files[dev->fd].tpmfront.respgot)) {
+   if(dev->waiting || (files[dev->fd].read && !files[dev->fd].tpmfront.respgot)) {
       if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
 	 errno = EIO;
 	 return -1;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 11:59:08 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 11:59:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253932.435377 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RQC-0003mw-56; Thu, 06 Jan 2022 11:59:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253932.435377; Thu, 06 Jan 2022 11:59:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RQC-0003mo-1s; Thu, 06 Jan 2022 11:59:08 +0000
Received: by outflank-mailman (input) for mailman id 253932;
 Thu, 06 Jan 2022 11:59:06 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RPL-0005UX-VR
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:15 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e3acd308-6ee7-11ec-81c0-a30af7de8005;
 Thu, 06 Jan 2022 12:57:58 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id B0A17212C7;
 Thu,  6 Jan 2022 11:57:57 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 89F2113C0D;
 Thu,  6 Jan 2022 11:57:57 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 6MSCIEXZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:57 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e3acd308-6ee7-11ec-81c0-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470277; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=479+ZsaQ/HR1Ri0lahF7rot1Udcg9gaoznCeT0QqN9I=;
	b=fP1cCOY+bPvVqpVlay1gDfX8O7NpxJ+V8buwFGlupD4VRta30a8gBxfuW2lXra6O/GVt+e
	pCzOXGwBw69b5smW/dAVi5M7tLZhZnqyLla5hcIvKtzGf+KKc8LR+RbsGKk0FY9xQfmcFe
	f4HEdxeC+uV07G6NiofcCCeYE3k5TIQ=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 13/15] mini-os: eliminate tpmtis union member in struct file
Date: Thu,  6 Jan 2022 12:57:39 +0100
Message-Id: <20220106115741.3219-14-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the tpmtis specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h | 5 -----
 lib/sys.c     | 2 +-
 tpm_tis.c     | 8 ++++----
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 2ddc076..d6a29ba 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -193,11 +193,6 @@ struct file {
 	    struct evtchn_port_list ports;
 	} evtchn;
 	struct gntmap gntmap;
-#ifdef CONFIG_TPM_TIS
-	struct {
-	   struct tpm_chip *dev;
-	} tpm_tis;
-#endif
 #ifdef CONFIG_XENBUS
         struct {
             /* To each xenbus FD is associated a queue of watch events for this
diff --git a/lib/sys.c b/lib/sys.c
index b042bf5..96fc769 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -468,7 +468,7 @@ int close(int fd)
 #endif
 #ifdef CONFIG_TPM_TIS
 	case FTYPE_TPM_TIS:
-            shutdown_tpm_tis(files[fd].tpm_tis.dev);
+            shutdown_tpm_tis(files[fd].dev);
 	    files[fd].type = FTYPE_NONE;
 	    return 0;
 #endif
diff --git a/tpm_tis.c b/tpm_tis.c
index 4127118..477f555 100644
--- a/tpm_tis.c
+++ b/tpm_tis.c
@@ -1288,14 +1288,14 @@ int tpm_tis_open(struct tpm_chip* tpm)
 
    tpm->fd = alloc_fd(FTYPE_TPM_TIS);
    printk("tpm_tis_open() -> %d\n", tpm->fd);
-   files[tpm->fd].tpm_tis.dev = tpm;
+   files[tpm->fd].dev = tpm;
    return tpm->fd;
 }
 
 int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count)
 {
    struct tpm_chip* tpm;
-   tpm = files[fd].tpm_tis.dev;
+   tpm = files[fd].dev;
 
    if(tpm->locality < 0) {
       printk("tpm_tis_posix_write() failed! locality not set!\n");
@@ -1323,7 +1323,7 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
 {
    int rc;
    struct tpm_chip* tpm;
-   tpm = files[fd].tpm_tis.dev;
+   tpm = files[fd].dev;
 
    if(count == 0) {
       return 0;
@@ -1350,7 +1350,7 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
 int tpm_tis_posix_fstat(int fd, struct stat* buf)
 {
    struct tpm_chip* tpm;
-   tpm = files[fd].tpm_tis.dev;
+   tpm = files[fd].dev;
 
    buf->st_mode = O_RDWR;
    buf->st_uid = 0;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 11:59:19 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 11:59:19 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253935.435381 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RQN-000450-8G; Thu, 06 Jan 2022 11:59:19 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253935.435381; Thu, 06 Jan 2022 11:59:19 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RQN-00044t-4o; Thu, 06 Jan 2022 11:59:19 +0000
Received: by outflank-mailman (input) for mailman id 253935;
 Thu, 06 Jan 2022 11:59:17 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RPJ-0005UX-VB
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:14 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e38fef9d-6ee7-11ec-81c0-a30af7de8005;
 Thu, 06 Jan 2022 12:57:57 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 56DD521637;
 Thu,  6 Jan 2022 11:57:57 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2F50613C0D;
 Thu,  6 Jan 2022 11:57:57 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id gJgyCkXZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:57 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e38fef9d-6ee7-11ec-81c0-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470277; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=zRc5gY/92MrOjMdEN5JMRpsapAMAJSL5mvFXRrg0SZ8=;
	b=EINi4iUrnmV02sZOkEQ0aY0MAvCbGsD2i1M+BL96gDxQk8ndjP1Ku7fAFaGucY5P7HstbD
	nGCSejiWKdhxXJAYAWY1ON+bV8q5+Xo6L7ThJLjeLIGtAE4z/tNkJTAzoO2pxzssh6mziG
	1ssRJAkF0pweesDReQlfRaTtpuPCXmE=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 11/15] mini-os: move tpm respgot member of struct file to device specific data
Date: Thu,  6 Jan 2022 12:57:37 +0100
Message-Id: <20220106115741.3219-12-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Tpmfront has a "respgot" flag in struct file, which can be moved to the
device specific data. While at it make it a bool.

The respgot flag of the tpm_tis member of struct file can be removed,
as it is never read.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h      |  2 --
 include/tpmfront.h |  2 ++
 tpm_tis.c          |  2 --
 tpmfront.c         | 10 +++++-----
 4 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index f2a124e..d740065 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -196,13 +196,11 @@ struct file {
 #ifdef CONFIG_TPMFRONT
 	struct {
 	   struct tpmfront_dev *dev;
-	   int respgot;
 	} tpmfront;
 #endif
 #ifdef CONFIG_TPM_TIS
 	struct {
 	   struct tpm_chip *dev;
-	   int respgot;
 	} tpm_tis;
 #endif
 #ifdef CONFIG_XENBUS
diff --git a/include/tpmfront.h b/include/tpmfront.h
index c489fae..b7da50e 100644
--- a/include/tpmfront.h
+++ b/include/tpmfront.h
@@ -25,6 +25,7 @@
 #ifndef TPMFRONT_H
 #define TPMFRONT_H
 
+#include <stdbool.h>
 #include <mini-os/types.h>
 #include <mini-os/os.h>
 #include <mini-os/events.h>
@@ -53,6 +54,7 @@ struct tpmfront_dev {
 
 #ifdef HAVE_LIBC
    int fd;
+   bool respgot;
 #endif
 
 };
diff --git a/tpm_tis.c b/tpm_tis.c
index 8a632b1..4127118 100644
--- a/tpm_tis.c
+++ b/tpm_tis.c
@@ -846,7 +846,6 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
 #ifdef HAVE_LIBC
    if(tpm->fd >= 0) {
       files[tpm->fd].read = false;
-      files[tpm->fd].tpm_tis.respgot = 0;
       files[tpm->fd].offset = 0;
    }
 #endif
@@ -1290,7 +1289,6 @@ int tpm_tis_open(struct tpm_chip* tpm)
    tpm->fd = alloc_fd(FTYPE_TPM_TIS);
    printk("tpm_tis_open() -> %d\n", tpm->fd);
    files[tpm->fd].tpm_tis.dev = tpm;
-   files[tpm->fd].tpm_tis.respgot = 0;
    return tpm->fd;
 }
 
diff --git a/tpmfront.c b/tpmfront.c
index 8b2a910..be671c2 100644
--- a/tpmfront.c
+++ b/tpmfront.c
@@ -439,8 +439,8 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
 #ifdef HAVE_LIBC
    if(dev->fd >= 0) {
       files[dev->fd].read = false;
-      files[dev->fd].tpmfront.respgot = 0;
       files[dev->fd].offset = 0;
+      dev->respgot = false;
    }
 #endif
    wmb();
@@ -499,7 +499,7 @@ int i;
 #endif
 #ifdef HAVE_LIBC
    if(dev->fd >= 0) {
-      files[dev->fd].tpmfront.respgot = 1;
+      dev->respgot = true;
    }
 #endif
 quit:
@@ -539,7 +539,7 @@ int tpmfront_open(struct tpmfront_dev* dev)
    dev->fd = alloc_fd(FTYPE_TPMFRONT);
    printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
    files[dev->fd].tpmfront.dev = dev;
-   files[dev->fd].tpmfront.respgot = 0;
+   dev->respgot = false;
    return dev->fd;
 }
 
@@ -580,7 +580,7 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
    }
 
    /* get the response if we haven't already */
-   if(files[dev->fd].tpmfront.respgot == 0) {
+   if (!dev->respgot) {
       if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
 	 errno = EIO;
 	 return -1;
@@ -610,7 +610,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
 
    /* If we have a response waiting, then read it now from the backend
     * so we can get its length*/
-   if(dev->waiting || (files[dev->fd].read && !files[dev->fd].tpmfront.respgot)) {
+   if(dev->waiting || (files[dev->fd].read && !dev->respgot)) {
       if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
 	 errno = EIO;
 	 return -1;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 12:00:06 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 12:00:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253952.435396 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RR8-0005cD-49; Thu, 06 Jan 2022 12:00:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253952.435396; Thu, 06 Jan 2022 12:00:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RR8-0005bu-0b; Thu, 06 Jan 2022 12:00:06 +0000
Received: by outflank-mailman (input) for mailman id 253952;
 Thu, 06 Jan 2022 12:00:05 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RPG-0005UX-Uy
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:11 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e30200bb-6ee7-11ec-81c0-a30af7de8005;
 Thu, 06 Jan 2022 12:57:57 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 911F11F3A2;
 Thu,  6 Jan 2022 11:57:56 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6968F13C0D;
 Thu,  6 Jan 2022 11:57:56 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id UFCSGETZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:56 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e30200bb-6ee7-11ec-81c0-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470276; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=0ADnCSUrVKDoJvsP7J4SKuUjUEXMRkB3QXB4kfD1iQE=;
	b=nkoh468iPXJMcFqUDXHeV++B8pzmUUI5aC7nUnBdGH5ZszTQtPxyUKPq4OU8SHE1WDw+x5
	PiPO+hD1IZXECQLPBYmFWcjpe3ilx/KRS9lTA9BFicOUyuumLBMYFQHZBLRtIFj/C/qdSR
	PjsikQERyv4EHkwiKW4TT7G5ry6t9Vs=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 07/15] mini-os: eliminate consfront union member in struct file
Date: Thu,  6 Jan 2022 12:57:33 +0100
Message-Id: <20220106115741.3219-8-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the consfront specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h |  3 ---
 lib/sys.c     | 31 +++++++++++++++++--------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 3a40634..0cedae6 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -202,9 +202,6 @@ struct file {
 	struct {
 	    struct fbfront_dev *dev;
 	} fb;
-	struct {
-	    struct consfront_dev *dev;
-	} cons;
 #ifdef CONFIG_TPMFRONT
 	struct {
 	   struct tpmfront_dev *dev;
diff --git a/lib/sys.c b/lib/sys.c
index f2fdbdf..62c2020 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -179,7 +179,7 @@ int posix_openpt(int flags)
 
     dev = init_consfront(NULL);
     dev->fd = alloc_fd(FTYPE_CONSOLE);
-    files[dev->fd].cons.dev = dev;
+    files[dev->fd].dev = dev;
 
     printk("fd(%d) = posix_openpt\n", dev->fd);
     return(dev->fd);
@@ -194,7 +194,7 @@ int open_savefile(const char *path, int save)
 
     dev = init_consfront(nodename);
     dev->fd = alloc_fd(FTYPE_SAVEFILE);
-    files[dev->fd].cons.dev = dev;
+    files[dev->fd].dev = dev;
 
     printk("fd(%d) = open_savefile\n", dev->fd);
     return(dev->fd);
@@ -248,7 +248,7 @@ int read(int fd, void *buf, size_t nbytes)
             DEFINE_WAIT(w);
             while(1) {
                 add_waiter(w, console_queue);
-                ret = xencons_ring_recv(files[fd].cons.dev, buf, nbytes);
+                ret = xencons_ring_recv(files[fd].dev, buf, nbytes);
                 if (ret)
                     break;
                 schedule();
@@ -324,14 +324,14 @@ int write(int fd, const void *buf, size_t nbytes)
         case FTYPE_SAVEFILE: {
                 int ret = 0, tot = nbytes;
                 while (nbytes > 0) {
-                    ret = xencons_ring_send(files[fd].cons.dev, (char *)buf, nbytes);
+                    ret = xencons_ring_send(files[fd].dev, (char *)buf, nbytes);
                     nbytes -= ret;
                     buf = (char *)buf + ret;
                 }
                 return tot - nbytes;
             }
 	case FTYPE_CONSOLE:
-	    console_print(files[fd].cons.dev, (char *)buf, nbytes);
+	    console_print(files[fd].dev, (char *)buf, nbytes);
 	    return nbytes;
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
@@ -487,7 +487,7 @@ int close(int fd)
 #ifdef CONFIG_CONSFRONT
         case FTYPE_SAVEFILE:
         case FTYPE_CONSOLE:
-            fini_consfront(files[fd].cons.dev);
+            fini_consfront(files[fd].dev);
             files[fd].type = FTYPE_NONE;
             return 0;
 #endif
@@ -764,7 +764,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 	    /* Fallthrough.  */
 	case FTYPE_CONSOLE:
 	    if (FD_ISSET(i, readfds)) {
-                if (xencons_ring_avail(files[i].cons.dev))
+                if (xencons_ring_avail(files[i].dev))
 		    n++;
 		else
 		    FD_CLR(i, readfds);
@@ -1447,6 +1447,8 @@ const struct termios default_termios = {0,             /* iflag */
 
 int tcsetattr(int fildes, int action, const struct termios *tios)
 {
+    struct consfront_dev *dev;
+
     if (fildes < 0 || fildes >= NOFILE) {
         errno = EBADF;
         return -1;
@@ -1472,21 +1474,21 @@ int tcsetattr(int fildes, int action, const struct termios *tios)
             return -1;
     }
 
-    if (files[fildes].cons.dev == NULL) {
+    dev = files[fildes].dev;
+    if (dev == NULL) {
         errno = ENOSYS;
         return -1;
     }
 
-    if (tios->c_oflag & OPOST)
-        files[fildes].cons.dev->is_raw = false;
-    else
-        files[fildes].cons.dev->is_raw = true;
+    dev->is_raw = !(tios->c_oflag & OPOST);
 
     return 0;
 }
 
 int tcgetattr(int fildes, struct termios *tios)
 {
+    struct consfront_dev *dev;
+
     if (fildes < 0 || fildes >= NOFILE) {
         errno = EBADF;
         return -1;
@@ -1497,7 +1499,8 @@ int tcgetattr(int fildes, struct termios *tios)
         return -1;
     }
 
-    if (files[fildes].cons.dev == NULL) {
+    dev = files[fildes].dev;
+    if (dev == NULL) {
         errno = ENOSYS;
         return 0;
     }
@@ -1509,7 +1512,7 @@ int tcgetattr(int fildes, struct termios *tios)
 
     memcpy(tios, &default_termios, sizeof(struct termios));
 
-    if (files[fildes].cons.dev->is_raw)
+    if (dev->is_raw)
         tios->c_oflag &= ~OPOST;
 
     return 0;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 12:00:15 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 12:00:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253955.435411 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RRH-0006GB-E2; Thu, 06 Jan 2022 12:00:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253955.435411; Thu, 06 Jan 2022 12:00:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RRH-0006G1-A6; Thu, 06 Jan 2022 12:00:15 +0000
Received: by outflank-mailman (input) for mailman id 253955;
 Thu, 06 Jan 2022 12:00:14 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RPH-0005UX-Uu
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:12 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e291ef39-6ee7-11ec-81c0-a30af7de8005;
 Thu, 06 Jan 2022 12:57:57 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id C6A48212CA;
 Thu,  6 Jan 2022 11:57:55 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9D50413C0D;
 Thu,  6 Jan 2022 11:57:55 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id kEA3JUPZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:55 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e291ef39-6ee7-11ec-81c0-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=x+0vw1I/hfTGOGb3eceoyxjODZK0aOUWRIC/lcz6R4A=;
	b=DnqYS+/rPg5//MChMz/HOdqP5Q1i1bqqVHyPWXD5pJruUm9Y4E6Nocyg5xuU88hFWGpuTe
	uO+ouVJC7JCpecOGRkZJRapyFPp4pzys7X1krV8/MHNO/Rqf7NL/wdzWh1RITCv84zdV1w
	UVYvnXlsqpLGYSIfOfgR5KDTAyewOJE=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 03/15] mini-os: make offset a common struct file member for all types
Date: Thu,  6 Jan 2022 12:57:29 +0100
Message-Id: <20220106115741.3219-4-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Currently 4 file types have an offset member in their private struct
file part. Make offset a common struct member shared by all file types.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 blkfront.c    |  5 ++---
 include/lib.h |  5 +----
 lib/sys.c     | 14 +++++---------
 tpm_tis.c     | 11 +++++------
 tpmfront.c    | 11 +++++------
 5 files changed, 18 insertions(+), 28 deletions(-)

diff --git a/blkfront.c b/blkfront.c
index 7c8eb74..8137106 100644
--- a/blkfront.c
+++ b/blkfront.c
@@ -563,14 +563,13 @@ int blkfront_open(struct blkfront_dev *dev)
     dev->fd = alloc_fd(FTYPE_BLK);
     printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
     files[dev->fd].blk.dev = dev;
-    files[dev->fd].blk.offset = 0;
     return dev->fd;
 }
 
 int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
 {
    struct blkfront_dev* dev = files[fd].blk.dev;
-   off_t offset = files[fd].blk.offset;
+   off_t offset = files[fd].offset;
    struct blkfront_aiocb aiocb;
    unsigned long long disksize = dev->info.sectors * dev->info.sector_size;
    unsigned int blocksize = dev->info.sector_size;
@@ -712,7 +711,7 @@ int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
    }
 
    free(copybuf);
-   files[fd].blk.offset += rc;
+   files[fd].offset += rc;
    return rc;
 
 }
diff --git a/include/lib.h b/include/lib.h
index df2de9e..4d9b14b 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -185,6 +185,7 @@ struct evtchn_port_info {
 struct file {
     enum fd_type type;
     bool read;	/* maybe available for read */
+    off_t offset;
     union {
 	struct {
             /* lwIP fd */
@@ -193,7 +194,6 @@ struct file {
 	struct {
             /* FS import fd */
 	    int fd;
-	    off_t offset;
 	} file;
 	struct {
 	    struct evtchn_port_list ports;
@@ -204,7 +204,6 @@ struct file {
 	} tap;
 	struct {
 	    struct blkfront_dev *dev;
-            off_t offset;
 	} blk;
 	struct {
 	    struct kbdfront_dev *dev;
@@ -219,14 +218,12 @@ struct file {
 	struct {
 	   struct tpmfront_dev *dev;
 	   int respgot;
-	   off_t offset;
 	} tpmfront;
 #endif
 #ifdef CONFIG_TPM_TIS
 	struct {
 	   struct tpm_chip *dev;
 	   int respgot;
-	   off_t offset;
 	} tpm_tis;
 #endif
 #ifdef CONFIG_XENBUS
diff --git a/lib/sys.c b/lib/sys.c
index e8d5eb2..e1cea70 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -107,6 +107,7 @@ int alloc_fd(enum fd_type type)
     for (i=0; i<NOFILE; i++) {
 	if (files[i].type == FTYPE_NONE) {
 	    files[i].type = type;
+            files[i].offset = 0;
 	    pthread_mutex_unlock(&fd_lock);
 	    return i;
 	}
@@ -363,25 +364,20 @@ int write(int fd, const void *buf, size_t nbytes)
 
 off_t lseek(int fd, off_t offset, int whence)
 {
-    off_t* target = NULL;
     switch(files[fd].type) {
 #ifdef CONFIG_BLKFRONT
        case FTYPE_BLK:
-          target = &files[fd].blk.offset;
           break;
 #endif
 #ifdef CONFIG_TPMFRONT
        case FTYPE_TPMFRONT:
-          target = &files[fd].tpmfront.offset;
           break;
 #endif
 #ifdef CONFIG_TPM_TIS
        case FTYPE_TPM_TIS:
-          target = &files[fd].tpm_tis.offset;
           break;
 #endif
        case FTYPE_FILE:
-          target = &files[fd].file.offset;
           break;
        default:
           /* Not implemented for this filetype */
@@ -391,10 +387,10 @@ off_t lseek(int fd, off_t offset, int whence)
 
     switch (whence) {
        case SEEK_SET:
-          *target = offset;
+          files[fd].offset = offset;
           break;
        case SEEK_CUR:
-          *target += offset;
+          files[fd].offset += offset;
           break;
        case SEEK_END:
           {
@@ -403,14 +399,14 @@ off_t lseek(int fd, off_t offset, int whence)
              ret = fstat(fd, &st);
              if (ret)
                 return -1;
-             *target = st.st_size + offset;
+             files[fd].offset = st.st_size + offset;
              break;
           }
        default:
           errno = EINVAL;
           return -1;
     }
-    return *target;
+    return files[fd].offset;
 }
 
 int fsync(int fd) {
diff --git a/tpm_tis.c b/tpm_tis.c
index 4a51027..8a632b1 100644
--- a/tpm_tis.c
+++ b/tpm_tis.c
@@ -847,7 +847,7 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
    if(tpm->fd >= 0) {
       files[tpm->fd].read = false;
       files[tpm->fd].tpm_tis.respgot = 0;
-      files[tpm->fd].tpm_tis.offset = 0;
+      files[tpm->fd].offset = 0;
    }
 #endif
    return len;
@@ -1290,7 +1290,6 @@ int tpm_tis_open(struct tpm_chip* tpm)
    tpm->fd = alloc_fd(FTYPE_TPM_TIS);
    printk("tpm_tis_open() -> %d\n", tpm->fd);
    files[tpm->fd].tpm_tis.dev = tpm;
-   files[tpm->fd].tpm_tis.offset = 0;
    files[tpm->fd].tpm_tis.respgot = 0;
    return tpm->fd;
 }
@@ -1340,13 +1339,13 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
 
 
    /* Handle EOF case */
-   if(files[fd].tpm_tis.offset >= tpm->data_len) {
+   if(files[fd].offset >= tpm->data_len) {
       rc = 0;
    } else {
-      rc = min(tpm->data_len - files[fd].tpm_tis.offset, count);
-      memcpy(buf, tpm->data_buffer + files[fd].tpm_tis.offset, rc);
+      rc = min(tpm->data_len - files[fd].offset, count);
+      memcpy(buf, tpm->data_buffer + files[fd].offset, rc);
    }
-   files[fd].tpm_tis.offset += rc;
+   files[fd].offset += rc;
    /* Reset the data pending flag */
    return rc;
 }
diff --git a/tpmfront.c b/tpmfront.c
index d825b49..8b2a910 100644
--- a/tpmfront.c
+++ b/tpmfront.c
@@ -440,7 +440,7 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
    if(dev->fd >= 0) {
       files[dev->fd].read = false;
       files[dev->fd].tpmfront.respgot = 0;
-      files[dev->fd].tpmfront.offset = 0;
+      files[dev->fd].offset = 0;
    }
 #endif
    wmb();
@@ -539,7 +539,6 @@ int tpmfront_open(struct tpmfront_dev* dev)
    dev->fd = alloc_fd(FTYPE_TPMFRONT);
    printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
    files[dev->fd].tpmfront.dev = dev;
-   files[dev->fd].tpmfront.offset = 0;
    files[dev->fd].tpmfront.respgot = 0;
    return dev->fd;
 }
@@ -589,14 +588,14 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
    }
 
    /* handle EOF case */
-   if(files[dev->fd].tpmfront.offset >= dev->resplen) {
+   if(files[dev->fd].offset >= dev->resplen) {
       return 0;
    }
 
    /* Compute the number of bytes and do the copy operation */
-   if((rc = min(count, dev->resplen - files[dev->fd].tpmfront.offset)) != 0) {
-      memcpy(buf, dev->respbuf + files[dev->fd].tpmfront.offset, rc);
-      files[dev->fd].tpmfront.offset += rc;
+   if((rc = min(count, dev->resplen - files[dev->fd].offset)) != 0) {
+      memcpy(buf, dev->respbuf + files[dev->fd].offset, rc);
+      files[dev->fd].offset += rc;
    }
 
    return rc;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Thu Jan 06 12:00:20 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 06 Jan 2022 12:00:20 +0000
Received: from list by lists.xenproject.org with outflank-mailman.253958.435415 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RRM-0006OE-GK; Thu, 06 Jan 2022 12:00:20 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 253958.435415; Thu, 06 Jan 2022 12:00:20 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5RRM-0006O3-Bo; Thu, 06 Jan 2022 12:00:20 +0000
Received: by outflank-mailman (input) for mailman id 253958;
 Thu, 06 Jan 2022 12:00:18 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kr4l=RW=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5RPN-0005UX-Va
 for minios-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:17 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e3e64e6f-6ee7-11ec-81c0-a30af7de8005;
 Thu, 06 Jan 2022 12:57:58 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 188541F3A2;
 Thu,  6 Jan 2022 11:57:58 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E4F1D13C0D;
 Thu,  6 Jan 2022 11:57:57 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id OCy1NkXZ1mHnJgAAMHmgww
 (envelope-from <jgross@suse.com>); Thu, 06 Jan 2022 11:57:57 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e3e64e6f-6ee7-11ec-81c0-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641470278; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=+GsFFIwit/Rt80w572ZQFBg1V74eYMuV1hjsub3Nyy0=;
	b=j/mDeu9UoOTfcQ/Pp6xXG3woMs+R3iP731Yk+OmKxmC5o4xgv83dcLoIqnL4xgZF/KUkzW
	9lsqeKRBzTMviC0ajrCi4mO4MNc7tXWd9ZTMAMT9Wf38zyCnpyKxYdTNxs/ipBsp+j4eWv
	gMX/kIuCenCimRfwWjVkagf1Wrk9yHo=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 15/15] mini-os: introduce get_file_from_fd()
Date: Thu,  6 Jan 2022 12:57:41 +0100
Message-Id: <20220106115741.3219-16-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Exporting the files[] array especially for components outside the
mini-os source tree is limiting the ability to change any file handling
in mini-os.

Introduce a new function get_file_from_fd() to return the struct file
pointer (or NULL) for a given file descriptor.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h | 1 +
 lib/sys.c     | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/include/lib.h b/include/lib.h
index 91364ba..7a0546b 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -198,6 +198,7 @@ struct file {
 
 extern struct file files[];
 
+struct file *get_file_from_fd(int fd);
 int alloc_fd(enum fd_type type);
 void close_all_files(void);
 extern struct thread *main_thread;
diff --git a/lib/sys.c b/lib/sys.c
index 6f2b026..0e6fe5d 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -98,6 +98,14 @@ struct file files[NOFILE] = {
     { .type = FTYPE_CONSOLE }, /* stderr */
 };
 
+struct file *get_file_from_fd(int fd)
+{
+    if ( fd < 0 || fd >= NOFILE )
+        return NULL;
+
+    return (files[fd].type == FTYPE_NONE) ? NULL : files + fd;
+}
+
 DECLARE_WAIT_QUEUE_HEAD(event_queue);
 
 int alloc_fd(enum fd_type type)
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Fri Jan 07 02:39:40 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 07 Jan 2022 02:39:40 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254252.435913 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5fAF-0002av-Sh; Fri, 07 Jan 2022 02:39:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254252.435913; Fri, 07 Jan 2022 02:39:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5fAF-0002ao-Oy; Fri, 07 Jan 2022 02:39:35 +0000
Received: by outflank-mailman (input) for mailman id 254252;
 Fri, 07 Jan 2022 02:39:34 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=yHxo=RX=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n5fAE-0002L6-2G
 for minios-devel@lists.xenproject.org; Fri, 07 Jan 2022 02:39:34 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 098cce22-6f63-11ec-9ce5-af14b9085ebd;
 Fri, 07 Jan 2022 03:39:31 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id AFCA1FF;
 Fri,  7 Jan 2022 03:39:28 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 17FGiXXIGYMX; Fri,  7 Jan 2022 03:39:27 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 5F7E0295;
 Fri,  7 Jan 2022 03:39:27 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n5fA5-001Sjd-QV;
 Fri, 07 Jan 2022 03:39:25 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 098cce22-6f63-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Fri, 7 Jan 2022 03:39:25 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 00/15] mini-os: remove struct file dependency from config
Message-ID: <20220107023925.535yyongimla2umw@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220106115741.3219-1-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: AFCA1FF
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Hello,

I had a glimpse at the changes, this looks good to me!

Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
on the whole series.

I'll see when I'll be able to find time to review the changes, unless
somebody beats me to it :)

Samuel

Juergen Gross, le jeu. 06 janv. 2022 12:57:26 +0100, a ecrit:
> Today the layout of struct file is depending on the Mini-OS
> configuration. This is especially bad as the layout is exported to
> external users like the Xen libraries built for Mini-OS, and those
> are being built only once for multiple stubdom configurations.
> 
> Today there is no direct problem resulting from this, as the main
> difference between struct file layouts is a large union containing all
> the device specific data for the different file types. The largest
> union member is not configuration dependant, so the build is currently
> not broken.
> 
> In order to avoid any future problems this patch series is eliminating
> the configuration dependency by replacing most of the device specific
> union members by a single pointer.
> 
> The two union members used by Xen libraries can't be replaced yet, as
> those need to be switched to use the generic pointer first.
> 
> In order to hide the Mini-OS internal implementation of the files
> array, the last patch is introducing a service function for obtaining
> the pointer to struct file for a given file descriptor, which must be
> used for that purpose by all Mini-OS external components.
> 
> Juergen Gross (15):
>   mini-os: split struct file definition from its usage
>   mini-os: makes file.read bool and move it ahead of device specific
>     part
>   mini-os: make offset a common struct file member for all types
>   mini-os: replace multiple fd elements in struct file by common one
>   mini-os: introduce a common dev pointer in struct file
>   mini-os: eliminate blkfront union member in struct file
>   mini-os: eliminate consfront union member in struct file
>   mini-os: eliminate fbfront union member in struct file
>   mini-os: eliminate kbdfront union member in struct file
>   mini-os: eliminate netfront union member in struct file
>   mini-os: move tpm respgot member of struct file to device specific
>     data
>   mini-os: eliminate tpmfront union member in struct file
>   mini-os: eliminate tpmtis union member in struct file
>   mini-os: eliminate xenbus union member in struct file
>   mini-os: introduce get_file_from_fd()
> 
>  blkfront.c             |  15 +++---
>  console/xencons_ring.c |   2 +-
>  fbfront.c              |  16 +++----
>  include/lib.h          |  59 ++++-------------------
>  include/tpmfront.h     |   2 +
>  lib/sys.c              | 103 ++++++++++++++++++++++-------------------
>  lib/xs.c               |  13 +++---
>  netfront.c             |   6 +--
>  tpm_tis.c              |  23 ++++-----
>  tpmfront.c             |  33 +++++++------
>  10 files changed, 119 insertions(+), 153 deletions(-)
> 
> -- 
> 2.26.2


From minios-devel-bounces@lists.xenproject.org Fri Jan 07 10:47:14 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 07 Jan 2022 10:47:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254356.436133 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5mm9-0004JK-3b; Fri, 07 Jan 2022 10:47:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254356.436133; Fri, 07 Jan 2022 10:47:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5mm8-0004Gi-QL; Fri, 07 Jan 2022 10:47:12 +0000
Received: by outflank-mailman (input) for mailman id 254356;
 Fri, 07 Jan 2022 10:47:11 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kqIQ=RX=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5mm7-00042k-TG
 for minios-devel@lists.xenproject.org; Fri, 07 Jan 2022 10:47:11 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 298be421-6fa7-11ec-9ce5-af14b9085ebd;
 Fri, 07 Jan 2022 11:47:09 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id BFC3C1F3A2;
 Fri,  7 Jan 2022 10:47:08 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A158C13CCC;
 Fri,  7 Jan 2022 10:47:08 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id mMMUJiwa2GHoEQAAMHmgww
 (envelope-from <jgross@suse.com>); Fri, 07 Jan 2022 10:47:08 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 298be421-6fa7-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641552428; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=Ns8EtRIR8x+IBI1Vuf5hHJfipnvDwTbW/7UbeMCK/V8=;
	b=eGpk+uGBBnD7UU57u0eCAaUYJMzN2y1rhbO5dCWDn9WdxJXdLs5LGhyL+Van6k5jOnj11t
	iNGQB65hdlhZOkAPKrXDHmeDbQWYeG2P7Bu642yWX1kfO1ZNQdMpDwl6tnbASB2jmuBoi8
	vyTpFcXov0As1rHT2UkjW0vHvQudEYc=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 1/2] mini-os: remove event channel specific struct file member
Date: Fri,  7 Jan 2022 11:47:05 +0100
Message-Id: <20220107104706.9859-2-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220107104706.9859-1-jgross@suse.com>
References: <20220107104706.9859-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

The event channel specific union member in struct file is no longer
needed, so remove it together with the associated structure
definitions.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 7a0546b..cbfeea3 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -173,15 +173,6 @@ enum fd_type {
     FTYPE_TPM_TIS,
 };
 
-LIST_HEAD(evtchn_port_list, evtchn_port_info);
-
-struct evtchn_port_info {
-        LIST_ENTRY(evtchn_port_info) list;
-        evtchn_port_t port;
-        unsigned long pending;
-        int bound;
-};
-
 struct file {
     enum fd_type type;
     bool read;	/* maybe available for read */
@@ -189,9 +180,6 @@ struct file {
     union {
         int fd; /* Any fd from an upper layer. */
         void *dev;
-	struct {
-	    struct evtchn_port_list ports;
-	} evtchn;
 	struct gntmap gntmap;
     };
 };
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Fri Jan 07 10:47:14 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 07 Jan 2022 10:47:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254355.436127 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5mm8-0004EK-QO; Fri, 07 Jan 2022 10:47:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254355.436127; Fri, 07 Jan 2022 10:47:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5mm8-0004Bt-F2; Fri, 07 Jan 2022 10:47:12 +0000
Received: by outflank-mailman (input) for mailman id 254355;
 Fri, 07 Jan 2022 10:47:11 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kqIQ=RX=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5mm7-00042l-5i
 for minios-devel@lists.xenproject.org; Fri, 07 Jan 2022 10:47:11 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 2983f7cb-6fa7-11ec-81c0-a30af7de8005;
 Fri, 07 Jan 2022 11:47:09 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 8F2BE1F39C;
 Fri,  7 Jan 2022 10:47:08 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 67E3613CCC;
 Fri,  7 Jan 2022 10:47:08 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id S1EFGCwa2GHoEQAAMHmgww
 (envelope-from <jgross@suse.com>); Fri, 07 Jan 2022 10:47:08 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 2983f7cb-6fa7-11ec-81c0-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641552428; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:  content-transfer-encoding:content-transfer-encoding;
	bh=yauxqOoJpXr2IEhNqv7BHVtNMqveFThpzv2/vAab4VQ=;
	b=LkEoP6u6oD3a3F4VjQ6bC7bhvC8snDCYNBoiqgVF54jARxwz+kXxXd5UeiQyodY6qzrWPl
	HFDEEbefcc2eaS/NzIIaTbL2jjdIXgQwNFRtJM4brlRlIrIc7hU0T+fj5z3oxdHWT5gywt
	M2Jttss/whvfjsh7pp+HXNY2XzhnGVY=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 0/2] mini-os: remove device specific struct file members
Date: Fri,  7 Jan 2022 11:47:04 +0100
Message-Id: <20220107104706.9859-1-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

This small series is a followup to the series sent recently:

https://lists.xen.org/archives/html/xen-devel/2022-01/threads.html#00110

It contains the last cleanups related to struct file and can only be
applied after the Xen libraries have stopped using the related union
members.

Juergen Gross (2):
  mini-os: remove event channel specific struct file member
  mini-os: remove gnttab specific member from struct file

 include/lib.h | 13 -------------
 1 file changed, 13 deletions(-)

-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Fri Jan 07 10:47:16 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 07 Jan 2022 10:47:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254354.436122 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5mm8-0004CS-MH; Fri, 07 Jan 2022 10:47:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254354.436122; Fri, 07 Jan 2022 10:47:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5mm8-00049Z-C2; Fri, 07 Jan 2022 10:47:12 +0000
Received: by outflank-mailman (input) for mailman id 254354;
 Fri, 07 Jan 2022 10:47:10 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kqIQ=RX=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5mm6-00042k-TC
 for minios-devel@lists.xenproject.org; Fri, 07 Jan 2022 10:47:10 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 29afe614-6fa7-11ec-9ce5-af14b9085ebd;
 Fri, 07 Jan 2022 11:47:09 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 073491F3A3;
 Fri,  7 Jan 2022 10:47:09 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D17BF13CCC;
 Fri,  7 Jan 2022 10:47:08 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 6IbNMSwa2GHoEQAAMHmgww
 (envelope-from <jgross@suse.com>); Fri, 07 Jan 2022 10:47:08 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 29afe614-6fa7-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641552429; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=aVrF+mPt/o/ahS4KD167P7tbO6r4eTb2AEM/MasOfew=;
	b=gqsoslElQKb2VGUq/K9P0iDX6INAIdMJieCxzDfDZafvdqXoabn5eAQw3ubxlgJh9ZDh4L
	aJCKqX0sggK1RKvVmNS1q79SSwHTyIrN5xBOg9AztNYBMwQrUyemJI1P/p7c0CMYn70mr5
	PoI3Sop03pMrVCQ9Elbibxvw8Xegjvs=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 2/2] mini-os: remove gnttab specific member from struct file
Date: Fri,  7 Jan 2022 11:47:06 +0100
Message-Id: <20220107104706.9859-3-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220107104706.9859-1-jgross@suse.com>
References: <20220107104706.9859-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

The event channel specific union member in struct file is no longer
needed, so remove it

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/lib.h b/include/lib.h
index cbfeea3..b82e285 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -180,7 +180,6 @@ struct file {
     union {
         int fd; /* Any fd from an upper layer. */
         void *dev;
-	struct gntmap gntmap;
     };
 };
 
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Fri Jan 07 11:34:05 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 07 Jan 2022 11:34:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254386.436189 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5nVS-0003sD-OZ; Fri, 07 Jan 2022 11:34:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254386.436189; Fri, 07 Jan 2022 11:34:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n5nVS-0003s6-LH; Fri, 07 Jan 2022 11:34:02 +0000
Received: by outflank-mailman (input) for mailman id 254386;
 Fri, 07 Jan 2022 11:34:00 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=kqIQ=RX=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n5nVQ-0003rv-Pt
 for minios-devel@lists.xenproject.org; Fri, 07 Jan 2022 11:34:00 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id b4e3f78c-6fad-11ec-9ce5-af14b9085ebd;
 Fri, 07 Jan 2022 12:33:59 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 91833210E7;
 Fri,  7 Jan 2022 11:33:59 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6072913350;
 Fri,  7 Jan 2022 11:33:59 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id F2ThFCcl2GHhJQAAMHmgww
 (envelope-from <jgross@suse.com>); Fri, 07 Jan 2022 11:33:59 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: b4e3f78c-6fad-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641555239; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=BrbFkh1H8DHh7FDlFrfzhtDMyAhtAlvzZh0lP0nE4xg=;
	b=nIeQF6Fsk9r+u15dhoqlzgZEfStwX6rj4s/IaqlnmyG686ln+tGcYU5nFvjM3MLkiZG3XC
	M553vMPIHkreLOCEPbhRhQ9MDxVfKzDbiKNeLGjC3Ix/aOvXGfv31mmnk4mXzIOthv/Wnl
	eNgCCBz84XVEvqQrX/w3hWZBJ7rGo8o=
Subject: Re: [PATCH 0/2] mini-os: remove device specific struct file members
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220107104706.9859-1-jgross@suse.com>
 <f1579294-4cc7-a685-0326-967444b69b86@srcf.net>
From: Juergen Gross <jgross@suse.com>
Message-ID: <e28981dd-239a-1213-dd2d-e4cfd7ad2a29@suse.com>
Date: Fri, 7 Jan 2022 12:33:58 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <f1579294-4cc7-a685-0326-967444b69b86@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="9dYvUsw6tZypt2UwYJ8xv8xbgTRutNLjs"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--9dYvUsw6tZypt2UwYJ8xv8xbgTRutNLjs
Content-Type: multipart/mixed; boundary="gA28VGGQ8NzkrjvVxtrVSrwNlUkQmuhOQ";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <e28981dd-239a-1213-dd2d-e4cfd7ad2a29@suse.com>
Subject: Re: [PATCH 0/2] mini-os: remove device specific struct file members
References: <20220107104706.9859-1-jgross@suse.com>
 <f1579294-4cc7-a685-0326-967444b69b86@srcf.net>
In-Reply-To: <f1579294-4cc7-a685-0326-967444b69b86@srcf.net>

--gA28VGGQ8NzkrjvVxtrVSrwNlUkQmuhOQ
Content-Type: multipart/mixed;
 boundary="------------AFF4EF5B9E1792DE884A90B3"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------AFF4EF5B9E1792DE884A90B3
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 07.01.22 12:30, Andrew Cooper wrote:
> On 07/01/2022 10:47, Juergen Gross wrote:
>> This small series is a followup to the series sent recently:
>>
>> https://lists.xen.org/archives/html/xen-devel/2022-01/threads.html#001=
10
>>
>> It contains the last cleanups related to struct file and can only be
>> applied after the Xen libraries have stopped using the related union
>> members.
>>
>> Juergen Gross (2):
>>    mini-os: remove event channel specific struct file member
>>    mini-os: remove gnttab specific member from struct file
>>
>>   include/lib.h | 13 -------------
>>   1 file changed, 13 deletions(-)
>>
>=20
> This all looks fine.=C2=A0 Even if we don't want to hide struct file,
> shouldn't we at least make the files[] array private to the MiniOS
> core?=C2=A0 It's another implementation detail which external users mus=
tn't
> rely on.

In theory yes.

This will need some more work either by splitting headers or by
using get_file_from_fd() everywhere in Mini-OS.


Juergen

--------------AFF4EF5B9E1792DE884A90B3
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------AFF4EF5B9E1792DE884A90B3--

--gA28VGGQ8NzkrjvVxtrVSrwNlUkQmuhOQ--

--9dYvUsw6tZypt2UwYJ8xv8xbgTRutNLjs
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHYJSYFAwAAAAAACgkQsN6d1ii/Ey/U
AQf/Qzqroj+LwcLr2Jut24qe8VvDl041f6sGYTsmDtF+kFu3h8X5EACMDx4qyvCPbZE5hba21dIB
9O3rN/l+PwCmjRW7wy+zwBN3ejsiv7FKieYqF1JqBL/iTV+PpHpkr9ztz08cdfDXZrWaK7q1EhI2
VBk60onJzTUCLpNUQwxP4kbPQi4FUG39k44qdDDvlWtKi0AJGHjdIfVFBep8v6q/nxrnAnjB/9i+
anx2pgJ1xcTmzEOSo6mp4bwdfDcj/iSgLWC76s5FCGIvHB973JgSDtW2MrXAQ3DuI6vEwVHDp1t8
OROHZsXLVnPtU0NDu9apAk1Bzc7r5LnNMVMiDjMKVA==
=m0FI
-----END PGP SIGNATURE-----

--9dYvUsw6tZypt2UwYJ8xv8xbgTRutNLjs--


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:15:27 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:15:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254939.436824 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6Mnq-0006El-Fj; Sun, 09 Jan 2022 01:15:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254939.436824; Sun, 09 Jan 2022 01:15:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6Mnq-0006Ec-9O; Sun, 09 Jan 2022 01:15:22 +0000
Received: by outflank-mailman (input) for mailman id 254939;
 Sun, 09 Jan 2022 01:15:21 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6Mnp-0006ER-94
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:15:21 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 9b758187-70e9-11ec-81c1-a30af7de8005;
 Sun, 09 Jan 2022 02:15:20 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 6EF153A7;
 Sun,  9 Jan 2022 02:15:17 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id HVlYJJq80gBA; Sun,  9 Jan 2022 02:15:16 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 79BE1331;
 Sun,  9 Jan 2022 02:15:16 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6Mnj-006i1Q-2N;
 Sun, 09 Jan 2022 02:15:15 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 9b758187-70e9-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:15:15 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 1/2] mini-os: remove event channel specific struct file
 member
Message-ID: <20220109011515.sx2qynqslxhllred@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220107104706.9859-1-jgross@suse.com>
 <20220107104706.9859-2-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220107104706.9859-2-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 6EF153A7
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le ven. 07 janv. 2022 11:47:05 +0100, a ecrit:
> The event channel specific union member in struct file is no longer
> needed,

Doesn't xen/tools/libs/evtchn/minios.c use it?

> so remove it together with the associated structure
> definitions.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
>  include/lib.h | 12 ------------
>  1 file changed, 12 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 7a0546b..cbfeea3 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -173,15 +173,6 @@ enum fd_type {
>      FTYPE_TPM_TIS,
>  };
>  
> -LIST_HEAD(evtchn_port_list, evtchn_port_info);
> -
> -struct evtchn_port_info {
> -        LIST_ENTRY(evtchn_port_info) list;
> -        evtchn_port_t port;
> -        unsigned long pending;
> -        int bound;
> -};
> -
>  struct file {
>      enum fd_type type;
>      bool read;	/* maybe available for read */
> @@ -189,9 +180,6 @@ struct file {
>      union {
>          int fd; /* Any fd from an upper layer. */
>          void *dev;
> -	struct {
> -	    struct evtchn_port_list ports;
> -	} evtchn;
>  	struct gntmap gntmap;
>      };
>  };
> -- 
> 2.26.2


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:16:08 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:16:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254942.436836 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6Moa-0006p9-PM; Sun, 09 Jan 2022 01:16:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254942.436836; Sun, 09 Jan 2022 01:16:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6Moa-0006p2-ME; Sun, 09 Jan 2022 01:16:08 +0000
Received: by outflank-mailman (input) for mailman id 254942;
 Sun, 09 Jan 2022 01:16:07 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6MoZ-0006oT-Lg
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:16:07 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id b76355ff-70e9-11ec-9ce5-af14b9085ebd;
 Sun, 09 Jan 2022 02:16:06 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id AAF073A7;
 Sun,  9 Jan 2022 02:16:04 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id zF027k-HoJ6H; Sun,  9 Jan 2022 02:16:04 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 3585464;
 Sun,  9 Jan 2022 02:16:04 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6MoV-006i4L-OX;
 Sun, 09 Jan 2022 02:16:03 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: b76355ff-70e9-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:16:03 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 0/2] mini-os: remove device specific struct file members
Message-ID: <20220109011603.bymferaebanvvmud@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220107104706.9859-1-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220107104706.9859-1-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: AAF073A7
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le ven. 07 janv. 2022 11:47:04 +0100, a ecrit:
> can only be applied after the Xen libraries have stopped using the
> related union members.

Ah, ok :) Was that submitted somewhere?

Samuel


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:17:16 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:17:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254948.436863 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6Mpg-0007mp-EH; Sun, 09 Jan 2022 01:17:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254948.436863; Sun, 09 Jan 2022 01:17:16 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6Mpg-0007mi-BF; Sun, 09 Jan 2022 01:17:16 +0000
Received: by outflank-mailman (input) for mailman id 254948;
 Sun, 09 Jan 2022 01:17:14 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6Mpe-0007Wc-Ma
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:17:14 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id dfdf7bbc-70e9-11ec-9ce5-af14b9085ebd;
 Sun, 09 Jan 2022 02:17:13 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 8CD36331;
 Sun,  9 Jan 2022 02:17:12 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id TK7gXm34arO3; Sun,  9 Jan 2022 02:17:12 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id C094564;
 Sun,  9 Jan 2022 02:17:11 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6Mpb-006i5T-2w;
 Sun, 09 Jan 2022 02:17:11 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: dfdf7bbc-70e9-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:17:11 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 01/15] mini-os: split struct file definition from its
 usage
Message-ID: <20220109011711.ft5xxxahzeixwxjm@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-2-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20220106115741.3219-2-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 8CD36331
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:27 +0100, a ecrit:
> Make the struct file definition standalone and use it for the
> declaration of the files array.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 39d6a18..a638bc9 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -181,7 +181,7 @@ struct evtchn_port_info {
>          int bound;
>  };
>  
> -extern struct file {
> +struct file {
>      enum fd_type type;
>      union {
>  	struct {
> @@ -236,7 +236,9 @@ extern struct file {
>  #endif
>      };
>      int read;	/* maybe available for read */
> -} files[];
> +};
> +
> +extern struct file files[];
>  
>  int alloc_fd(enum fd_type type);
>  void close_all_files(void);
> -- 
> 2.26.2
> 

-- 
Samuel
> C'est vrai. FreeBSD pourrait être bien s'il avait une licence
> correcte.
Oh, mon troll-ô-meter vient d'exploser...
-+- OR in Guide du linuxien pervers - "Bien regler son troll-ô-meter"


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:18:50 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:18:50 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254955.436875 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6MrC-0008JX-22; Sun, 09 Jan 2022 01:18:50 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254955.436875; Sun, 09 Jan 2022 01:18:50 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6MrB-0008Io-Rl; Sun, 09 Jan 2022 01:18:49 +0000
Received: by outflank-mailman (input) for mailman id 254955;
 Sun, 09 Jan 2022 01:18:48 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6MrA-0008EH-PZ
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:18:48 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 17beb424-70ea-11ec-9ce5-af14b9085ebd;
 Sun, 09 Jan 2022 02:18:46 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 4B7283A7;
 Sun,  9 Jan 2022 02:18:46 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id FeCwvJhCkT26; Sun,  9 Jan 2022 02:18:45 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 2B3B664;
 Sun,  9 Jan 2022 02:18:45 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6Mr6-006i91-Ft;
 Sun, 09 Jan 2022 02:18:44 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 17beb424-70ea-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:18:44 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 02/15] mini-os: makes file.read bool and move it ahead of
 device specific part
Message-ID: <20220109011844.ztd7uwre6kb3dzwv@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-3-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220106115741.3219-3-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 4B7283A7
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:28 +0100, a ecrit:
> The read member of struct file should be bool.
> 
> In order to have the device specific part at the end of the structure
> move "read" ahead of that.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  blkfront.c             |  4 ++--
>  console/xencons_ring.c |  2 +-
>  fbfront.c              | 12 ++++++------
>  include/lib.h          |  3 ++-
>  netfront.c             |  4 ++--
>  tpm_tis.c              |  2 +-
>  tpmfront.c             |  6 +++---
>  7 files changed, 17 insertions(+), 16 deletions(-)
> 
> diff --git a/blkfront.c b/blkfront.c
> index 834a978..7c8eb74 100644
> --- a/blkfront.c
> +++ b/blkfront.c
> @@ -62,7 +62,7 @@ void blkfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
>      int fd = dev->fd;
>  
>      if (fd != -1)
> -        files[fd].read = 1;
> +        files[fd].read = true;
>  #endif
>      wake_up(&blkfront_queue);
>  }
> @@ -484,7 +484,7 @@ int blkfront_aio_poll(struct blkfront_dev *dev)
>  moretodo:
>  #ifdef HAVE_LIBC
>      if (dev->fd != -1) {
> -        files[dev->fd].read = 0;
> +        files[dev->fd].read = false;
>          mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
>      }
>  #endif
> diff --git a/console/xencons_ring.c b/console/xencons_ring.c
> index b6db74e..c348f3c 100644
> --- a/console/xencons_ring.c
> +++ b/console/xencons_ring.c
> @@ -102,7 +102,7 @@ void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data)
>          int fd = dev ? dev->fd : -1;
>  
>          if (fd != -1)
> -            files[fd].read = 1;
> +            files[fd].read = true;
>  
>          wake_up(&console_queue);
>  #else
> diff --git a/fbfront.c b/fbfront.c
> index d3b3848..6725da1 100644
> --- a/fbfront.c
> +++ b/fbfront.c
> @@ -45,7 +45,7 @@ void kbdfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
>      int fd = dev->fd;
>  
>      if (fd != -1)
> -        files[fd].read = 1;
> +        files[fd].read = true;
>  #endif
>      wake_up(&kbdfront_queue);
>  }
> @@ -207,7 +207,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
>  
>  #ifdef HAVE_LIBC
>      if (dev->fd != -1) {
> -        files[dev->fd].read = 0;
> +        files[dev->fd].read = false;
>          mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
>      }
>  #endif
> @@ -229,7 +229,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
>  #ifdef HAVE_LIBC
>      if (cons != prod && dev->fd != -1)
>          /* still some events to read */
> -        files[dev->fd].read = 1;
> +        files[dev->fd].read = true;
>  #endif
>  
>      return i;
> @@ -349,7 +349,7 @@ void fbfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
>      int fd = dev->fd;
>  
>      if (fd != -1)
> -        files[fd].read = 1;
> +        files[fd].read = true;
>  #endif
>      wake_up(&fbfront_queue);
>  }
> @@ -376,7 +376,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
>  
>  #ifdef HAVE_LIBC
>      if (dev->fd != -1) {
> -        files[dev->fd].read = 0;
> +        files[dev->fd].read = false;
>          mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
>      }
>  #endif
> @@ -398,7 +398,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
>  #ifdef HAVE_LIBC
>      if (cons != prod && dev->fd != -1)
>          /* still some events to read */
> -        files[dev->fd].read = 1;
> +        files[dev->fd].read = true;
>  #endif
>  
>      return i;
> diff --git a/include/lib.h b/include/lib.h
> index a638bc9..df2de9e 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -49,6 +49,7 @@
>  #define _LIB_H_
>  
>  #include <stdarg.h>
> +#include <stdbool.h>
>  #include <stddef.h>
>  #include <xen/xen.h>
>  #include <xen/event_channel.h>
> @@ -183,6 +184,7 @@ struct evtchn_port_info {
>  
>  struct file {
>      enum fd_type type;
> +    bool read;	/* maybe available for read */
>      union {
>  	struct {
>              /* lwIP fd */
> @@ -235,7 +237,6 @@ struct file {
>          } xenbus;
>  #endif
>      };
> -    int read;	/* maybe available for read */
>  };
>  
>  extern struct file files[];
> diff --git a/netfront.c b/netfront.c
> index dfe065b..a566e34 100644
> --- a/netfront.c
> +++ b/netfront.c
> @@ -255,7 +255,7 @@ void netfront_select_handler(evtchn_port_t port, struct pt_regs *regs, void *dat
>      local_irq_restore(flags);
>  
>      if (fd != -1)
> -        files[fd].read = 1;
> +        files[fd].read = true;
>      wake_up(&netfront_queue);
>  }
>  #endif
> @@ -783,7 +783,7 @@ ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t l
>      network_rx(dev);
>      if (!dev->rlen && fd != -1)
>          /* No data for us, make select stop returning */
> -        files[fd].read = 0;
> +        files[fd].read = false;
>      /* Before re-enabling the interrupts, in case a packet just arrived in the
>       * meanwhile. */
>      local_irq_restore(flags);
> diff --git a/tpm_tis.c b/tpm_tis.c
> index 475ac5d..4a51027 100644
> --- a/tpm_tis.c
> +++ b/tpm_tis.c
> @@ -845,7 +845,7 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
>     }
>  #ifdef HAVE_LIBC
>     if(tpm->fd >= 0) {
> -      files[tpm->fd].read = 0;
> +      files[tpm->fd].read = false;
>        files[tpm->fd].tpm_tis.respgot = 0;
>        files[tpm->fd].tpm_tis.offset = 0;
>     }
> diff --git a/tpmfront.c b/tpmfront.c
> index 6049244..d825b49 100644
> --- a/tpmfront.c
> +++ b/tpmfront.c
> @@ -66,7 +66,7 @@ void tpmfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) {
>     dev->waiting = 0;
>  #ifdef HAVE_LIBC
>     if(dev->fd >= 0) {
> -      files[dev->fd].read = 1;
> +      files[dev->fd].read = true;
>     }
>  #endif
>     wake_up(&dev->waitq);
> @@ -438,7 +438,7 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
>     dev->resplen = 0;
>  #ifdef HAVE_LIBC
>     if(dev->fd >= 0) {
> -      files[dev->fd].read = 0;
> +      files[dev->fd].read = false;
>        files[dev->fd].tpmfront.respgot = 0;
>        files[dev->fd].tpmfront.offset = 0;
>     }
> @@ -611,7 +611,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
>  
>     /* If we have a response waiting, then read it now from the backend
>      * so we can get its length*/
> -   if(dev->waiting || (files[dev->fd].read == 1 && !files[dev->fd].tpmfront.respgot)) {
> +   if(dev->waiting || (files[dev->fd].read && !files[dev->fd].tpmfront.respgot)) {
>        if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
>  	 errno = EIO;
>  	 return -1;
> -- 
> 2.26.2
> 

-- 
Samuel
> No manual is ever necessary.
May I politely interject here: BULLSHIT.  That's the biggest Apple lie of all!
(Discussion in comp.os.linux.misc on the intuitiveness of interfaces.)


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:21:08 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:21:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254961.436882 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6MtP-0001Ja-5z; Sun, 09 Jan 2022 01:21:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254961.436882; Sun, 09 Jan 2022 01:21:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6MtP-0001JS-2e; Sun, 09 Jan 2022 01:21:07 +0000
Received: by outflank-mailman (input) for mailman id 254961;
 Sun, 09 Jan 2022 01:21:05 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6MtN-0001JH-TB
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:21:05 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 69460c7f-70ea-11ec-81c1-a30af7de8005;
 Sun, 09 Jan 2022 02:21:04 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id B4FCE3A7;
 Sun,  9 Jan 2022 02:21:02 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id P1x4HL83GeeH; Sun,  9 Jan 2022 02:21:01 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 47ECA64;
 Sun,  9 Jan 2022 02:21:01 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6MtI-006iHK-8I;
 Sun, 09 Jan 2022 02:21:00 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 69460c7f-70ea-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:21:00 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
Subject: Re: [PATCH 02/15] mini-os: makes file.read bool and move it ahead of
 device specific part
Message-ID: <20220109012100.tpv42y3efylqgrhr@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-3-jgross@suse.com>
 <20220109011844.ztd7uwre6kb3dzwv@begin>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220109011844.ztd7uwre6kb3dzwv@begin>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: B4FCE3A7
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Samuel Thibault, le dim. 09 janv. 2022 02:18:44 +0100, a ecrit:
> Juergen Gross, le jeu. 06 janv. 2022 12:57:28 +0100, a ecrit:
> > The read member of struct file should be bool.
> > 
> > In order to have the device specific part at the end of the structure
> > move "read" ahead of that.
> > 
> > Signed-off-by: Juergen Gross <jgross@suse.com>
> 
> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Mmm, but tools/libs/evtchn/minios.c needs updating, doesn't it?

> > ---
> >  blkfront.c             |  4 ++--
> >  console/xencons_ring.c |  2 +-
> >  fbfront.c              | 12 ++++++------
> >  include/lib.h          |  3 ++-
> >  netfront.c             |  4 ++--
> >  tpm_tis.c              |  2 +-
> >  tpmfront.c             |  6 +++---
> >  7 files changed, 17 insertions(+), 16 deletions(-)
> > 
> > diff --git a/blkfront.c b/blkfront.c
> > index 834a978..7c8eb74 100644
> > --- a/blkfront.c
> > +++ b/blkfront.c
> > @@ -62,7 +62,7 @@ void blkfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
> >      int fd = dev->fd;
> >  
> >      if (fd != -1)
> > -        files[fd].read = 1;
> > +        files[fd].read = true;
> >  #endif
> >      wake_up(&blkfront_queue);
> >  }
> > @@ -484,7 +484,7 @@ int blkfront_aio_poll(struct blkfront_dev *dev)
> >  moretodo:
> >  #ifdef HAVE_LIBC
> >      if (dev->fd != -1) {
> > -        files[dev->fd].read = 0;
> > +        files[dev->fd].read = false;
> >          mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
> >      }
> >  #endif
> > diff --git a/console/xencons_ring.c b/console/xencons_ring.c
> > index b6db74e..c348f3c 100644
> > --- a/console/xencons_ring.c
> > +++ b/console/xencons_ring.c
> > @@ -102,7 +102,7 @@ void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data)
> >          int fd = dev ? dev->fd : -1;
> >  
> >          if (fd != -1)
> > -            files[fd].read = 1;
> > +            files[fd].read = true;
> >  
> >          wake_up(&console_queue);
> >  #else
> > diff --git a/fbfront.c b/fbfront.c
> > index d3b3848..6725da1 100644
> > --- a/fbfront.c
> > +++ b/fbfront.c
> > @@ -45,7 +45,7 @@ void kbdfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
> >      int fd = dev->fd;
> >  
> >      if (fd != -1)
> > -        files[fd].read = 1;
> > +        files[fd].read = true;
> >  #endif
> >      wake_up(&kbdfront_queue);
> >  }
> > @@ -207,7 +207,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
> >  
> >  #ifdef HAVE_LIBC
> >      if (dev->fd != -1) {
> > -        files[dev->fd].read = 0;
> > +        files[dev->fd].read = false;
> >          mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
> >      }
> >  #endif
> > @@ -229,7 +229,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
> >  #ifdef HAVE_LIBC
> >      if (cons != prod && dev->fd != -1)
> >          /* still some events to read */
> > -        files[dev->fd].read = 1;
> > +        files[dev->fd].read = true;
> >  #endif
> >  
> >      return i;
> > @@ -349,7 +349,7 @@ void fbfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
> >      int fd = dev->fd;
> >  
> >      if (fd != -1)
> > -        files[fd].read = 1;
> > +        files[fd].read = true;
> >  #endif
> >      wake_up(&fbfront_queue);
> >  }
> > @@ -376,7 +376,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
> >  
> >  #ifdef HAVE_LIBC
> >      if (dev->fd != -1) {
> > -        files[dev->fd].read = 0;
> > +        files[dev->fd].read = false;
> >          mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
> >      }
> >  #endif
> > @@ -398,7 +398,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
> >  #ifdef HAVE_LIBC
> >      if (cons != prod && dev->fd != -1)
> >          /* still some events to read */
> > -        files[dev->fd].read = 1;
> > +        files[dev->fd].read = true;
> >  #endif
> >  
> >      return i;
> > diff --git a/include/lib.h b/include/lib.h
> > index a638bc9..df2de9e 100644
> > --- a/include/lib.h
> > +++ b/include/lib.h
> > @@ -49,6 +49,7 @@
> >  #define _LIB_H_
> >  
> >  #include <stdarg.h>
> > +#include <stdbool.h>
> >  #include <stddef.h>
> >  #include <xen/xen.h>
> >  #include <xen/event_channel.h>
> > @@ -183,6 +184,7 @@ struct evtchn_port_info {
> >  
> >  struct file {
> >      enum fd_type type;
> > +    bool read;	/* maybe available for read */
> >      union {
> >  	struct {
> >              /* lwIP fd */
> > @@ -235,7 +237,6 @@ struct file {
> >          } xenbus;
> >  #endif
> >      };
> > -    int read;	/* maybe available for read */
> >  };
> >  
> >  extern struct file files[];
> > diff --git a/netfront.c b/netfront.c
> > index dfe065b..a566e34 100644
> > --- a/netfront.c
> > +++ b/netfront.c
> > @@ -255,7 +255,7 @@ void netfront_select_handler(evtchn_port_t port, struct pt_regs *regs, void *dat
> >      local_irq_restore(flags);
> >  
> >      if (fd != -1)
> > -        files[fd].read = 1;
> > +        files[fd].read = true;
> >      wake_up(&netfront_queue);
> >  }
> >  #endif
> > @@ -783,7 +783,7 @@ ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t l
> >      network_rx(dev);
> >      if (!dev->rlen && fd != -1)
> >          /* No data for us, make select stop returning */
> > -        files[fd].read = 0;
> > +        files[fd].read = false;
> >      /* Before re-enabling the interrupts, in case a packet just arrived in the
> >       * meanwhile. */
> >      local_irq_restore(flags);
> > diff --git a/tpm_tis.c b/tpm_tis.c
> > index 475ac5d..4a51027 100644
> > --- a/tpm_tis.c
> > +++ b/tpm_tis.c
> > @@ -845,7 +845,7 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
> >     }
> >  #ifdef HAVE_LIBC
> >     if(tpm->fd >= 0) {
> > -      files[tpm->fd].read = 0;
> > +      files[tpm->fd].read = false;
> >        files[tpm->fd].tpm_tis.respgot = 0;
> >        files[tpm->fd].tpm_tis.offset = 0;
> >     }
> > diff --git a/tpmfront.c b/tpmfront.c
> > index 6049244..d825b49 100644
> > --- a/tpmfront.c
> > +++ b/tpmfront.c
> > @@ -66,7 +66,7 @@ void tpmfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) {
> >     dev->waiting = 0;
> >  #ifdef HAVE_LIBC
> >     if(dev->fd >= 0) {
> > -      files[dev->fd].read = 1;
> > +      files[dev->fd].read = true;
> >     }
> >  #endif
> >     wake_up(&dev->waitq);
> > @@ -438,7 +438,7 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
> >     dev->resplen = 0;
> >  #ifdef HAVE_LIBC
> >     if(dev->fd >= 0) {
> > -      files[dev->fd].read = 0;
> > +      files[dev->fd].read = false;
> >        files[dev->fd].tpmfront.respgot = 0;
> >        files[dev->fd].tpmfront.offset = 0;
> >     }
> > @@ -611,7 +611,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
> >  
> >     /* If we have a response waiting, then read it now from the backend
> >      * so we can get its length*/
> > -   if(dev->waiting || (files[dev->fd].read == 1 && !files[dev->fd].tpmfront.respgot)) {
> > +   if(dev->waiting || (files[dev->fd].read && !files[dev->fd].tpmfront.respgot)) {
> >        if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
> >  	 errno = EIO;
> >  	 return -1;
> > -- 
> > 2.26.2
> > 
> 
> -- 
> Samuel
> > No manual is ever necessary.
> May I politely interject here: BULLSHIT.  That's the biggest Apple lie of all!
> (Discussion in comp.os.linux.misc on the intuitiveness of interfaces.)

-- 
Samuel
<c> xlnt comme sujet de stage je peux essayer de donner une description formelle de automake
 -+- #ens-mim -+-


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:23:18 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:23:18 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254968.436907 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6MvV-0002Gr-TU; Sun, 09 Jan 2022 01:23:17 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254968.436907; Sun, 09 Jan 2022 01:23:17 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6MvV-0002Gk-Q2; Sun, 09 Jan 2022 01:23:17 +0000
Received: by outflank-mailman (input) for mailman id 254968;
 Sun, 09 Jan 2022 01:23:16 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6MvU-00020e-1U
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:23:16 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id b711d1c4-70ea-11ec-9ce5-af14b9085ebd;
 Sun, 09 Jan 2022 02:23:14 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 851FA3A7;
 Sun,  9 Jan 2022 02:23:13 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id Pqr1WHjmhjWY; Sun,  9 Jan 2022 02:23:12 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 4090E331;
 Sun,  9 Jan 2022 02:23:12 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6MvP-006iIv-Eq;
 Sun, 09 Jan 2022 02:23:11 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: b711d1c4-70ea-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:23:11 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 03/15] mini-os: make offset a common struct file member
 for all types
Message-ID: <20220109012311.hzqr2pganyngte5b@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-4-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220106115741.3219-4-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 851FA3A7
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:29 +0100, a ecrit:
> Currently 4 file types have an offset member in their private struct
> file part. Make offset a common struct member shared by all file types.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  blkfront.c    |  5 ++---
>  include/lib.h |  5 +----
>  lib/sys.c     | 14 +++++---------
>  tpm_tis.c     | 11 +++++------
>  tpmfront.c    | 11 +++++------
>  5 files changed, 18 insertions(+), 28 deletions(-)
> 
> diff --git a/blkfront.c b/blkfront.c
> index 7c8eb74..8137106 100644
> --- a/blkfront.c
> +++ b/blkfront.c
> @@ -563,14 +563,13 @@ int blkfront_open(struct blkfront_dev *dev)
>      dev->fd = alloc_fd(FTYPE_BLK);
>      printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
>      files[dev->fd].blk.dev = dev;
> -    files[dev->fd].blk.offset = 0;
>      return dev->fd;
>  }
>  
>  int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
>  {
>     struct blkfront_dev* dev = files[fd].blk.dev;
> -   off_t offset = files[fd].blk.offset;
> +   off_t offset = files[fd].offset;
>     struct blkfront_aiocb aiocb;
>     unsigned long long disksize = dev->info.sectors * dev->info.sector_size;
>     unsigned int blocksize = dev->info.sector_size;
> @@ -712,7 +711,7 @@ int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
>     }
>  
>     free(copybuf);
> -   files[fd].blk.offset += rc;
> +   files[fd].offset += rc;
>     return rc;
>  
>  }
> diff --git a/include/lib.h b/include/lib.h
> index df2de9e..4d9b14b 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -185,6 +185,7 @@ struct evtchn_port_info {
>  struct file {
>      enum fd_type type;
>      bool read;	/* maybe available for read */
> +    off_t offset;
>      union {
>  	struct {
>              /* lwIP fd */
> @@ -193,7 +194,6 @@ struct file {
>  	struct {
>              /* FS import fd */
>  	    int fd;
> -	    off_t offset;
>  	} file;
>  	struct {
>  	    struct evtchn_port_list ports;
> @@ -204,7 +204,6 @@ struct file {
>  	} tap;
>  	struct {
>  	    struct blkfront_dev *dev;
> -            off_t offset;
>  	} blk;
>  	struct {
>  	    struct kbdfront_dev *dev;
> @@ -219,14 +218,12 @@ struct file {
>  	struct {
>  	   struct tpmfront_dev *dev;
>  	   int respgot;
> -	   off_t offset;
>  	} tpmfront;
>  #endif
>  #ifdef CONFIG_TPM_TIS
>  	struct {
>  	   struct tpm_chip *dev;
>  	   int respgot;
> -	   off_t offset;
>  	} tpm_tis;
>  #endif
>  #ifdef CONFIG_XENBUS
> diff --git a/lib/sys.c b/lib/sys.c
> index e8d5eb2..e1cea70 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -107,6 +107,7 @@ int alloc_fd(enum fd_type type)
>      for (i=0; i<NOFILE; i++) {
>  	if (files[i].type == FTYPE_NONE) {
>  	    files[i].type = type;
> +            files[i].offset = 0;
>  	    pthread_mutex_unlock(&fd_lock);
>  	    return i;
>  	}
> @@ -363,25 +364,20 @@ int write(int fd, const void *buf, size_t nbytes)
>  
>  off_t lseek(int fd, off_t offset, int whence)
>  {
> -    off_t* target = NULL;
>      switch(files[fd].type) {
>  #ifdef CONFIG_BLKFRONT
>         case FTYPE_BLK:
> -          target = &files[fd].blk.offset;
>            break;
>  #endif
>  #ifdef CONFIG_TPMFRONT
>         case FTYPE_TPMFRONT:
> -          target = &files[fd].tpmfront.offset;
>            break;
>  #endif
>  #ifdef CONFIG_TPM_TIS
>         case FTYPE_TPM_TIS:
> -          target = &files[fd].tpm_tis.offset;
>            break;
>  #endif
>         case FTYPE_FILE:
> -          target = &files[fd].file.offset;
>            break;
>         default:
>            /* Not implemented for this filetype */
> @@ -391,10 +387,10 @@ off_t lseek(int fd, off_t offset, int whence)
>  
>      switch (whence) {
>         case SEEK_SET:
> -          *target = offset;
> +          files[fd].offset = offset;
>            break;
>         case SEEK_CUR:
> -          *target += offset;
> +          files[fd].offset += offset;
>            break;
>         case SEEK_END:
>            {
> @@ -403,14 +399,14 @@ off_t lseek(int fd, off_t offset, int whence)
>               ret = fstat(fd, &st);
>               if (ret)
>                  return -1;
> -             *target = st.st_size + offset;
> +             files[fd].offset = st.st_size + offset;
>               break;
>            }
>         default:
>            errno = EINVAL;
>            return -1;
>      }
> -    return *target;
> +    return files[fd].offset;
>  }
>  
>  int fsync(int fd) {
> diff --git a/tpm_tis.c b/tpm_tis.c
> index 4a51027..8a632b1 100644
> --- a/tpm_tis.c
> +++ b/tpm_tis.c
> @@ -847,7 +847,7 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
>     if(tpm->fd >= 0) {
>        files[tpm->fd].read = false;
>        files[tpm->fd].tpm_tis.respgot = 0;
> -      files[tpm->fd].tpm_tis.offset = 0;
> +      files[tpm->fd].offset = 0;
>     }
>  #endif
>     return len;
> @@ -1290,7 +1290,6 @@ int tpm_tis_open(struct tpm_chip* tpm)
>     tpm->fd = alloc_fd(FTYPE_TPM_TIS);
>     printk("tpm_tis_open() -> %d\n", tpm->fd);
>     files[tpm->fd].tpm_tis.dev = tpm;
> -   files[tpm->fd].tpm_tis.offset = 0;
>     files[tpm->fd].tpm_tis.respgot = 0;
>     return tpm->fd;
>  }
> @@ -1340,13 +1339,13 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
>  
>  
>     /* Handle EOF case */
> -   if(files[fd].tpm_tis.offset >= tpm->data_len) {
> +   if(files[fd].offset >= tpm->data_len) {
>        rc = 0;
>     } else {
> -      rc = min(tpm->data_len - files[fd].tpm_tis.offset, count);
> -      memcpy(buf, tpm->data_buffer + files[fd].tpm_tis.offset, rc);
> +      rc = min(tpm->data_len - files[fd].offset, count);
> +      memcpy(buf, tpm->data_buffer + files[fd].offset, rc);
>     }
> -   files[fd].tpm_tis.offset += rc;
> +   files[fd].offset += rc;
>     /* Reset the data pending flag */
>     return rc;
>  }
> diff --git a/tpmfront.c b/tpmfront.c
> index d825b49..8b2a910 100644
> --- a/tpmfront.c
> +++ b/tpmfront.c
> @@ -440,7 +440,7 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
>     if(dev->fd >= 0) {
>        files[dev->fd].read = false;
>        files[dev->fd].tpmfront.respgot = 0;
> -      files[dev->fd].tpmfront.offset = 0;
> +      files[dev->fd].offset = 0;
>     }
>  #endif
>     wmb();
> @@ -539,7 +539,6 @@ int tpmfront_open(struct tpmfront_dev* dev)
>     dev->fd = alloc_fd(FTYPE_TPMFRONT);
>     printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
>     files[dev->fd].tpmfront.dev = dev;
> -   files[dev->fd].tpmfront.offset = 0;
>     files[dev->fd].tpmfront.respgot = 0;
>     return dev->fd;
>  }
> @@ -589,14 +588,14 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
>     }
>  
>     /* handle EOF case */
> -   if(files[dev->fd].tpmfront.offset >= dev->resplen) {
> +   if(files[dev->fd].offset >= dev->resplen) {
>        return 0;
>     }
>  
>     /* Compute the number of bytes and do the copy operation */
> -   if((rc = min(count, dev->resplen - files[dev->fd].tpmfront.offset)) != 0) {
> -      memcpy(buf, dev->respbuf + files[dev->fd].tpmfront.offset, rc);
> -      files[dev->fd].tpmfront.offset += rc;
> +   if((rc = min(count, dev->resplen - files[dev->fd].offset)) != 0) {
> +      memcpy(buf, dev->respbuf + files[dev->fd].offset, rc);
> +      files[dev->fd].offset += rc;
>     }
>  
>     return rc;
> -- 
> 2.26.2
> 

-- 
Samuel
`When you say "I wrote a program that crashed Windows", people just stare at
you blankly and say "Hey, I got those with the system, *for free*".'
(By Linus Torvalds)


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:25:40 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:25:40 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254973.436923 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6Mxn-0002vx-D1; Sun, 09 Jan 2022 01:25:39 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254973.436923; Sun, 09 Jan 2022 01:25:39 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6Mxn-0002vq-9P; Sun, 09 Jan 2022 01:25:39 +0000
Received: by outflank-mailman (input) for mailman id 254973;
 Sun, 09 Jan 2022 01:25:37 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6Mxl-0002fv-Br
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:25:37 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 0b59b941-70eb-11ec-81c1-a30af7de8005;
 Sun, 09 Jan 2022 02:25:35 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id EAC5B346;
 Sun,  9 Jan 2022 02:25:34 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id bE8UVSb-c4mp; Sun,  9 Jan 2022 02:25:33 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 66036331;
 Sun,  9 Jan 2022 02:25:33 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6Mxg-006iNc-FY;
 Sun, 09 Jan 2022 02:25:32 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 0b59b941-70eb-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:25:32 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 04/15] mini-os: replace multiple fd elements in struct
 file by common one
Message-ID: <20220109012532.3xggmswcyfgs2xiq@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-5-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220106115741.3219-5-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: EAC5B346
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:30 +0100, a ecrit:
> The type specific union in struct files contains two instances of
> "int fd". Replace them by a common one.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h |  9 +--------
>  lib/sys.c     | 28 ++++++++++++++--------------
>  2 files changed, 15 insertions(+), 22 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 4d9b14b..dc56f52 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -187,14 +187,7 @@ struct file {
>      bool read;	/* maybe available for read */
>      off_t offset;
>      union {
> -	struct {
> -            /* lwIP fd */
> -	    int fd;
> -	} socket;
> -	struct {
> -            /* FS import fd */
> -	    int fd;
> -	} file;
> +        int fd; /* Any fd from an upper layer. */
>  	struct {
>  	    struct evtchn_port_list ports;
>  	} evtchn;
> diff --git a/lib/sys.c b/lib/sys.c
> index e1cea70..1da7401 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -258,7 +258,7 @@ int read(int fd, void *buf, size_t nbytes)
>          }
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
> -	    return lwip_read(files[fd].socket.fd, buf, nbytes);
> +	    return lwip_read(files[fd].fd, buf, nbytes);
>  #endif
>  #ifdef CONFIG_NETFRONT
>  	case FTYPE_TAP: {
> @@ -335,7 +335,7 @@ int write(int fd, const void *buf, size_t nbytes)
>  	    return nbytes;
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
> -	    return lwip_write(files[fd].socket.fd, (void*) buf, nbytes);
> +	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
>  #endif
>  #ifdef CONFIG_NETFRONT
>  	case FTYPE_TAP:
> @@ -428,7 +428,7 @@ int close(int fd)
>  #endif
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET: {
> -	    int res = lwip_close(files[fd].socket.fd);
> +	    int res = lwip_close(files[fd].fd);
>  	    files[fd].type = FTYPE_NONE;
>  	    return res;
>  	}
> @@ -594,7 +594,7 @@ int fcntl(int fd, int cmd, ...)
>  	    if (files[fd].type == FTYPE_SOCKET && !(arg & ~O_NONBLOCK)) {
>  		/* Only flag supported: non-blocking mode */
>  		uint32_t nblock = !!(arg & O_NONBLOCK);
> -		return lwip_ioctl(files[fd].socket.fd, FIONBIO, &nblock);
> +		return lwip_ioctl(files[fd].fd, FIONBIO, &nblock);
>  	    }
>  	    /* Fallthrough */
>  #endif
> @@ -732,15 +732,15 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>      for (i = 0; i < nfds; i++) {
>  	if (files[i].type == FTYPE_SOCKET) {
>  	    if (FD_ISSET(i, readfds)) {
> -		FD_SET(files[i].socket.fd, &sock_readfds);
> +		FD_SET(files[i].fd, &sock_readfds);
>  		sock_nfds = i+1;
>  	    }
>  	    if (FD_ISSET(i, writefds)) {
> -		FD_SET(files[i].socket.fd, &sock_writefds);
> +		FD_SET(files[i].fd, &sock_writefds);
>  		sock_nfds = i+1;
>  	    }
>  	    if (FD_ISSET(i, exceptfds)) {
> -		FD_SET(files[i].socket.fd, &sock_exceptfds);
> +		FD_SET(files[i].fd, &sock_exceptfds);
>  		sock_nfds = i+1;
>  	    }
>  	}
> @@ -803,19 +803,19 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  	case FTYPE_SOCKET:
>  	    if (FD_ISSET(i, readfds)) {
>  	        /* Optimize no-network-packet case.  */
> -		if (sock_n && FD_ISSET(files[i].socket.fd, &sock_readfds))
> +		if (sock_n && FD_ISSET(files[i].fd, &sock_readfds))
>  		    n++;
>  		else
>  		    FD_CLR(i, readfds);
>  	    }
>              if (FD_ISSET(i, writefds)) {
> -		if (sock_n && FD_ISSET(files[i].socket.fd, &sock_writefds))
> +		if (sock_n && FD_ISSET(files[i].fd, &sock_writefds))
>  		    n++;
>  		else
>  		    FD_CLR(i, writefds);
>              }
>              if (FD_ISSET(i, exceptfds)) {
> -		if (sock_n && FD_ISSET(files[i].socket.fd, &sock_exceptfds))
> +		if (sock_n && FD_ISSET(files[i].fd, &sock_exceptfds))
>  		    n++;
>  		else
>  		    FD_CLR(i, exceptfds);
> @@ -1112,7 +1112,7 @@ int socket(int domain, int type, int protocol)
>  	return -1;
>      res = alloc_fd(FTYPE_SOCKET);
>      printk("socket -> %d\n", res);
> -    files[res].socket.fd = fd;
> +    files[res].fd = fd;
>      return res;
>  }
>  
> @@ -1124,11 +1124,11 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
>  	errno = EBADF;
>  	return -1;
>      }
> -    fd = lwip_accept(files[s].socket.fd, addr, addrlen);
> +    fd = lwip_accept(files[s].fd, addr, addrlen);
>      if (fd < 0)
>  	return -1;
>      res = alloc_fd(FTYPE_SOCKET);
> -    files[res].socket.fd = fd;
> +    files[res].fd = fd;
>      printk("accepted on %d -> %d\n", s, res);
>      return res;
>  }
> @@ -1141,7 +1141,7 @@ ret name proto \
>  	errno = EBADF; \
>  	return -1; \
>      } \
> -    s = files[s].socket.fd; \
> +    s = files[s].fd; \
>      return lwip_##name args; \
>  }
>  
> -- 
> 2.26.2
> 

-- 
Samuel
<c> xlnt comme sujet de stage je peux essayer de donner une description formelle de automake
 -+- #ens-mim -+-


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:25:50 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:25:50 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254975.436931 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6Mxy-0003Cr-TQ; Sun, 09 Jan 2022 01:25:50 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254975.436931; Sun, 09 Jan 2022 01:25:50 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6Mxy-0003Ay-PY; Sun, 09 Jan 2022 01:25:50 +0000
Received: by outflank-mailman (input) for mailman id 254975;
 Sun, 09 Jan 2022 01:25:49 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6Mxx-00033A-Kh
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:25:49 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 12c83944-70eb-11ec-9ce5-af14b9085ebd;
 Sun, 09 Jan 2022 02:25:47 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 74BB4346;
 Sun,  9 Jan 2022 02:25:47 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id aohzlgKPsW72; Sun,  9 Jan 2022 02:25:46 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id BE9EF64;
 Sun,  9 Jan 2022 02:25:46 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6Mxu-006iNr-B7;
 Sun, 09 Jan 2022 02:25:46 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 12c83944-70eb-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:25:46 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 05/15] mini-os: introduce a common dev pointer in struct
 file
Message-ID: <20220109012546.m3ibst5odqcpyzxl@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-6-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220106115741.3219-6-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 74BB4346
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:31 +0100, a ecrit:
> There are many dev pointers in a union in struct file. Prepare to
> switch to a single one by introducing a new common one.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/lib.h b/include/lib.h
> index dc56f52..60aaf1c 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -188,6 +188,7 @@ struct file {
>      off_t offset;
>      union {
>          int fd; /* Any fd from an upper layer. */
> +        void *dev;
>  	struct {
>  	    struct evtchn_port_list ports;
>  	} evtchn;
> -- 
> 2.26.2
> 

-- 
Samuel
Now I know someone out there is going to claim, "Well then, UNIX is intuitive,
because you only need to learn 5000 commands, and then everything else follows
from that! Har har har!"
(Andy Bates in comp.os.linux.misc, on "intuitive interfaces", slightly
defending Macs.)


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:26:29 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:26:29 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254979.436941 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6Mya-0003xv-Vy; Sun, 09 Jan 2022 01:26:28 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254979.436941; Sun, 09 Jan 2022 01:26:28 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6Mya-0003xo-T1; Sun, 09 Jan 2022 01:26:28 +0000
Received: by outflank-mailman (input) for mailman id 254979;
 Sun, 09 Jan 2022 01:26:27 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6MyZ-0002fv-Jl
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:26:27 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 29fec98f-70eb-11ec-81c1-a30af7de8005;
 Sun, 09 Jan 2022 02:26:26 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 378A5346;
 Sun,  9 Jan 2022 02:26:26 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id sv4vUZ5LBzCD; Sun,  9 Jan 2022 02:26:25 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 8DE4964;
 Sun,  9 Jan 2022 02:26:25 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6MyW-006iP0-S2;
 Sun, 09 Jan 2022 02:26:24 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 29fec98f-70eb-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:26:24 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 06/15] mini-os: eliminate blkfront union member in struct
 file
Message-ID: <20220109012624.zsd2agf7hhmcyd2r@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-7-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20220106115741.3219-7-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 378A5346
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:32 +0100, a ecrit:
> Replace the blkfront specific union member in struct file with the
> common dev pointer.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  blkfront.c    | 6 +++---
>  include/lib.h | 3 ---
>  lib/sys.c     | 2 +-
>  3 files changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/blkfront.c b/blkfront.c
> index 8137106..e3f42be 100644
> --- a/blkfront.c
> +++ b/blkfront.c
> @@ -562,13 +562,13 @@ int blkfront_open(struct blkfront_dev *dev)
>      }
>      dev->fd = alloc_fd(FTYPE_BLK);
>      printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
> -    files[dev->fd].blk.dev = dev;
> +    files[dev->fd].dev = dev;
>      return dev->fd;
>  }
>  
>  int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
>  {
> -   struct blkfront_dev* dev = files[fd].blk.dev;
> +   struct blkfront_dev* dev = files[fd].dev;
>     off_t offset = files[fd].offset;
>     struct blkfront_aiocb aiocb;
>     unsigned long long disksize = dev->info.sectors * dev->info.sector_size;
> @@ -718,7 +718,7 @@ int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
>  
>  int blkfront_posix_fstat(int fd, struct stat* buf)
>  {
> -   struct blkfront_dev* dev = files[fd].blk.dev;
> +   struct blkfront_dev* dev = files[fd].dev;
>  
>     buf->st_mode = dev->info.mode;
>     buf->st_uid = 0;
> diff --git a/include/lib.h b/include/lib.h
> index 60aaf1c..3a40634 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -196,9 +196,6 @@ struct file {
>  	struct {
>  	    struct netfront_dev *dev;
>  	} tap;
> -	struct {
> -	    struct blkfront_dev *dev;
> -	} blk;
>  	struct {
>  	    struct kbdfront_dev *dev;
>  	} kbd;
> diff --git a/lib/sys.c b/lib/sys.c
> index 1da7401..f2fdbdf 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -456,7 +456,7 @@ int close(int fd)
>  #endif
>  #ifdef CONFIG_BLKFRONT
>  	case FTYPE_BLK:
> -            shutdown_blkfront(files[fd].blk.dev);
> +            shutdown_blkfront(files[fd].dev);
>  	    files[fd].type = FTYPE_NONE;
>  	    return 0;
>  #endif
> -- 
> 2.26.2
> 

-- 
Samuel
Accroche-toi au terminal, j'enlève le shell...
 -+- nojhan -+-


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:27:35 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:27:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254986.436956 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6Mze-0004iN-CT; Sun, 09 Jan 2022 01:27:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254986.436956; Sun, 09 Jan 2022 01:27:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6Mze-0004iG-94; Sun, 09 Jan 2022 01:27:34 +0000
Received: by outflank-mailman (input) for mailman id 254986;
 Sun, 09 Jan 2022 01:27:33 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6Mzc-0004i1-Vx
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:27:32 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 50c76975-70eb-11ec-81c1-a30af7de8005;
 Sun, 09 Jan 2022 02:27:31 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 7BC69331;
 Sun,  9 Jan 2022 02:27:31 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id v3emtEJI6slJ; Sun,  9 Jan 2022 02:27:30 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 3587D64;
 Sun,  9 Jan 2022 02:27:30 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6MzZ-006iPj-HL;
 Sun, 09 Jan 2022 02:27:29 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 50c76975-70eb-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:27:29 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 07/15] mini-os: eliminate consfront union member in
 struct file
Message-ID: <20220109012729.kyt3ksnyq3wu6edb@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-8-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220106115741.3219-8-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 7BC69331
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:33 +0100, a ecrit:
> Replace the consfront specific union member in struct file with the
> common dev pointer.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h |  3 ---
>  lib/sys.c     | 31 +++++++++++++++++--------------
>  2 files changed, 17 insertions(+), 17 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 3a40634..0cedae6 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -202,9 +202,6 @@ struct file {
>  	struct {
>  	    struct fbfront_dev *dev;
>  	} fb;
> -	struct {
> -	    struct consfront_dev *dev;
> -	} cons;
>  #ifdef CONFIG_TPMFRONT
>  	struct {
>  	   struct tpmfront_dev *dev;
> diff --git a/lib/sys.c b/lib/sys.c
> index f2fdbdf..62c2020 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -179,7 +179,7 @@ int posix_openpt(int flags)
>  
>      dev = init_consfront(NULL);
>      dev->fd = alloc_fd(FTYPE_CONSOLE);
> -    files[dev->fd].cons.dev = dev;
> +    files[dev->fd].dev = dev;
>  
>      printk("fd(%d) = posix_openpt\n", dev->fd);
>      return(dev->fd);
> @@ -194,7 +194,7 @@ int open_savefile(const char *path, int save)
>  
>      dev = init_consfront(nodename);
>      dev->fd = alloc_fd(FTYPE_SAVEFILE);
> -    files[dev->fd].cons.dev = dev;
> +    files[dev->fd].dev = dev;
>  
>      printk("fd(%d) = open_savefile\n", dev->fd);
>      return(dev->fd);
> @@ -248,7 +248,7 @@ int read(int fd, void *buf, size_t nbytes)
>              DEFINE_WAIT(w);
>              while(1) {
>                  add_waiter(w, console_queue);
> -                ret = xencons_ring_recv(files[fd].cons.dev, buf, nbytes);
> +                ret = xencons_ring_recv(files[fd].dev, buf, nbytes);
>                  if (ret)
>                      break;
>                  schedule();
> @@ -324,14 +324,14 @@ int write(int fd, const void *buf, size_t nbytes)
>          case FTYPE_SAVEFILE: {
>                  int ret = 0, tot = nbytes;
>                  while (nbytes > 0) {
> -                    ret = xencons_ring_send(files[fd].cons.dev, (char *)buf, nbytes);
> +                    ret = xencons_ring_send(files[fd].dev, (char *)buf, nbytes);
>                      nbytes -= ret;
>                      buf = (char *)buf + ret;
>                  }
>                  return tot - nbytes;
>              }
>  	case FTYPE_CONSOLE:
> -	    console_print(files[fd].cons.dev, (char *)buf, nbytes);
> +	    console_print(files[fd].dev, (char *)buf, nbytes);
>  	    return nbytes;
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
> @@ -487,7 +487,7 @@ int close(int fd)
>  #ifdef CONFIG_CONSFRONT
>          case FTYPE_SAVEFILE:
>          case FTYPE_CONSOLE:
> -            fini_consfront(files[fd].cons.dev);
> +            fini_consfront(files[fd].dev);
>              files[fd].type = FTYPE_NONE;
>              return 0;
>  #endif
> @@ -764,7 +764,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  	    /* Fallthrough.  */
>  	case FTYPE_CONSOLE:
>  	    if (FD_ISSET(i, readfds)) {
> -                if (xencons_ring_avail(files[i].cons.dev))
> +                if (xencons_ring_avail(files[i].dev))
>  		    n++;
>  		else
>  		    FD_CLR(i, readfds);
> @@ -1447,6 +1447,8 @@ const struct termios default_termios = {0,             /* iflag */
>  
>  int tcsetattr(int fildes, int action, const struct termios *tios)
>  {
> +    struct consfront_dev *dev;
> +
>      if (fildes < 0 || fildes >= NOFILE) {
>          errno = EBADF;
>          return -1;
> @@ -1472,21 +1474,21 @@ int tcsetattr(int fildes, int action, const struct termios *tios)
>              return -1;
>      }
>  
> -    if (files[fildes].cons.dev == NULL) {
> +    dev = files[fildes].dev;
> +    if (dev == NULL) {
>          errno = ENOSYS;
>          return -1;
>      }
>  
> -    if (tios->c_oflag & OPOST)
> -        files[fildes].cons.dev->is_raw = false;
> -    else
> -        files[fildes].cons.dev->is_raw = true;
> +    dev->is_raw = !(tios->c_oflag & OPOST);
>  
>      return 0;
>  }
>  
>  int tcgetattr(int fildes, struct termios *tios)
>  {
> +    struct consfront_dev *dev;
> +
>      if (fildes < 0 || fildes >= NOFILE) {
>          errno = EBADF;
>          return -1;
> @@ -1497,7 +1499,8 @@ int tcgetattr(int fildes, struct termios *tios)
>          return -1;
>      }
>  
> -    if (files[fildes].cons.dev == NULL) {
> +    dev = files[fildes].dev;
> +    if (dev == NULL) {
>          errno = ENOSYS;
>          return 0;
>      }
> @@ -1509,7 +1512,7 @@ int tcgetattr(int fildes, struct termios *tios)
>  
>      memcpy(tios, &default_termios, sizeof(struct termios));
>  
> -    if (files[fildes].cons.dev->is_raw)
> +    if (dev->is_raw)
>          tios->c_oflag &= ~OPOST;
>  
>      return 0;
> -- 
> 2.26.2
> 

-- 
Samuel
<s> on se croirait en cool : Some browsers close comments on the first ">" character, so to hide script content from such browsers, you can transpose operands for relational and shift operators (e.g., use "y < x" rather than "x > y") or use scripting language-dependent escapes for ">".
 -+- #ens-mim -+-


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:27:58 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:27:58 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254989.436972 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N02-0005Ir-Nr; Sun, 09 Jan 2022 01:27:58 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254989.436972; Sun, 09 Jan 2022 01:27:58 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N02-0005Ik-Kh; Sun, 09 Jan 2022 01:27:58 +0000
Received: by outflank-mailman (input) for mailman id 254989;
 Sun, 09 Jan 2022 01:27:57 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6N01-0005IG-Ge
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:27:57 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 5f6cafa4-70eb-11ec-9ce5-af14b9085ebd;
 Sun, 09 Jan 2022 02:27:56 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 11CCC346;
 Sun,  9 Jan 2022 02:27:56 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id XVGfLPZ5rbkE; Sun,  9 Jan 2022 02:27:55 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 8E0F0331;
 Sun,  9 Jan 2022 02:27:55 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6Mzz-006iQU-57;
 Sun, 09 Jan 2022 02:27:55 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 5f6cafa4-70eb-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:27:55 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 08/15] mini-os: eliminate fbfront union member in struct
 file
Message-ID: <20220109012755.cboatcoozf3ntwkt@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-9-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20220106115741.3219-9-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 11CCC346
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:34 +0100, a ecrit:
> Replace the fbfront specific union member in struct file with the
> common dev pointer.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  fbfront.c     | 2 +-
>  include/lib.h | 3 ---
>  lib/sys.c     | 4 ++--
>  3 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/fbfront.c b/fbfront.c
> index 6725da1..c8410af 100644
> --- a/fbfront.c
> +++ b/fbfront.c
> @@ -703,7 +703,7 @@ int fbfront_open(struct fbfront_dev *dev)
>  {
>      dev->fd = alloc_fd(FTYPE_FB);
>      printk("fb_open(%s) -> %d\n", dev->nodename, dev->fd);
> -    files[dev->fd].fb.dev = dev;
> +    files[dev->fd].dev = dev;
>      return dev->fd;
>  }
>  #endif
> diff --git a/include/lib.h b/include/lib.h
> index 0cedae6..2a9a01c 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -199,9 +199,6 @@ struct file {
>  	struct {
>  	    struct kbdfront_dev *dev;
>  	} kbd;
> -	struct {
> -	    struct fbfront_dev *dev;
> -	} fb;
>  #ifdef CONFIG_TPMFRONT
>  	struct {
>  	   struct tpmfront_dev *dev;
> diff --git a/lib/sys.c b/lib/sys.c
> index 62c2020..2d48657 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -287,7 +287,7 @@ int read(int fd, void *buf, size_t nbytes)
>          case FTYPE_FB: {
>              int ret, n;
>              n = nbytes / sizeof(union xenfb_in_event);
> -            ret = fbfront_receive(files[fd].fb.dev, buf, n);
> +            ret = fbfront_receive(files[fd].dev, buf, n);
>  	    if (ret <= 0) {
>  		errno = EAGAIN;
>  		return -1;
> @@ -480,7 +480,7 @@ int close(int fd)
>  #endif
>  #ifdef CONFIG_FBFRONT
>  	case FTYPE_FB:
> -            shutdown_fbfront(files[fd].fb.dev);
> +            shutdown_fbfront(files[fd].dev);
>              files[fd].type = FTYPE_NONE;
>              return 0;
>  #endif
> -- 
> 2.26.2
> 

-- 
Samuel
       La  fonction  memfrob() crypte les n premiers octets de la
       zone de mémoire  s  en  effectuant  un  OU-exclusif  entre
       chaque  octet  et le nombre 42.
(extrait de la page de man de memfrob -- Manuel du programmeur Linux)


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:28:21 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:28:21 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254995.436987 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N0P-0005wY-2A; Sun, 09 Jan 2022 01:28:21 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254995.436987; Sun, 09 Jan 2022 01:28:21 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N0O-0005wR-VG; Sun, 09 Jan 2022 01:28:20 +0000
Received: by outflank-mailman (input) for mailman id 254995;
 Sun, 09 Jan 2022 01:28:20 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6N0O-0005IG-GP
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:28:20 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 6d4f76c0-70eb-11ec-9ce5-af14b9085ebd;
 Sun, 09 Jan 2022 02:28:19 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 5997D346;
 Sun,  9 Jan 2022 02:28:19 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id W77v-MeaXf17; Sun,  9 Jan 2022 02:28:18 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id C3EE0331;
 Sun,  9 Jan 2022 02:28:18 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6N0M-006iRA-Bp;
 Sun, 09 Jan 2022 02:28:18 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 6d4f76c0-70eb-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:28:18 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 09/15] mini-os: eliminate kbdfront union member in struct
 file
Message-ID: <20220109012818.fvdt6mjv65itsocw@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-10-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220106115741.3219-10-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 5997D346
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:35 +0100, a ecrit:
> Replace the kbdfront specific union member in struct file with the
> common dev pointer.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  fbfront.c     | 2 +-
>  include/lib.h | 3 ---
>  lib/sys.c     | 4 ++--
>  3 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/fbfront.c b/fbfront.c
> index c8410af..1e055fb 100644
> --- a/fbfront.c
> +++ b/fbfront.c
> @@ -302,7 +302,7 @@ int kbdfront_open(struct kbdfront_dev *dev)
>  {
>      dev->fd = alloc_fd(FTYPE_KBD);
>      printk("kbd_open(%s) -> %d\n", dev->nodename, dev->fd);
> -    files[dev->fd].kbd.dev = dev;
> +    files[dev->fd].dev = dev;
>      return dev->fd;
>  }
>  #endif
> diff --git a/include/lib.h b/include/lib.h
> index 2a9a01c..5201ed7 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -196,9 +196,6 @@ struct file {
>  	struct {
>  	    struct netfront_dev *dev;
>  	} tap;
> -	struct {
> -	    struct kbdfront_dev *dev;
> -	} kbd;
>  #ifdef CONFIG_TPMFRONT
>  	struct {
>  	   struct tpmfront_dev *dev;
> diff --git a/lib/sys.c b/lib/sys.c
> index 2d48657..8c7ea3c 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -275,7 +275,7 @@ int read(int fd, void *buf, size_t nbytes)
>          case FTYPE_KBD: {
>              int ret, n;
>              n = nbytes / sizeof(union xenkbd_in_event);
> -            ret = kbdfront_receive(files[fd].kbd.dev, buf, n);
> +            ret = kbdfront_receive(files[fd].dev, buf, n);
>  	    if (ret <= 0) {
>  		errno = EAGAIN;
>  		return -1;
> @@ -474,7 +474,7 @@ int close(int fd)
>  #endif
>  #ifdef CONFIG_KBDFRONT
>  	case FTYPE_KBD:
> -            shutdown_kbdfront(files[fd].kbd.dev);
> +            shutdown_kbdfront(files[fd].dev);
>              files[fd].type = FTYPE_NONE;
>              return 0;
>  #endif
> -- 
> 2.26.2
> 

-- 
Samuel
X-Favorit-Cartoon: Calvin and Hobbes
 -+- Mail header of Wim van Dorst -+-


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:28:49 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:28:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254998.437013 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N0q-0006tP-QW; Sun, 09 Jan 2022 01:28:48 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254998.437013; Sun, 09 Jan 2022 01:28:48 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N0q-0006tI-Me; Sun, 09 Jan 2022 01:28:48 +0000
Received: by outflank-mailman (input) for mailman id 254998;
 Sun, 09 Jan 2022 01:28:47 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6N0p-0005IG-5B
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:28:47 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 7c58fb31-70eb-11ec-9ce5-af14b9085ebd;
 Sun, 09 Jan 2022 02:28:45 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 910C2346;
 Sun,  9 Jan 2022 02:28:44 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 3G50eid9-Hwv; Sun,  9 Jan 2022 02:28:43 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 7235964;
 Sun,  9 Jan 2022 02:28:43 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6N0k-006iRq-QN;
 Sun, 09 Jan 2022 02:28:42 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7c58fb31-70eb-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:28:42 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 10/15] mini-os: eliminate netfront union member in struct
 file
Message-ID: <20220109012842.6zdw7z6jbh52kd7a@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-11-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20220106115741.3219-11-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 910C2346
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:36 +0100, a ecrit:
> Replace the netfront specific union member in struct file with the
> common dev pointer.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h | 3 ---
>  lib/sys.c     | 6 +++---
>  netfront.c    | 2 +-
>  3 files changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 5201ed7..f2a124e 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -193,9 +193,6 @@ struct file {
>  	    struct evtchn_port_list ports;
>  	} evtchn;
>  	struct gntmap gntmap;
> -	struct {
> -	    struct netfront_dev *dev;
> -	} tap;
>  #ifdef CONFIG_TPMFRONT
>  	struct {
>  	   struct tpmfront_dev *dev;
> diff --git a/lib/sys.c b/lib/sys.c
> index 8c7ea3c..b35e433 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -263,7 +263,7 @@ int read(int fd, void *buf, size_t nbytes)
>  #ifdef CONFIG_NETFRONT
>  	case FTYPE_TAP: {
>  	    ssize_t ret;
> -	    ret = netfront_receive(files[fd].tap.dev, buf, nbytes);
> +	    ret = netfront_receive(files[fd].dev, buf, nbytes);
>  	    if (ret <= 0) {
>  		errno = EAGAIN;
>  		return -1;
> @@ -339,7 +339,7 @@ int write(int fd, const void *buf, size_t nbytes)
>  #endif
>  #ifdef CONFIG_NETFRONT
>  	case FTYPE_TAP:
> -	    netfront_xmit(files[fd].tap.dev, (void*) buf, nbytes);
> +	    netfront_xmit(files[fd].dev, (void*) buf, nbytes);
>  	    return nbytes;
>  #endif
>  #ifdef CONFIG_BLKFRONT
> @@ -450,7 +450,7 @@ int close(int fd)
>  #endif
>  #ifdef CONFIG_NETFRONT
>  	case FTYPE_TAP:
> -	    shutdown_netfront(files[fd].tap.dev);
> +	    shutdown_netfront(files[fd].dev);
>  	    files[fd].type = FTYPE_NONE;
>  	    return 0;
>  #endif
> diff --git a/netfront.c b/netfront.c
> index a566e34..7696451 100644
> --- a/netfront.c
> +++ b/netfront.c
> @@ -576,7 +576,7 @@ int netfront_tap_open(char *nodename) {
>      }
>      dev->fd = alloc_fd(FTYPE_TAP);
>      printk("tap_open(%s) -> %d\n", nodename, dev->fd);
> -    files[dev->fd].tap.dev = dev;
> +    files[dev->fd].dev = dev;
>      return dev->fd;
>  }
>  #endif
> -- 
> 2.26.2
> 

-- 
Samuel
<c> tiens, je suis déçu
<c> quand on clique sur le bouton random de http://xkcd.com/221/ on ne tombe pas (toujours) sur http://xkcd.com/4/
<c> bon, j'envoie un bug-report à l'auteur


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:30:07 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:30:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255008.437016 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N26-0008Dc-Uf; Sun, 09 Jan 2022 01:30:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255008.437016; Sun, 09 Jan 2022 01:30:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N26-0008DW-RX; Sun, 09 Jan 2022 01:30:06 +0000
Received: by outflank-mailman (input) for mailman id 255008;
 Sun, 09 Jan 2022 01:30:05 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6N24-0007T5-S9
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:30:04 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id ab6f19c2-70eb-11ec-81c1-a30af7de8005;
 Sun, 09 Jan 2022 02:30:04 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 910F1346;
 Sun,  9 Jan 2022 02:30:03 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id DQj1Z03I4Q9A; Sun,  9 Jan 2022 02:30:03 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 8D423331;
 Sun,  9 Jan 2022 02:30:02 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6N21-006iSb-TU;
 Sun, 09 Jan 2022 02:30:01 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ab6f19c2-70eb-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:30:01 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 11/15] mini-os: move tpm respgot member of struct file to
 device specific data
Message-ID: <20220109013001.ba7i73tay366ipxg@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-12-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220106115741.3219-12-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 910F1346
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:37 +0100, a ecrit:
> Tpmfront has a "respgot" flag in struct file, which can be moved to the
> device specific data. While at it make it a bool.
> 
> The respgot flag of the tpm_tis member of struct file can be removed,
> as it is never read.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h      |  2 --
>  include/tpmfront.h |  2 ++
>  tpm_tis.c          |  2 --
>  tpmfront.c         | 10 +++++-----
>  4 files changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index f2a124e..d740065 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -196,13 +196,11 @@ struct file {
>  #ifdef CONFIG_TPMFRONT
>  	struct {
>  	   struct tpmfront_dev *dev;
> -	   int respgot;
>  	} tpmfront;
>  #endif
>  #ifdef CONFIG_TPM_TIS
>  	struct {
>  	   struct tpm_chip *dev;
> -	   int respgot;
>  	} tpm_tis;
>  #endif
>  #ifdef CONFIG_XENBUS
> diff --git a/include/tpmfront.h b/include/tpmfront.h
> index c489fae..b7da50e 100644
> --- a/include/tpmfront.h
> +++ b/include/tpmfront.h
> @@ -25,6 +25,7 @@
>  #ifndef TPMFRONT_H
>  #define TPMFRONT_H
>  
> +#include <stdbool.h>
>  #include <mini-os/types.h>
>  #include <mini-os/os.h>
>  #include <mini-os/events.h>
> @@ -53,6 +54,7 @@ struct tpmfront_dev {
>  
>  #ifdef HAVE_LIBC
>     int fd;
> +   bool respgot;
>  #endif
>  
>  };
> diff --git a/tpm_tis.c b/tpm_tis.c
> index 8a632b1..4127118 100644
> --- a/tpm_tis.c
> +++ b/tpm_tis.c
> @@ -846,7 +846,6 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
>  #ifdef HAVE_LIBC
>     if(tpm->fd >= 0) {
>        files[tpm->fd].read = false;
> -      files[tpm->fd].tpm_tis.respgot = 0;
>        files[tpm->fd].offset = 0;
>     }
>  #endif
> @@ -1290,7 +1289,6 @@ int tpm_tis_open(struct tpm_chip* tpm)
>     tpm->fd = alloc_fd(FTYPE_TPM_TIS);
>     printk("tpm_tis_open() -> %d\n", tpm->fd);
>     files[tpm->fd].tpm_tis.dev = tpm;
> -   files[tpm->fd].tpm_tis.respgot = 0;
>     return tpm->fd;
>  }
>  
> diff --git a/tpmfront.c b/tpmfront.c
> index 8b2a910..be671c2 100644
> --- a/tpmfront.c
> +++ b/tpmfront.c
> @@ -439,8 +439,8 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
>  #ifdef HAVE_LIBC
>     if(dev->fd >= 0) {
>        files[dev->fd].read = false;
> -      files[dev->fd].tpmfront.respgot = 0;
>        files[dev->fd].offset = 0;
> +      dev->respgot = false;
>     }
>  #endif
>     wmb();
> @@ -499,7 +499,7 @@ int i;
>  #endif
>  #ifdef HAVE_LIBC
>     if(dev->fd >= 0) {
> -      files[dev->fd].tpmfront.respgot = 1;
> +      dev->respgot = true;
>     }
>  #endif
>  quit:
> @@ -539,7 +539,7 @@ int tpmfront_open(struct tpmfront_dev* dev)
>     dev->fd = alloc_fd(FTYPE_TPMFRONT);
>     printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
>     files[dev->fd].tpmfront.dev = dev;
> -   files[dev->fd].tpmfront.respgot = 0;
> +   dev->respgot = false;
>     return dev->fd;
>  }
>  
> @@ -580,7 +580,7 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
>     }
>  
>     /* get the response if we haven't already */
> -   if(files[dev->fd].tpmfront.respgot == 0) {
> +   if (!dev->respgot) {
>        if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
>  	 errno = EIO;
>  	 return -1;
> @@ -610,7 +610,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
>  
>     /* If we have a response waiting, then read it now from the backend
>      * so we can get its length*/
> -   if(dev->waiting || (files[dev->fd].read && !files[dev->fd].tpmfront.respgot)) {
> +   if(dev->waiting || (files[dev->fd].read && !dev->respgot)) {
>        if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
>  	 errno = EIO;
>  	 return -1;
> -- 
> 2.26.2
> 

-- 
Samuel
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This email was infected under the terms of the GNU General Public License.


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:30:43 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:30:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255014.437031 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N2h-0000Ow-BQ; Sun, 09 Jan 2022 01:30:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255014.437031; Sun, 09 Jan 2022 01:30:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N2h-0000Or-85; Sun, 09 Jan 2022 01:30:43 +0000
Received: by outflank-mailman (input) for mailman id 255014;
 Sun, 09 Jan 2022 01:30:42 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6N2g-000094-JU
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:30:42 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id c1e083d3-70eb-11ec-9ce5-af14b9085ebd;
 Sun, 09 Jan 2022 02:30:41 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 3E5DD346;
 Sun,  9 Jan 2022 02:30:41 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id JPv3Ogv4G6aF; Sun,  9 Jan 2022 02:30:40 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id C59D064;
 Sun,  9 Jan 2022 02:30:40 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6N2e-006iTC-3h;
 Sun, 09 Jan 2022 02:30:40 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: c1e083d3-70eb-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:30:40 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 12/15] mini-os: eliminate tpmfront union member in struct
 file
Message-ID: <20220109013040.rhljjzid44opt2fn@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-13-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220106115741.3219-13-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 3E5DD346
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:38 +0100, a ecrit:
> Replace the tpmfront specific union member in struct file with the
> common dev pointer.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h | 5 -----
>  lib/sys.c     | 2 +-
>  tpmfront.c    | 8 ++++----
>  3 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index d740065..2ddc076 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -193,11 +193,6 @@ struct file {
>  	    struct evtchn_port_list ports;
>  	} evtchn;
>  	struct gntmap gntmap;
> -#ifdef CONFIG_TPMFRONT
> -	struct {
> -	   struct tpmfront_dev *dev;
> -	} tpmfront;
> -#endif
>  #ifdef CONFIG_TPM_TIS
>  	struct {
>  	   struct tpm_chip *dev;
> diff --git a/lib/sys.c b/lib/sys.c
> index b35e433..b042bf5 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -462,7 +462,7 @@ int close(int fd)
>  #endif
>  #ifdef CONFIG_TPMFRONT
>  	case FTYPE_TPMFRONT:
> -            shutdown_tpmfront(files[fd].tpmfront.dev);
> +            shutdown_tpmfront(files[fd].dev);
>  	    files[fd].type = FTYPE_NONE;
>  	    return 0;
>  #endif
> diff --git a/tpmfront.c b/tpmfront.c
> index be671c2..0a2fefc 100644
> --- a/tpmfront.c
> +++ b/tpmfront.c
> @@ -538,7 +538,7 @@ int tpmfront_open(struct tpmfront_dev* dev)
>  
>     dev->fd = alloc_fd(FTYPE_TPMFRONT);
>     printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
> -   files[dev->fd].tpmfront.dev = dev;
> +   files[dev->fd].dev = dev;
>     dev->respgot = false;
>     return dev->fd;
>  }
> @@ -547,7 +547,7 @@ int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count)
>  {
>     int rc;
>     struct tpmfront_dev* dev;
> -   dev = files[fd].tpmfront.dev;
> +   dev = files[fd].dev;
>  
>     if(count == 0) {
>        return 0;
> @@ -573,7 +573,7 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
>     size_t dummysz;
>     struct tpmfront_dev* dev;
>  
> -   dev = files[fd].tpmfront.dev;
> +   dev = files[fd].dev;
>  
>     if(count == 0) {
>        return 0;
> @@ -606,7 +606,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
>     uint8_t* dummybuf;
>     size_t dummysz;
>     int rc;
> -   struct tpmfront_dev* dev = files[fd].tpmfront.dev;
> +   struct tpmfront_dev* dev = files[fd].dev;
>  
>     /* If we have a response waiting, then read it now from the backend
>      * so we can get its length*/
> -- 
> 2.26.2
> 

-- 
Samuel
/* Halley */

	(Halley's comment.)


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:31:06 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:31:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255017.437046 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N34-00011T-Mz; Sun, 09 Jan 2022 01:31:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255017.437046; Sun, 09 Jan 2022 01:31:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N34-00011J-Io; Sun, 09 Jan 2022 01:31:06 +0000
Received: by outflank-mailman (input) for mailman id 255017;
 Sun, 09 Jan 2022 01:31:05 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6N33-0007T5-Mn
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:31:05 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id cfc4a04f-70eb-11ec-81c1-a30af7de8005;
 Sun, 09 Jan 2022 02:31:05 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 8F725346;
 Sun,  9 Jan 2022 02:31:04 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 2cH_o0_ByF5S; Sun,  9 Jan 2022 02:31:04 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id B03C564;
 Sun,  9 Jan 2022 02:31:03 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6N31-006iTg-8O;
 Sun, 09 Jan 2022 02:31:03 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: cfc4a04f-70eb-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:31:03 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 13/15] mini-os: eliminate tpmtis union member in struct
 file
Message-ID: <20220109013103.gapt7g7jw353c4md@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-14-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220106115741.3219-14-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 8F725346
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:39 +0100, a ecrit:
> Replace the tpmtis specific union member in struct file with the
> common dev pointer.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h | 5 -----
>  lib/sys.c     | 2 +-
>  tpm_tis.c     | 8 ++++----
>  3 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 2ddc076..d6a29ba 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -193,11 +193,6 @@ struct file {
>  	    struct evtchn_port_list ports;
>  	} evtchn;
>  	struct gntmap gntmap;
> -#ifdef CONFIG_TPM_TIS
> -	struct {
> -	   struct tpm_chip *dev;
> -	} tpm_tis;
> -#endif
>  #ifdef CONFIG_XENBUS
>          struct {
>              /* To each xenbus FD is associated a queue of watch events for this
> diff --git a/lib/sys.c b/lib/sys.c
> index b042bf5..96fc769 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -468,7 +468,7 @@ int close(int fd)
>  #endif
>  #ifdef CONFIG_TPM_TIS
>  	case FTYPE_TPM_TIS:
> -            shutdown_tpm_tis(files[fd].tpm_tis.dev);
> +            shutdown_tpm_tis(files[fd].dev);
>  	    files[fd].type = FTYPE_NONE;
>  	    return 0;
>  #endif
> diff --git a/tpm_tis.c b/tpm_tis.c
> index 4127118..477f555 100644
> --- a/tpm_tis.c
> +++ b/tpm_tis.c
> @@ -1288,14 +1288,14 @@ int tpm_tis_open(struct tpm_chip* tpm)
>  
>     tpm->fd = alloc_fd(FTYPE_TPM_TIS);
>     printk("tpm_tis_open() -> %d\n", tpm->fd);
> -   files[tpm->fd].tpm_tis.dev = tpm;
> +   files[tpm->fd].dev = tpm;
>     return tpm->fd;
>  }
>  
>  int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count)
>  {
>     struct tpm_chip* tpm;
> -   tpm = files[fd].tpm_tis.dev;
> +   tpm = files[fd].dev;
>  
>     if(tpm->locality < 0) {
>        printk("tpm_tis_posix_write() failed! locality not set!\n");
> @@ -1323,7 +1323,7 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
>  {
>     int rc;
>     struct tpm_chip* tpm;
> -   tpm = files[fd].tpm_tis.dev;
> +   tpm = files[fd].dev;
>  
>     if(count == 0) {
>        return 0;
> @@ -1350,7 +1350,7 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
>  int tpm_tis_posix_fstat(int fd, struct stat* buf)
>  {
>     struct tpm_chip* tpm;
> -   tpm = files[fd].tpm_tis.dev;
> +   tpm = files[fd].dev;
>  
>     buf->st_mode = O_RDWR;
>     buf->st_uid = 0;
> -- 
> 2.26.2
> 

-- 
Samuel
<r> make
<r> oops
<m> make clean


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:32:30 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:32:30 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255025.437063 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N4P-0001nK-4m; Sun, 09 Jan 2022 01:32:29 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255025.437063; Sun, 09 Jan 2022 01:32:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N4P-0001nC-0n; Sun, 09 Jan 2022 01:32:29 +0000
Received: by outflank-mailman (input) for mailman id 255025;
 Sun, 09 Jan 2022 01:32:27 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6N4N-0001mv-Sw
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:32:27 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 009b7c19-70ec-11ec-81c1-a30af7de8005;
 Sun, 09 Jan 2022 02:32:26 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 391E4368;
 Sun,  9 Jan 2022 02:32:26 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id w3vO7bERRuhm; Sun,  9 Jan 2022 02:32:25 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 538DA283;
 Sun,  9 Jan 2022 02:32:25 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6N4K-006iUf-LB;
 Sun, 09 Jan 2022 02:32:24 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 009b7c19-70ec-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:32:24 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 14/15] mini-os: eliminate xenbus union member in struct
 file
Message-ID: <20220109013224.c4nv77dayhlg3z5o@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-15-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220106115741.3219-15-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 391E4368
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:40 +0100, a ecrit:
> Replace the xenbus specific union member in struct file with the
> common dev pointer.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h |  7 -------
>  lib/sys.c     |  2 +-
>  lib/xs.c      | 13 +++++++------
>  3 files changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index d6a29ba..91364ba 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -193,13 +193,6 @@ struct file {
>  	    struct evtchn_port_list ports;
>  	} evtchn;
>  	struct gntmap gntmap;
> -#ifdef CONFIG_XENBUS
> -        struct {
> -            /* To each xenbus FD is associated a queue of watch events for this
> -             * FD.  */
> -            xenbus_event_queue events;
> -        } xenbus;
> -#endif
>      };
>  };
>  
> diff --git a/lib/sys.c b/lib/sys.c
> index 96fc769..6f2b026 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -776,7 +776,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  #ifdef CONFIG_XENBUS
>  	case FTYPE_XENBUS:
>  	    if (FD_ISSET(i, readfds)) {
> -                if (files[i].xenbus.events)
> +                if (files[i].dev)
>  		    n++;
>  		else
>  		    FD_CLR(i, readfds);
> diff --git a/lib/xs.c b/lib/xs.c
> index 324bd05..0459f52 100644
> --- a/lib/xs.c
> +++ b/lib/xs.c
> @@ -21,8 +21,8 @@ static inline int _xs_fileno(struct xs_handle *h) {
>  struct xs_handle *xs_daemon_open()
>  {
>      int fd = alloc_fd(FTYPE_XENBUS);
> -    files[fd].xenbus.events = NULL;
> -    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].xenbus.events);
> +    files[fd].dev = NULL;
> +    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].dev);
>      return (void*)(intptr_t) fd;
>  }
>  
> @@ -30,7 +30,7 @@ void xs_daemon_close(struct xs_handle *h)
>  {
>      int fd = _xs_fileno(h);
>      struct xenbus_event *event, *next;
> -    for (event = files[fd].xenbus.events; event; event = next)
> +    for (event = files[fd].dev; event; event = next)
>      {
>          next = event->next;
>          free(event);
> @@ -172,15 +172,16 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)
>  {
>      int fd = _xs_fileno(h);
>      printk("xs_watch(%s, %s)\n", path, token);
> -    return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token, &files[fd].xenbus.events));
> +    return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token,
> +                   (xenbus_event_queue *)&files[fd].dev));
>  }
>  
>  char **xs_read_watch(struct xs_handle *h, unsigned int *num)
>  {
>      int fd = _xs_fileno(h);
>      struct xenbus_event *event;
> -    event = files[fd].xenbus.events;
> -    files[fd].xenbus.events = event->next;
> +    event = files[fd].dev;
> +    files[fd].dev = event->next;
>      printk("xs_read_watch() -> %s %s\n", event->path, event->token);
>      *num = 2;
>      return (char **) &event->path;
> -- 
> 2.26.2
> 

-- 
Samuel
"I don't know why, but first C programs tend to look a lot worse than
first programs in any other language (maybe except for fortran, but then
I suspect all fortran programs look like `firsts')"
(By Olaf Kirch)


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 01:33:44 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 01:33:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255032.437083 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N5b-0002TX-U9; Sun, 09 Jan 2022 01:33:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255032.437083; Sun, 09 Jan 2022 01:33:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6N5b-0002TE-MX; Sun, 09 Jan 2022 01:33:43 +0000
Received: by outflank-mailman (input) for mailman id 255032;
 Sun, 09 Jan 2022 01:33:43 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6N5a-0002Qy-WD
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 01:33:43 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 2ced7483-70ec-11ec-9ce5-af14b9085ebd;
 Sun, 09 Jan 2022 02:33:41 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id D1330368;
 Sun,  9 Jan 2022 02:33:40 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id HGccZaLAxH5G; Sun,  9 Jan 2022 02:33:40 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 07374283;
 Sun,  9 Jan 2022 02:33:40 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6N5X-006iV8-BD;
 Sun, 09 Jan 2022 02:33:39 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 2ced7483-70ec-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 02:33:39 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 15/15] mini-os: introduce get_file_from_fd()
Message-ID: <20220109013339.bilc3u2xc3t72irf@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-16-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220106115741.3219-16-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: D1330368
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le jeu. 06 janv. 2022 12:57:41 +0100, a ecrit:
> Exporting the files[] array especially for components outside the
> mini-os source tree is limiting the ability to change any file handling
> in mini-os.
> 
> Introduce a new function get_file_from_fd() to return the struct file
> pointer (or NULL) for a given file descriptor.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h | 1 +
>  lib/sys.c     | 8 ++++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 91364ba..7a0546b 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -198,6 +198,7 @@ struct file {
>  
>  extern struct file files[];
>  
> +struct file *get_file_from_fd(int fd);
>  int alloc_fd(enum fd_type type);
>  void close_all_files(void);
>  extern struct thread *main_thread;
> diff --git a/lib/sys.c b/lib/sys.c
> index 6f2b026..0e6fe5d 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -98,6 +98,14 @@ struct file files[NOFILE] = {
>      { .type = FTYPE_CONSOLE }, /* stderr */
>  };
>  
> +struct file *get_file_from_fd(int fd)
> +{
> +    if ( fd < 0 || fd >= NOFILE )
> +        return NULL;
> +
> +    return (files[fd].type == FTYPE_NONE) ? NULL : files + fd;
> +}
> +
>  DECLARE_WAIT_QUEUE_HEAD(event_queue);
>  
>  int alloc_fd(enum fd_type type)
> -- 
> 2.26.2
> 

-- 
Samuel
The nice thing about Windows is - It does not just crash, it displays a
dialog box and lets you press 'OK' first.
(Arno Schaefer's .sig)


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 06:12:44 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 06:12:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255060.437119 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6RRX-0004sl-C0; Sun, 09 Jan 2022 06:12:39 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255060.437119; Sun, 09 Jan 2022 06:12:39 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6RRX-0004ru-6i; Sun, 09 Jan 2022 06:12:39 +0000
Received: by outflank-mailman (input) for mailman id 255060;
 Sun, 09 Jan 2022 06:12:37 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=uXRL=RZ=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n6RRV-0004pc-Ny
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 06:12:37 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 224ccd7d-7113-11ec-81c1-a30af7de8005;
 Sun, 09 Jan 2022 07:12:33 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id A57DB210F5;
 Sun,  9 Jan 2022 06:12:33 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 827FA1323E;
 Sun,  9 Jan 2022 06:12:33 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id w6x5HtF82mHCAgAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 09 Jan 2022 06:12:33 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 224ccd7d-7113-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641708753; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=2NEZWzPh5lRyG3jS2xnF4imOt3KxOxtziXli0WcVzAQ=;
	b=YANISiT/wi2/S9CofJGi+QX/rRiATlxD3+jnRoGpbTiy1OLYrXdTcUWw2h8YkIE7lzdZ8e
	fJwiZk8gQEmInbJwOHXQw1MkQlCm2QjTT/MdhayLUOoRzZafad7u9r12nCiv8GMY8fiUfz
	6DPUsBbPn2HkWp/dx1Bf05xA9aS3b6w=
Subject: Re: [PATCH 02/15] mini-os: makes file.read bool and move it ahead of
 device specific part
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-3-jgross@suse.com>
 <20220109011844.ztd7uwre6kb3dzwv@begin>
 <20220109012100.tpv42y3efylqgrhr@begin>
From: Juergen Gross <jgross@suse.com>
Message-ID: <4b989643-9a9f-7bba-d729-d3248db49499@suse.com>
Date: Sun, 9 Jan 2022 07:12:32 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <20220109012100.tpv42y3efylqgrhr@begin>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="8DA3GSwe4AyWz92cpZ4rQCYNdfNu2Hbm3"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--8DA3GSwe4AyWz92cpZ4rQCYNdfNu2Hbm3
Content-Type: multipart/mixed; boundary="Z602Mw8QTB5loTPygdsDUDC35Z5JxK0fW";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org
Message-ID: <4b989643-9a9f-7bba-d729-d3248db49499@suse.com>
Subject: Re: [PATCH 02/15] mini-os: makes file.read bool and move it ahead of
 device specific part
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-3-jgross@suse.com>
 <20220109011844.ztd7uwre6kb3dzwv@begin>
 <20220109012100.tpv42y3efylqgrhr@begin>
In-Reply-To: <20220109012100.tpv42y3efylqgrhr@begin>

--Z602Mw8QTB5loTPygdsDUDC35Z5JxK0fW
Content-Type: multipart/mixed;
 boundary="------------A8BC179E04DBA680FFE9E233"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------A8BC179E04DBA680FFE9E233
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 09.01.22 02:21, Samuel Thibault wrote:
> Samuel Thibault, le dim. 09 janv. 2022 02:18:44 +0100, a ecrit:
>> Juergen Gross, le jeu. 06 janv. 2022 12:57:28 +0100, a ecrit:
>>> The read member of struct file should be bool.
>>>
>>> In order to have the device specific part at the end of the structure=

>>> move "read" ahead of that.
>>>
>>> Signed-off-by: Juergen Gross <jgross@suse.com>
>>
>> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
>=20
> Mmm, but tools/libs/evtchn/minios.c needs updating, doesn't it?

It will be, but assigning 1 to a bool is just fine.


Juergen

--------------A8BC179E04DBA680FFE9E233
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------A8BC179E04DBA680FFE9E233--

--Z602Mw8QTB5loTPygdsDUDC35Z5JxK0fW--

--8DA3GSwe4AyWz92cpZ4rQCYNdfNu2Hbm3
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHafNAFAwAAAAAACgkQsN6d1ii/Ey8A
4Qf/ahmMqH+bFa9eRLYPf5dFGBg+ZXPcUIuQTgPFgJ0TcndIyaqLWoXvk6VS7jFk0Vme1a8j2RYM
/X8JwuusFTRp3pIm2vaml06SkTIJiFVAP1M9AV7+XyzKqPsK/c6dtPS368hc1a8VwuC5SBuRxYKl
hw41ikhNM4eGUs9zgIkk8bsoCYTVorpXZwWERwwJdsJh8d/+ENv1LIQPo0nFHuOOa+sCj/p9A2cq
zefD8dvrT0VdXB8xH2CETk4ZAAQRCoRIJfDdAdWWJKGfg0EaFQJGdRSULSRt6s0Ev2P8X3Op7RpP
IHSqtMryqgo/QQAo8ajH2M2f/kwXteBXGXmWS30ylg==
=pWYc
-----END PGP SIGNATURE-----

--8DA3GSwe4AyWz92cpZ4rQCYNdfNu2Hbm3--


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 06:17:25 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 06:17:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255065.437128 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6RW8-0005Y0-MP; Sun, 09 Jan 2022 06:17:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255065.437128; Sun, 09 Jan 2022 06:17:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6RW8-0005Xt-JY; Sun, 09 Jan 2022 06:17:24 +0000
Received: by outflank-mailman (input) for mailman id 255065;
 Sun, 09 Jan 2022 06:17:23 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=uXRL=RZ=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n6RW7-0005Xi-AP
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 06:17:23 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id cdc8962a-7113-11ec-9ce5-af14b9085ebd;
 Sun, 09 Jan 2022 07:17:21 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 1F9E31F382;
 Sun,  9 Jan 2022 06:17:21 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E361E1323E;
 Sun,  9 Jan 2022 06:17:20 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id BjjTNfB92mH4AwAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 09 Jan 2022 06:17:20 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: cdc8962a-7113-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641709041; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=JQvgevWvobT9sZOfI/2lM7ceVgGrP0PQ53Ah8wWQ+Gs=;
	b=HEh4J70Kh2sX7Qtc9b1Ao0xx/JE3PzelXsoI8fAZ6o0QV+cr0Br0pQYOuTk2mYnZc3rdbi
	SY1YjropN2pnWhO7Bo/y3KXPbDQBz/kJ4EwDjNn7G8a9hJL+Ai83xpIwb0vzd9ImSbrlRn
	B0Xsx2L03lN8yD13yJjYq0bLfezuh0g=
Subject: Re: [PATCH 0/2] mini-os: remove device specific struct file members
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org
References: <20220107104706.9859-1-jgross@suse.com>
 <20220109011603.bymferaebanvvmud@begin>
From: Juergen Gross <jgross@suse.com>
Message-ID: <b1341eb8-cd80-db17-d69c-ed0781a8ea74@suse.com>
Date: Sun, 9 Jan 2022 07:17:20 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <20220109011603.bymferaebanvvmud@begin>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="EorJ2WnWwLhDno7OhVFNeyKsTYJRBykzc"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--EorJ2WnWwLhDno7OhVFNeyKsTYJRBykzc
Content-Type: multipart/mixed; boundary="Psy6U8Xi5KhEHr6AJK7WJkxElTf8Q9ZeN";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org
Message-ID: <b1341eb8-cd80-db17-d69c-ed0781a8ea74@suse.com>
Subject: Re: [PATCH 0/2] mini-os: remove device specific struct file members
References: <20220107104706.9859-1-jgross@suse.com>
 <20220109011603.bymferaebanvvmud@begin>
In-Reply-To: <20220109011603.bymferaebanvvmud@begin>

--Psy6U8Xi5KhEHr6AJK7WJkxElTf8Q9ZeN
Content-Type: multipart/mixed;
 boundary="------------82B1C12707A7F8D2FE966FE2"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------82B1C12707A7F8D2FE966FE2
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 09.01.22 02:16, Samuel Thibault wrote:
> Juergen Gross, le ven. 07 janv. 2022 11:47:04 +0100, a ecrit:
>> can only be applied after the Xen libraries have stopped using the
>> related union members.
>=20
> Ah, ok :) Was that submitted somewhere?

I've sent the patches, but they can be applied only after the first
Mini-OS series has been applied and the Xen build is using the
updated Mini-OS tree.

Meanwhile I've found a way to decouple Mini-OS and the Xen libs even
further. So this series and the Xen one will be updated.

In the end the libs will use dynamic hooks and Mini-OS will no longer
need to have a config knob for supporting the libs (other than having
libc enabled).


Juergen

--------------82B1C12707A7F8D2FE966FE2
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------82B1C12707A7F8D2FE966FE2--

--Psy6U8Xi5KhEHr6AJK7WJkxElTf8Q9ZeN--

--EorJ2WnWwLhDno7OhVFNeyKsTYJRBykzc
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHaffAFAwAAAAAACgkQsN6d1ii/Ey84
Pgf/e6yKopYElSi/OHj5OhdNshjGSD2f97ea4yjdyPKtvi4kv+xLxB1s59vVJbhStMkDXCi1zpW/
Toa1wPFtEKlpIcMjI/0Qvop8RNRdhPQbsI+bMUCvlj91cs25oU+fgwdakDHzFvIH1aVWLaARDpad
chv3eTL4lJiIh9mrswopQ0JTh7I3nQV86JCLQMqHUBZhHBcdU/Wk+3FYtN4dW0e7voxlDkxfI26E
s2IPt38sf7qOlCc5U/rhg2TV5robDN4fhm8bhmkXdHYIihah1w6SUD0RBB/89/OmQHK4w12zeak2
sVG4bsotPH0ob6eCbx0IP0caljfym4Q5v5/Wy6BpjA==
=tQu8
-----END PGP SIGNATURE-----

--EorJ2WnWwLhDno7OhVFNeyKsTYJRBykzc--


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 06:18:15 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 06:18:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255070.437144 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6RWx-0006FB-5N; Sun, 09 Jan 2022 06:18:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255070.437144; Sun, 09 Jan 2022 06:18:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6RWx-0006F4-20; Sun, 09 Jan 2022 06:18:15 +0000
Received: by outflank-mailman (input) for mailman id 255070;
 Sun, 09 Jan 2022 06:18:14 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=uXRL=RZ=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n6RWw-0006Es-3a
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 06:18:14 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id ec6acd21-7113-11ec-81c1-a30af7de8005;
 Sun, 09 Jan 2022 07:18:12 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id AD050210F5;
 Sun,  9 Jan 2022 06:18:12 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 877F41323E;
 Sun,  9 Jan 2022 06:18:12 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 2nauHyR+2mExBAAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 09 Jan 2022 06:18:12 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ec6acd21-7113-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641709092; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=wMqyVMz5DLJ/dsfqXM7of5hL28ZIUcfqqjLAZZsN2BQ=;
	b=JjEA5lq+BP8oR9lCMe2xHeixGkKlEZmJyHdJ4/mYhU4YdBF4s8cmX5ZYKB4F99HMZwDDcs
	1ZdiP2tS8udmtk9RCxqcHprRZ1kgPsSEBgJ/TdYVsc+1XADkXCIztQ6UgimB499RDW8gTV
	968wv2e2dUosH/q3JKxXGTefGoE/kvA=
Subject: Re: [PATCH 1/2] mini-os: remove event channel specific struct file
 member
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org
References: <20220107104706.9859-1-jgross@suse.com>
 <20220107104706.9859-2-jgross@suse.com>
 <20220109011515.sx2qynqslxhllred@begin>
From: Juergen Gross <jgross@suse.com>
Message-ID: <f7bca511-3fa7-cbc6-5a10-5b6edb7a8bd1@suse.com>
Date: Sun, 9 Jan 2022 07:18:12 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <20220109011515.sx2qynqslxhllred@begin>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="DmKJmeQPuzGX4YVULogHvEG45qroerTks"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--DmKJmeQPuzGX4YVULogHvEG45qroerTks
Content-Type: multipart/mixed; boundary="aqzsLJLSYlM4nmru4NfrACfzwZxiXIvex";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org
Message-ID: <f7bca511-3fa7-cbc6-5a10-5b6edb7a8bd1@suse.com>
Subject: Re: [PATCH 1/2] mini-os: remove event channel specific struct file
 member
References: <20220107104706.9859-1-jgross@suse.com>
 <20220107104706.9859-2-jgross@suse.com>
 <20220109011515.sx2qynqslxhllred@begin>
In-Reply-To: <20220109011515.sx2qynqslxhllred@begin>

--aqzsLJLSYlM4nmru4NfrACfzwZxiXIvex
Content-Type: multipart/mixed;
 boundary="------------D1CCBDDA8EF4517C57A65864"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------D1CCBDDA8EF4517C57A65864
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 09.01.22 02:15, Samuel Thibault wrote:
> Juergen Gross, le ven. 07 janv. 2022 11:47:05 +0100, a ecrit:
>> The event channel specific union member in struct file is no longer
>> needed,
>=20
> Doesn't xen/tools/libs/evtchn/minios.c use it?

Not after the Xen patches have been applied.


Juergen

--------------D1CCBDDA8EF4517C57A65864
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------D1CCBDDA8EF4517C57A65864--

--aqzsLJLSYlM4nmru4NfrACfzwZxiXIvex--

--DmKJmeQPuzGX4YVULogHvEG45qroerTks
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHafiQFAwAAAAAACgkQsN6d1ii/Ey8K
9Qf/UC/85CU3A/FVDzqiv3yd1YA6MihUg6BpTJUBRn5e/4J+mWKFE4ygonenw74okL3ZYZOMCR5B
wkxjh+4oPpKwQG6UxunrpYyFE7Bl+XFWE8OODuA/h/qdKCee/OnirVCmXmSaU0M19iAudsMSAEb4
nigoTi2ZiY/QusvCACHHZuOSuL5dyL5qOOZc6DCi1p3euuUhZRck1l8X43DpyEKS3x1LrGwAWYr+
yIrRR2cyBZMSnVF6gVq8rLezCmUuvNi9by0+R5yCNBMuLKUJJqJtvVKg7oM+123vvH/L8T4e0DEP
hTTkD+wHcnRRwO1qs3nEUxCGk05XnzGgFvGVuGXC+w==
=jIyN
-----END PGP SIGNATURE-----

--DmKJmeQPuzGX4YVULogHvEG45qroerTks--


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 10:20:47 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 10:20:47 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255113.437203 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6VJb-0006Ka-4p; Sun, 09 Jan 2022 10:20:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255113.437203; Sun, 09 Jan 2022 10:20:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6VJb-0006KS-1E; Sun, 09 Jan 2022 10:20:43 +0000
Received: by outflank-mailman (input) for mailman id 255113;
 Sun, 09 Jan 2022 10:20:41 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6VJZ-00064j-EU
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 10:20:41 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ca41a26d-7135-11ec-9ce5-af14b9085ebd;
 Sun, 09 Jan 2022 11:20:38 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 752C217D;
 Sun,  9 Jan 2022 11:20:37 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id nJSn2jWH_SWF; Sun,  9 Jan 2022 11:20:36 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 13A5A174;
 Sun,  9 Jan 2022 11:20:36 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6VJT-005iAR-1F;
 Sun, 09 Jan 2022 11:20:35 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ca41a26d-7135-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 11:20:35 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 02/15] mini-os: makes file.read bool and move it ahead of
 device specific part
Message-ID: <20220109102035.36bhefgq3y2xhdto@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-3-jgross@suse.com>
 <20220109011844.ztd7uwre6kb3dzwv@begin>
 <20220109012100.tpv42y3efylqgrhr@begin>
 <4b989643-9a9f-7bba-d729-d3248db49499@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4b989643-9a9f-7bba-d729-d3248db49499@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 752C217D
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 09 janv. 2022 07:12:32 +0100, a ecrit:
> On 09.01.22 02:21, Samuel Thibault wrote:
> > Samuel Thibault, le dim. 09 janv. 2022 02:18:44 +0100, a ecrit:
> > > Juergen Gross, le jeu. 06 janv. 2022 12:57:28 +0100, a ecrit:
> > > > The read member of struct file should be bool.
> > > > 
> > > > In order to have the device specific part at the end of the structure
> > > > move "read" ahead of that.
> > > > 
> > > > Signed-off-by: Juergen Gross <jgross@suse.com>
> > > 
> > > Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > 
> > Mmm, but tools/libs/evtchn/minios.c needs updating, doesn't it?
> 
> It will be, but assigning 1 to a bool is just fine.

Yes but it's moved in the structure.

Samuel


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 10:29:03 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 10:29:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255118.437207 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6VRe-0006rK-Pd; Sun, 09 Jan 2022 10:29:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255118.437207; Sun, 09 Jan 2022 10:29:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6VRe-0006rD-Mb; Sun, 09 Jan 2022 10:29:02 +0000
Received: by outflank-mailman (input) for mailman id 255118;
 Sun, 09 Jan 2022 10:29:00 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=uXRL=RZ=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n6VRc-0006pb-UM
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 10:29:00 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id f52cacd0-7136-11ec-81c1-a30af7de8005;
 Sun, 09 Jan 2022 11:29:00 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 84FD421109;
 Sun,  9 Jan 2022 10:28:59 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5C4ED1342A;
 Sun,  9 Jan 2022 10:28:59 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id b3zIFOu42mHSPQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 09 Jan 2022 10:28:59 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: f52cacd0-7136-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641724139; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=J3VgMteoioKXsiP19aWt+aBAbb1/ZOOWK4ny/y/hNBw=;
	b=ssKLJgQfs5YEZAznsI8L3IoaIC1DEV7XmOE82Gv9Zp/pcIvgWGK3IuZQPVFrjq6RzGT44r
	fqIc2y/77kCbGezcdvznh2Mihu5H7QhQRRFMgfmmVlqL01sKPgVNKguhr+ad3uWclIfbkG
	rJuFBhqRSZ64jFt86YUnEhvMfko5X7M=
Subject: Re: [PATCH 02/15] mini-os: makes file.read bool and move it ahead of
 device specific part
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-3-jgross@suse.com>
 <20220109011844.ztd7uwre6kb3dzwv@begin>
 <20220109012100.tpv42y3efylqgrhr@begin>
 <4b989643-9a9f-7bba-d729-d3248db49499@suse.com>
 <20220109102035.36bhefgq3y2xhdto@begin>
From: Juergen Gross <jgross@suse.com>
Message-ID: <f5c0fb67-fefe-ac64-84a6-a8013ba0c041@suse.com>
Date: Sun, 9 Jan 2022 11:28:58 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <20220109102035.36bhefgq3y2xhdto@begin>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="ZV1lwR9v6xLvym9tYPIr0pqWWHtUFNgIK"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--ZV1lwR9v6xLvym9tYPIr0pqWWHtUFNgIK
Content-Type: multipart/mixed; boundary="NMlOVhwKyQwqbuhjGJGgwAA1xuayIQkDb";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org
Message-ID: <f5c0fb67-fefe-ac64-84a6-a8013ba0c041@suse.com>
Subject: Re: [PATCH 02/15] mini-os: makes file.read bool and move it ahead of
 device specific part
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-3-jgross@suse.com>
 <20220109011844.ztd7uwre6kb3dzwv@begin>
 <20220109012100.tpv42y3efylqgrhr@begin>
 <4b989643-9a9f-7bba-d729-d3248db49499@suse.com>
 <20220109102035.36bhefgq3y2xhdto@begin>
In-Reply-To: <20220109102035.36bhefgq3y2xhdto@begin>

--NMlOVhwKyQwqbuhjGJGgwAA1xuayIQkDb
Content-Type: multipart/mixed;
 boundary="------------A3D3AC09BDEDFC19C696E33F"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------A3D3AC09BDEDFC19C696E33F
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 09.01.22 11:20, Samuel Thibault wrote:
> Juergen Gross, le dim. 09 janv. 2022 07:12:32 +0100, a ecrit:
>> On 09.01.22 02:21, Samuel Thibault wrote:
>>> Samuel Thibault, le dim. 09 janv. 2022 02:18:44 +0100, a ecrit:
>>>> Juergen Gross, le jeu. 06 janv. 2022 12:57:28 +0100, a ecrit:
>>>>> The read member of struct file should be bool.
>>>>>
>>>>> In order to have the device specific part at the end of the structu=
re
>>>>> move "read" ahead of that.
>>>>>
>>>>> Signed-off-by: Juergen Gross <jgross@suse.com>
>>>>
>>>> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
>>>
>>> Mmm, but tools/libs/evtchn/minios.c needs updating, doesn't it?
>>
>> It will be, but assigning 1 to a bool is just fine.
>=20
> Yes but it's moved in the structure.

It needs recompiling, but no change. Its still file->read.


Juergen

--------------A3D3AC09BDEDFC19C696E33F
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------A3D3AC09BDEDFC19C696E33F--

--NMlOVhwKyQwqbuhjGJGgwAA1xuayIQkDb--

--ZV1lwR9v6xLvym9tYPIr0pqWWHtUFNgIK
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHauOoFAwAAAAAACgkQsN6d1ii/Ey/w
Ugf/Vzs55gFZiekuJN4uTx+SEB0SeBlCZrjZOp/7ub+gwjpDmP1ZbsYgSzpwnkZmCbXH0hlUm/rk
mKGHR+SQjpUbRyNkhca9+mTdNlkKHF8xK06ahruVDKeXeg7D7y8f0uwAdQ9DbphehxAbxcekLW2R
fIuX2UHhhCKEks7mmO8s9MwmZfCiUlwPdiOhCqgTI77irGlZISOiHdGuplNZKv/OuLLooDGHyT3Q
lhPmR5d4NvIIRwmWoVFCSX1ijtOG1QMbibTIh7PQE2ALa6HXWPsb4onjtzci73pMH+HfHKD4cczW
oAXTkJilHTjj0lJE8j/m0x4+OA8XDFL0PZ54d1XDew==
=BYwv
-----END PGP SIGNATURE-----

--ZV1lwR9v6xLvym9tYPIr0pqWWHtUFNgIK--


From minios-devel-bounces@lists.xenproject.org Sun Jan 09 10:33:48 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 09 Jan 2022 10:33:48 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255125.437226 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6VWF-0008Kr-Lu; Sun, 09 Jan 2022 10:33:47 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255125.437226; Sun, 09 Jan 2022 10:33:47 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6VWF-0008KP-IJ; Sun, 09 Jan 2022 10:33:47 +0000
Received: by outflank-mailman (input) for mailman id 255125;
 Sun, 09 Jan 2022 10:33:46 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4WZq=RZ=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6VWE-0008IQ-Pv
 for minios-devel@lists.xenproject.org; Sun, 09 Jan 2022 10:33:46 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 9e90a409-7137-11ec-9ce5-af14b9085ebd;
 Sun, 09 Jan 2022 11:33:44 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 6C2F317D;
 Sun,  9 Jan 2022 11:33:43 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id XXzIjj3Tt45f; Sun,  9 Jan 2022 11:33:42 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 6A9A5174;
 Sun,  9 Jan 2022 11:33:42 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6VW9-006FSd-Gi;
 Sun, 09 Jan 2022 11:33:41 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 9e90a409-7137-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 9 Jan 2022 11:33:41 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH 02/15] mini-os: makes file.read bool and move it ahead of
 device specific part
Message-ID: <20220109103341.nmjyrkg2tiz3g4j2@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220106115741.3219-1-jgross@suse.com>
 <20220106115741.3219-3-jgross@suse.com>
 <20220109011844.ztd7uwre6kb3dzwv@begin>
 <20220109012100.tpv42y3efylqgrhr@begin>
 <4b989643-9a9f-7bba-d729-d3248db49499@suse.com>
 <20220109102035.36bhefgq3y2xhdto@begin>
 <f5c0fb67-fefe-ac64-84a6-a8013ba0c041@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <f5c0fb67-fefe-ac64-84a6-a8013ba0c041@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 6C2F317D
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 09 janv. 2022 11:28:58 +0100, a ecrit:
> On 09.01.22 11:20, Samuel Thibault wrote:
> > Juergen Gross, le dim. 09 janv. 2022 07:12:32 +0100, a ecrit:
> > > On 09.01.22 02:21, Samuel Thibault wrote:
> > > > Samuel Thibault, le dim. 09 janv. 2022 02:18:44 +0100, a ecrit:
> > > > > Juergen Gross, le jeu. 06 janv. 2022 12:57:28 +0100, a ecrit:
> > > > > > The read member of struct file should be bool.
> > > > > > 
> > > > > > In order to have the device specific part at the end of the structure
> > > > > > move "read" ahead of that.
> > > > > > 
> > > > > > Signed-off-by: Juergen Gross <jgross@suse.com>
> > > > > 
> > > > > Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > > > 
> > > > Mmm, but tools/libs/evtchn/minios.c needs updating, doesn't it?
> > > 
> > > It will be, but assigning 1 to a bool is just fine.
> > 
> > Yes but it's moved in the structure.
> 
> It needs recompiling, but no change. Its still file->read.

Ah, right, I was thinking about other fields such as gntmap,
evtchn.ports which will need updating.

Samuel


From minios-devel-bounces@lists.xenproject.org Mon Jan 10 11:41:59 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 10 Jan 2022 11:41:59 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255304.437457 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6t3j-0001aQ-8F; Mon, 10 Jan 2022 11:41:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255304.437457; Mon, 10 Jan 2022 11:41:55 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n6t3j-0001aJ-5B; Mon, 10 Jan 2022 11:41:55 +0000
Received: by outflank-mailman (input) for mailman id 255304;
 Mon, 10 Jan 2022 11:41:54 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=HJuU=R2=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n6t3i-0001Zs-48
 for minios-devel@lists.xenproject.org; Mon, 10 Jan 2022 11:41:54 +0000
Received: from mail3-relais-sop.national.inria.fr
 (mail3-relais-sop.national.inria.fr [192.134.164.104])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 3f34282e-720a-11ec-9ce5-af14b9085ebd;
 Mon, 10 Jan 2022 12:41:29 +0100 (CET)
Received: from nat-inria-interne-52-gw-01-bso.bordeaux.inria.fr (HELO begin)
 ([194.199.1.52])
 by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 10 Jan 2022 12:41:27 +0100
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n6t3G-00BIjn-Eo;
 Mon, 10 Jan 2022 12:41:26 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 3f34282e-720a-11ec-9ce5-af14b9085ebd
IronPort-Data: =?us-ascii?q?A9a23=3A2uCFRqvZWTTDfXocWzxRkc6OQefnVMFcMUV32f8?=
 =?us-ascii?q?akzHdYEJGY0x3mGRLCGCPMv+JN2Kgc9FyPN7l8k0CuZHXzNZgG1ds+HtgHilAw?=
 =?us-ascii?q?SbnLYTAfx2oZ0t+DeWaERk5t51GAjX4wXFdokb0/n9BCZC86yksvU20buCkUrS?=
 =?us-ascii?q?cY3kpHVYMpBoJ0nqPpcZo2+aEvvDpW2thifuqyyHuEAfNNwxcagr42IrfwP9bh?=
 =?us-ascii?q?8kejRtD1rAIiV+ni3eF/5UdJMp3yahctBIUSKEMdgKxb76rIL1UYgrkExkR5tO?=
 =?us-ascii?q?Nyt4Xc2UAT7HTO2BiiFIPCvTk20kT4HV0j/xT2Pk0MC+7jx2SltVsxdELqZyxQ?=
 =?us-ascii?q?w40OrHkleIGFh1JFCc4OrdJkFPCCSLl7JTLkBOun3zEhq8G4FsNFYQd8bcpKXp?=
 =?us-ascii?q?U/vJeLj0RBjiBiPix26mTUfR3i4IoK8yDFIYevHBn1nTVAOgrRbjHQr7W/plI0?=
 =?us-ascii?q?TEonMdMEP3CIc0DZlJHfBnGJhFCJFoTIJY/h/uzwGnydSVCr1CYrrZx5HLcpCR?=
 =?us-ascii?q?u1JD9PdyTfcaFLfi5NG7wSnnu+W3lRxAcLt2WjDuD7n+2gOKKwHm+V51XTOT9/?=
 =?us-ascii?q?OVtxleU3GAeAQAGE1q9u/iwzECkM++z4nc8okIGxZXePmTyJjUlYyCFnQ=3D?=
 =?us-ascii?q?=3D?=
IronPort-HdrOrdr: =?us-ascii?q?A9a23=3AMYSUza3Vzqv+SOCQX0oOawqjBKMkLtp133Aq?=
 =?us-ascii?q?2lEZdPU1SKGlfq+V8sjzuSWftN9VYgBCpTn/AtjjfZqsz/JICOAqVN/IYOClgg?=
 =?us-ascii?q?qVxepZgrcKrQeBJ8SHzJ856Ztd?=
X-IronPort-AV: E=Sophos;i="5.88,276,1635199200"; 
   d="scan'208";a="2250076"
Date: Mon, 10 Jan 2022 12:41:26 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Andrew Cooper <amc96@srcf.net>
Cc: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
Subject: Re: [PATCH 0/2] mini-os: remove device specific struct file members
Message-ID: <20220110114126.liis6f2pv5vfajqj@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Andrew Cooper <amc96@srcf.net>, Juergen Gross <jgross@suse.com>,
	minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
References: <20220107104706.9859-1-jgross@suse.com>
 <20220109011603.bymferaebanvvmud@begin>
 <25899482-4b0c-5fb4-5b02-226f75d1e5a6@srcf.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <25899482-4b0c-5fb4-5b02-226f75d1e5a6@srcf.net>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)

Andrew Cooper, le lun. 10 janv. 2022 11:35:14 +0000, a ecrit:
> On 09/01/2022 01:16, Samuel Thibault wrote:
> > Juergen Gross, le ven. 07 janv. 2022 11:47:04 +0100, a ecrit:
> >> can only be applied after the Xen libraries have stopped using the
> >> related union members.
> > Ah, ok :) Was that submitted somewhere?
> 
> https://lore.kernel.org/xen-devel/20220107103544.9271-1-jgross@suse.com/T/#u

Ok!

Samuel


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 14:58:28 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 14:58:28 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255762.438376 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbS-0002PV-2S; Tue, 11 Jan 2022 14:58:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255762.438376; Tue, 11 Jan 2022 14:58:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbR-0002PG-Pj; Tue, 11 Jan 2022 14:58:25 +0000
Received: by outflank-mailman (input) for mailman id 255762;
 Tue, 11 Jan 2022 14:58:23 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7IbP-0002Oa-UG
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:23 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ea732dc8-72ee-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 15:58:22 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 307611F3B1;
 Tue, 11 Jan 2022 14:58:20 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 08E741403F;
 Tue, 11 Jan 2022 14:58:20 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id SPr4AAyb3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:20 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ea732dc8-72ee-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913100; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=+t0vHow+1jfI7LN6o5B5LYduCmgQ0IacEYiredT7b+0=;
	b=OGLo/N++S22CxpWwoigNm0n3vT4KfIh+MFOyER6HhCKV1FtpwitHHHzo+gmfes2bV425cz
	GLU3ADO3UMjXdJPokxOSOt1R7tOwm5JmnGoIBcGvDwirbibYOJz5laz4dMPqFs+3AuXmjn
	MhsqXMzy2J0gEG06o26qYSJFajXVNR8=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 01/18] mini-os: split struct file definition from its usage
Date: Tue, 11 Jan 2022 15:58:00 +0100
Message-Id: <20220111145817.22170-2-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Make the struct file definition standalone and use it for the
declaration of the files array.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 include/lib.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 39d6a18..a638bc9 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -181,7 +181,7 @@ struct evtchn_port_info {
         int bound;
 };
 
-extern struct file {
+struct file {
     enum fd_type type;
     union {
 	struct {
@@ -236,7 +236,9 @@ extern struct file {
 #endif
     };
     int read;	/* maybe available for read */
-} files[];
+};
+
+extern struct file files[];
 
 int alloc_fd(enum fd_type type);
 void close_all_files(void);
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 14:58:28 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 14:58:28 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255765.438388 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbS-0002aH-Ns; Tue, 11 Jan 2022 14:58:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255765.438388; Tue, 11 Jan 2022 14:58:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbS-0002YO-EU; Tue, 11 Jan 2022 14:58:26 +0000
Received: by outflank-mailman (input) for mailman id 255765;
 Tue, 11 Jan 2022 14:58:25 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7IbR-0002OZ-CW
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:25 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id eb74dc4e-72ee-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 15:58:22 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id E9B53212CA;
 Tue, 11 Jan 2022 14:58:21 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BFE8913DDD;
 Tue, 11 Jan 2022 14:58:21 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id SM+DLQ2b3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:21 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: eb74dc4e-72ee-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913101; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=TREXG7+5/igcPNPrnaoW0C+ol3WOPsTOJ1n+uetqVIM=;
	b=RMzEluR0R4fgFdGUYZlpRN9kcrLAm9FKaQhlsOwmr0NuaXYDlXIX2d9602zbkd5n3DldVS
	FWh6iw030rnPWCiK37hb+Kqi0mle91w9GKtHPMavCQJZCK0fT2kygkIPsxpMysR9NYHfHS
	vvB0GFH/b9YGFFmP7w1jRCSg3WT26KE=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 10/18] mini-os: eliminate netfront union member in struct file
Date: Tue, 11 Jan 2022 15:58:09 +0100
Message-Id: <20220111145817.22170-11-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the netfront specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 include/lib.h | 3 ---
 lib/sys.c     | 6 +++---
 netfront.c    | 2 +-
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 5201ed7..f2a124e 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -193,9 +193,6 @@ struct file {
 	    struct evtchn_port_list ports;
 	} evtchn;
 	struct gntmap gntmap;
-	struct {
-	    struct netfront_dev *dev;
-	} tap;
 #ifdef CONFIG_TPMFRONT
 	struct {
 	   struct tpmfront_dev *dev;
diff --git a/lib/sys.c b/lib/sys.c
index 8c7ea3c..b35e433 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -263,7 +263,7 @@ int read(int fd, void *buf, size_t nbytes)
 #ifdef CONFIG_NETFRONT
 	case FTYPE_TAP: {
 	    ssize_t ret;
-	    ret = netfront_receive(files[fd].tap.dev, buf, nbytes);
+	    ret = netfront_receive(files[fd].dev, buf, nbytes);
 	    if (ret <= 0) {
 		errno = EAGAIN;
 		return -1;
@@ -339,7 +339,7 @@ int write(int fd, const void *buf, size_t nbytes)
 #endif
 #ifdef CONFIG_NETFRONT
 	case FTYPE_TAP:
-	    netfront_xmit(files[fd].tap.dev, (void*) buf, nbytes);
+	    netfront_xmit(files[fd].dev, (void*) buf, nbytes);
 	    return nbytes;
 #endif
 #ifdef CONFIG_BLKFRONT
@@ -450,7 +450,7 @@ int close(int fd)
 #endif
 #ifdef CONFIG_NETFRONT
 	case FTYPE_TAP:
-	    shutdown_netfront(files[fd].tap.dev);
+	    shutdown_netfront(files[fd].dev);
 	    files[fd].type = FTYPE_NONE;
 	    return 0;
 #endif
diff --git a/netfront.c b/netfront.c
index a566e34..7696451 100644
--- a/netfront.c
+++ b/netfront.c
@@ -576,7 +576,7 @@ int netfront_tap_open(char *nodename) {
     }
     dev->fd = alloc_fd(FTYPE_TAP);
     printk("tap_open(%s) -> %d\n", nodename, dev->fd);
-    files[dev->fd].tap.dev = dev;
+    files[dev->fd].dev = dev;
     return dev->fd;
 }
 #endif
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 14:58:28 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 14:58:28 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255769.438420 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbU-0003Cv-Sf; Tue, 11 Jan 2022 14:58:28 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255769.438420; Tue, 11 Jan 2022 14:58:28 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbU-0003BR-G7; Tue, 11 Jan 2022 14:58:28 +0000
Received: by outflank-mailman (input) for mailman id 255769;
 Tue, 11 Jan 2022 14:58:27 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7IbT-0002Oa-Ck
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:27 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id eb21f76e-72ee-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 15:58:22 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 5C3C8212C9;
 Tue, 11 Jan 2022 14:58:21 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 31DD213DDD;
 Tue, 11 Jan 2022 14:58:21 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id kN/9Cg2b3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:21 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: eb21f76e-72ee-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913101; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=+xnAEQMivwL4xL9yiMr125JOzBgLed0TX8eG+d+rWgM=;
	b=R/45p93GSeJMhztoEblmNbeURw2Jd3i2M59SMmUr9L5QQZte6tY/E0Z8grVdSp9wexDUMw
	TP0HcQa9WBa/HfMYQNuU9pZltF2FEFkQzOYBeteIUQ2dCE21n5q5T+W9hmiMbg5JpHb2pT
	SFRKXp0LflJIK2ZWYuu5sPTGJWUifTI=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 07/18] mini-os: eliminate consfront union member in struct file
Date: Tue, 11 Jan 2022 15:58:06 +0100
Message-Id: <20220111145817.22170-8-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the consfront specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 include/lib.h |  3 ---
 lib/sys.c     | 31 +++++++++++++++++--------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 3a40634..0cedae6 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -202,9 +202,6 @@ struct file {
 	struct {
 	    struct fbfront_dev *dev;
 	} fb;
-	struct {
-	    struct consfront_dev *dev;
-	} cons;
 #ifdef CONFIG_TPMFRONT
 	struct {
 	   struct tpmfront_dev *dev;
diff --git a/lib/sys.c b/lib/sys.c
index f2fdbdf..62c2020 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -179,7 +179,7 @@ int posix_openpt(int flags)
 
     dev = init_consfront(NULL);
     dev->fd = alloc_fd(FTYPE_CONSOLE);
-    files[dev->fd].cons.dev = dev;
+    files[dev->fd].dev = dev;
 
     printk("fd(%d) = posix_openpt\n", dev->fd);
     return(dev->fd);
@@ -194,7 +194,7 @@ int open_savefile(const char *path, int save)
 
     dev = init_consfront(nodename);
     dev->fd = alloc_fd(FTYPE_SAVEFILE);
-    files[dev->fd].cons.dev = dev;
+    files[dev->fd].dev = dev;
 
     printk("fd(%d) = open_savefile\n", dev->fd);
     return(dev->fd);
@@ -248,7 +248,7 @@ int read(int fd, void *buf, size_t nbytes)
             DEFINE_WAIT(w);
             while(1) {
                 add_waiter(w, console_queue);
-                ret = xencons_ring_recv(files[fd].cons.dev, buf, nbytes);
+                ret = xencons_ring_recv(files[fd].dev, buf, nbytes);
                 if (ret)
                     break;
                 schedule();
@@ -324,14 +324,14 @@ int write(int fd, const void *buf, size_t nbytes)
         case FTYPE_SAVEFILE: {
                 int ret = 0, tot = nbytes;
                 while (nbytes > 0) {
-                    ret = xencons_ring_send(files[fd].cons.dev, (char *)buf, nbytes);
+                    ret = xencons_ring_send(files[fd].dev, (char *)buf, nbytes);
                     nbytes -= ret;
                     buf = (char *)buf + ret;
                 }
                 return tot - nbytes;
             }
 	case FTYPE_CONSOLE:
-	    console_print(files[fd].cons.dev, (char *)buf, nbytes);
+	    console_print(files[fd].dev, (char *)buf, nbytes);
 	    return nbytes;
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
@@ -487,7 +487,7 @@ int close(int fd)
 #ifdef CONFIG_CONSFRONT
         case FTYPE_SAVEFILE:
         case FTYPE_CONSOLE:
-            fini_consfront(files[fd].cons.dev);
+            fini_consfront(files[fd].dev);
             files[fd].type = FTYPE_NONE;
             return 0;
 #endif
@@ -764,7 +764,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 	    /* Fallthrough.  */
 	case FTYPE_CONSOLE:
 	    if (FD_ISSET(i, readfds)) {
-                if (xencons_ring_avail(files[i].cons.dev))
+                if (xencons_ring_avail(files[i].dev))
 		    n++;
 		else
 		    FD_CLR(i, readfds);
@@ -1447,6 +1447,8 @@ const struct termios default_termios = {0,             /* iflag */
 
 int tcsetattr(int fildes, int action, const struct termios *tios)
 {
+    struct consfront_dev *dev;
+
     if (fildes < 0 || fildes >= NOFILE) {
         errno = EBADF;
         return -1;
@@ -1472,21 +1474,21 @@ int tcsetattr(int fildes, int action, const struct termios *tios)
             return -1;
     }
 
-    if (files[fildes].cons.dev == NULL) {
+    dev = files[fildes].dev;
+    if (dev == NULL) {
         errno = ENOSYS;
         return -1;
     }
 
-    if (tios->c_oflag & OPOST)
-        files[fildes].cons.dev->is_raw = false;
-    else
-        files[fildes].cons.dev->is_raw = true;
+    dev->is_raw = !(tios->c_oflag & OPOST);
 
     return 0;
 }
 
 int tcgetattr(int fildes, struct termios *tios)
 {
+    struct consfront_dev *dev;
+
     if (fildes < 0 || fildes >= NOFILE) {
         errno = EBADF;
         return -1;
@@ -1497,7 +1499,8 @@ int tcgetattr(int fildes, struct termios *tios)
         return -1;
     }
 
-    if (files[fildes].cons.dev == NULL) {
+    dev = files[fildes].dev;
+    if (dev == NULL) {
         errno = ENOSYS;
         return 0;
     }
@@ -1509,7 +1512,7 @@ int tcgetattr(int fildes, struct termios *tios)
 
     memcpy(tios, &default_termios, sizeof(struct termios));
 
-    if (files[fildes].cons.dev->is_raw)
+    if (dev->is_raw)
         tios->c_oflag &= ~OPOST;
 
     return 0;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 14:58:29 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 14:58:29 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255770.438421 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbU-0003Eq-Vi; Tue, 11 Jan 2022 14:58:28 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255770.438421; Tue, 11 Jan 2022 14:58:28 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbU-0003D0-JL; Tue, 11 Jan 2022 14:58:28 +0000
Received: by outflank-mailman (input) for mailman id 255770;
 Tue, 11 Jan 2022 14:58:27 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7IbT-0002OZ-Ck
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:27 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id eb953028-72ee-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 15:58:22 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 242F7212CB;
 Tue, 11 Jan 2022 14:58:22 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EF06413DDD;
 Tue, 11 Jan 2022 14:58:21 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id gEULOQ2b3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:21 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: eb953028-72ee-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913102; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=Kc8vjPoaiZBPWJd7bC9/lWlsrU4qpi/hgSPUhZ8Wm48=;
	b=LQxJ7OH+F7Zw7qdHdMyNJ2UZp9vmF7os301Zp+Ys8Ek/bMu0+EImR1SRe2hGXSSHeMo/QX
	xQUrY5LeQ8sRz0L1Ngdk93hAUn4RUUO17NZL8C36p2AKFBD8060iTmEiJtqjFrJOoZ/txp
	JkeH5ZgZyrLtps8OYkxDA+zWq5ReSdI=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 11/18] mini-os: move tpm respgot member of struct file to device specific data
Date: Tue, 11 Jan 2022 15:58:10 +0100
Message-Id: <20220111145817.22170-12-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Tpmfront has a "respgot" flag in struct file, which can be moved to the
device specific data. While at it make it a bool.

The respgot flag of the tpm_tis member of struct file can be removed,
as it is never read.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 include/lib.h      |  2 --
 include/tpmfront.h |  2 ++
 tpm_tis.c          |  2 --
 tpmfront.c         | 10 +++++-----
 4 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index f2a124e..d740065 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -196,13 +196,11 @@ struct file {
 #ifdef CONFIG_TPMFRONT
 	struct {
 	   struct tpmfront_dev *dev;
-	   int respgot;
 	} tpmfront;
 #endif
 #ifdef CONFIG_TPM_TIS
 	struct {
 	   struct tpm_chip *dev;
-	   int respgot;
 	} tpm_tis;
 #endif
 #ifdef CONFIG_XENBUS
diff --git a/include/tpmfront.h b/include/tpmfront.h
index c489fae..b7da50e 100644
--- a/include/tpmfront.h
+++ b/include/tpmfront.h
@@ -25,6 +25,7 @@
 #ifndef TPMFRONT_H
 #define TPMFRONT_H
 
+#include <stdbool.h>
 #include <mini-os/types.h>
 #include <mini-os/os.h>
 #include <mini-os/events.h>
@@ -53,6 +54,7 @@ struct tpmfront_dev {
 
 #ifdef HAVE_LIBC
    int fd;
+   bool respgot;
 #endif
 
 };
diff --git a/tpm_tis.c b/tpm_tis.c
index 8a632b1..4127118 100644
--- a/tpm_tis.c
+++ b/tpm_tis.c
@@ -846,7 +846,6 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
 #ifdef HAVE_LIBC
    if(tpm->fd >= 0) {
       files[tpm->fd].read = false;
-      files[tpm->fd].tpm_tis.respgot = 0;
       files[tpm->fd].offset = 0;
    }
 #endif
@@ -1290,7 +1289,6 @@ int tpm_tis_open(struct tpm_chip* tpm)
    tpm->fd = alloc_fd(FTYPE_TPM_TIS);
    printk("tpm_tis_open() -> %d\n", tpm->fd);
    files[tpm->fd].tpm_tis.dev = tpm;
-   files[tpm->fd].tpm_tis.respgot = 0;
    return tpm->fd;
 }
 
diff --git a/tpmfront.c b/tpmfront.c
index 8b2a910..be671c2 100644
--- a/tpmfront.c
+++ b/tpmfront.c
@@ -439,8 +439,8 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
 #ifdef HAVE_LIBC
    if(dev->fd >= 0) {
       files[dev->fd].read = false;
-      files[dev->fd].tpmfront.respgot = 0;
       files[dev->fd].offset = 0;
+      dev->respgot = false;
    }
 #endif
    wmb();
@@ -499,7 +499,7 @@ int i;
 #endif
 #ifdef HAVE_LIBC
    if(dev->fd >= 0) {
-      files[dev->fd].tpmfront.respgot = 1;
+      dev->respgot = true;
    }
 #endif
 quit:
@@ -539,7 +539,7 @@ int tpmfront_open(struct tpmfront_dev* dev)
    dev->fd = alloc_fd(FTYPE_TPMFRONT);
    printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
    files[dev->fd].tpmfront.dev = dev;
-   files[dev->fd].tpmfront.respgot = 0;
+   dev->respgot = false;
    return dev->fd;
 }
 
@@ -580,7 +580,7 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
    }
 
    /* get the response if we haven't already */
-   if(files[dev->fd].tpmfront.respgot == 0) {
+   if (!dev->respgot) {
       if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
 	 errno = EIO;
 	 return -1;
@@ -610,7 +610,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
 
    /* If we have a response waiting, then read it now from the backend
     * so we can get its length*/
-   if(dev->waiting || (files[dev->fd].read && !files[dev->fd].tpmfront.respgot)) {
+   if(dev->waiting || (files[dev->fd].read && !dev->respgot)) {
       if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
 	 errno = EIO;
 	 return -1;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 14:58:29 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 14:58:29 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255766.438396 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbS-0002bT-U2; Tue, 11 Jan 2022 14:58:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255766.438396; Tue, 11 Jan 2022 14:58:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbS-0002ZR-GZ; Tue, 11 Jan 2022 14:58:26 +0000
Received: by outflank-mailman (input) for mailman id 255766;
 Tue, 11 Jan 2022 14:58:25 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7IbR-0002Oa-CY
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:25 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id eb068b7d-72ee-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 15:58:22 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 2BE751F3BC;
 Tue, 11 Jan 2022 14:58:21 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0484A13DDD;
 Tue, 11 Jan 2022 14:58:20 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 8NN9Owyb3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:20 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: eb068b7d-72ee-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913101; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=cpZ+5J0dnLWZk57QHjN9YUOxVha4rvn1wsE3TtHogLs=;
	b=GgsG7/fulZvIDHuEMcqegNiYNkq/fIzKJ14c9i1ZyEujrgF7ivH9zajgC+1sYzo67tNkVC
	z5tBQ66e1EP45KeW2YHCgLaTT81ormHlyMXeQ0cNwZxwQmKjPRsnP+Q4GRR7br7XsJeoZl
	dCHr125Rm95Gx36yZl+/4hhKPiPJTQc=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 06/18] mini-os: eliminate blkfront union member in struct file
Date: Tue, 11 Jan 2022 15:58:05 +0100
Message-Id: <20220111145817.22170-7-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the blkfront specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 blkfront.c    | 6 +++---
 include/lib.h | 3 ---
 lib/sys.c     | 2 +-
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/blkfront.c b/blkfront.c
index 8137106..e3f42be 100644
--- a/blkfront.c
+++ b/blkfront.c
@@ -562,13 +562,13 @@ int blkfront_open(struct blkfront_dev *dev)
     }
     dev->fd = alloc_fd(FTYPE_BLK);
     printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].blk.dev = dev;
+    files[dev->fd].dev = dev;
     return dev->fd;
 }
 
 int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
 {
-   struct blkfront_dev* dev = files[fd].blk.dev;
+   struct blkfront_dev* dev = files[fd].dev;
    off_t offset = files[fd].offset;
    struct blkfront_aiocb aiocb;
    unsigned long long disksize = dev->info.sectors * dev->info.sector_size;
@@ -718,7 +718,7 @@ int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
 
 int blkfront_posix_fstat(int fd, struct stat* buf)
 {
-   struct blkfront_dev* dev = files[fd].blk.dev;
+   struct blkfront_dev* dev = files[fd].dev;
 
    buf->st_mode = dev->info.mode;
    buf->st_uid = 0;
diff --git a/include/lib.h b/include/lib.h
index 60aaf1c..3a40634 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -196,9 +196,6 @@ struct file {
 	struct {
 	    struct netfront_dev *dev;
 	} tap;
-	struct {
-	    struct blkfront_dev *dev;
-	} blk;
 	struct {
 	    struct kbdfront_dev *dev;
 	} kbd;
diff --git a/lib/sys.c b/lib/sys.c
index 1da7401..f2fdbdf 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -456,7 +456,7 @@ int close(int fd)
 #endif
 #ifdef CONFIG_BLKFRONT
 	case FTYPE_BLK:
-            shutdown_blkfront(files[fd].blk.dev);
+            shutdown_blkfront(files[fd].dev);
 	    files[fd].type = FTYPE_NONE;
 	    return 0;
 #endif
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 14:58:30 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 14:58:30 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255761.438371 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbR-0002PC-Re; Tue, 11 Jan 2022 14:58:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255761.438371; Tue, 11 Jan 2022 14:58:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbR-0002P5-O6; Tue, 11 Jan 2022 14:58:25 +0000
Received: by outflank-mailman (input) for mailman id 255761;
 Tue, 11 Jan 2022 14:58:23 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7IbP-0002OZ-Qs
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:23 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id eae6e135-72ee-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 15:58:22 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id F1D5A1F3BB;
 Tue, 11 Jan 2022 14:58:20 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BEF7D13DDD;
 Tue, 11 Jan 2022 14:58:20 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id iPVtLQyb3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:20 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: eae6e135-72ee-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913100; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=bXQLf+XZM4DSdC0ST175q8yp6sLq3mgUD+Ukh4h4ycY=;
	b=uo+Ej/mLxhV+wD9G0M/07AtRWmY/ziB4vZFuM4UjznOccjblD0NKqbjdhR7PaUhIu46N2w
	uCSwSIv3JpiHCPmX+mQitsPCQYAlODzC8u7T1VYDwvWZ+SN1hzrsJPN0L+SYivvl3y8VOz
	gIhCyXUdpfgBdjM+gutQGZFr/MluhKI=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 05/18] mini-os: introduce a common dev pointer in struct file
Date: Tue, 11 Jan 2022 15:58:04 +0100
Message-Id: <20220111145817.22170-6-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

There are many dev pointers in a union in struct file. Prepare to
switch to a single one by introducing a new common one.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 include/lib.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/lib.h b/include/lib.h
index dc56f52..60aaf1c 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -188,6 +188,7 @@ struct file {
     off_t offset;
     union {
         int fd; /* Any fd from an upper layer. */
+        void *dev;
 	struct {
 	    struct evtchn_port_list ports;
 	} evtchn;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 14:58:32 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 14:58:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255773.438446 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbY-0003o5-24; Tue, 11 Jan 2022 14:58:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255773.438446; Tue, 11 Jan 2022 14:58:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbX-0003me-HN; Tue, 11 Jan 2022 14:58:31 +0000
Received: by outflank-mailman (input) for mailman id 255773;
 Tue, 11 Jan 2022 14:58:29 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7IbV-0002Oa-D2
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:29 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ea732db9-72ee-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 15:58:22 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 04412212C3;
 Tue, 11 Jan 2022 14:58:20 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CE0BC13DDD;
 Tue, 11 Jan 2022 14:58:19 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 7Q0EMQub3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:19 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ea732db9-72ee-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913100; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:  content-transfer-encoding:content-transfer-encoding;
	bh=Z0tDS/aCIk9/03puqNfGz+4Is8FvtxuzfJRiRCv9vJ4=;
	b=fLKxX0ckKc31+m9WJlAtkqCR1c/JuWOIieT+T52JOxFls53jvYaVskuhoh5cOdCmxnUfj1
	ns2ZrKYrQPeYWUREbvBzqFoR1zMObREdwKJpAm1dkjHslL5a0z+SqUvL8er6We2vzD01Jx
	APT0NDVjDftv1WZBDRc2C/K+YLDq/n0=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 00/18] mini-os: remove struct file dependency on config
Date: Tue, 11 Jan 2022 15:57:59 +0100
Message-Id: <20220111145817.22170-1-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Today the layout of struct file is depending on the Mini-OS
configuration. This is especially bad as the layout is exported to
external users like the Xen libraries built for Mini-OS, and those
are being built only once for multiple stubdom configurations.

Today there is no direct problem resulting from this, as the main
difference between struct file layouts is a large union containing all
the device specific data for the different file types. The largest
union member is not configuration dependant, so the build is currently
not broken.

In order to avoid any future problems this patch series is eliminating
the configuration dependency by replacing most of the device specific
union members by a single pointer.

The two union members used by Xen libraries can't be replaced yet, as
those need to be switched to use the generic pointer first.

In order to hide the Mini-OS internal implementation of the files
array, patches 15-17 are introducing a common framework to access a
struct file via its file descriptor, and to allocate new file types
dynamically instead of having them all pre-defined. The file type
specific operations are supplied via a function vector in order to
remove the dependency of lib/sys.c on all the various file types.

Changes in V2:
- added 3 more patches

Juergen Gross (18):
  mini-os: split struct file definition from its usage
  mini-os: makes file.read bool and move it ahead of device specific
    part
  mini-os: make offset a common struct file member for all types
  mini-os: replace multiple fd elements in struct file by common one
  mini-os: introduce a common dev pointer in struct file
  mini-os: eliminate blkfront union member in struct file
  mini-os: eliminate consfront union member in struct file
  mini-os: eliminate fbfront union member in struct file
  mini-os: eliminate kbdfront union member in struct file
  mini-os: eliminate netfront union member in struct file
  mini-os: move tpm respgot member of struct file to device specific
    data
  mini-os: eliminate tpmfront union member in struct file
  mini-os: eliminate tpmtis union member in struct file
  mini-os: eliminate xenbus union member in struct file
  mini-os: introduce get_file_from_fd()
  mini-os: reset file type in close() in one place only
  mini-os: use function vectors instead of switch for file operations
  mini-os: remove file type FTYPE_XC

 Config.mk                     |   1 -
 arch/x86/testbuild/all-no     |   1 -
 arch/x86/testbuild/all-yes    |   1 -
 arch/x86/testbuild/newxen-yes |   1 -
 blkfront.c                    |  15 +-
 console/xencons_ring.c        |   2 +-
 fbfront.c                     |  16 +-
 include/lib.h                 | 123 ++++++------
 include/tpmfront.h            |   2 +
 lib/sys.c                     | 363 +++++++++++++++++++++++-----------
 lib/xs.c                      |  14 +-
 netfront.c                    |   6 +-
 tpm_tis.c                     |  23 +--
 tpmfront.c                    |  33 ++--
 14 files changed, 352 insertions(+), 249 deletions(-)

-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 14:58:32 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 14:58:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255774.438452 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbY-0003pa-8O; Tue, 11 Jan 2022 14:58:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255774.438452; Tue, 11 Jan 2022 14:58:32 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IbX-0003o3-MU; Tue, 11 Jan 2022 14:58:31 +0000
Received: by outflank-mailman (input) for mailman id 255774;
 Tue, 11 Jan 2022 14:58:29 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7IbV-0002OZ-D4
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:29 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id eabddecc-72ee-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 15:58:22 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id B8B941F3BA;
 Tue, 11 Jan 2022 14:58:20 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 90B4913DDD;
 Tue, 11 Jan 2022 14:58:20 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id YLshIgyb3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:20 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: eabddecc-72ee-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913100; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=DMMBPYWRjtz4/x5ruR8HIV8cwX5HYWaCHB+pYDCnRVA=;
	b=JzdJyIpda3v4DRJ6dS3sevj+AMPFI4kl5bVC6hqBjKmi/wVNJD011RpzoX3nC6Wow99h/x
	abJGpEd/063Sn404YSrpDDbM34VQl0OcQOOvrZrKpVyM5NMvV9IkhKmt972sFvCU31b+Ce
	tIjGmAXz8jLlE4wy673TLMcZqma+nX8=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 04/18] mini-os: replace multiple fd elements in struct file by common one
Date: Tue, 11 Jan 2022 15:58:03 +0100
Message-Id: <20220111145817.22170-5-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

The type specific union in struct files contains two instances of
"int fd". Replace them by a common one.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 include/lib.h |  9 +--------
 lib/sys.c     | 28 ++++++++++++++--------------
 2 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 4d9b14b..dc56f52 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -187,14 +187,7 @@ struct file {
     bool read;	/* maybe available for read */
     off_t offset;
     union {
-	struct {
-            /* lwIP fd */
-	    int fd;
-	} socket;
-	struct {
-            /* FS import fd */
-	    int fd;
-	} file;
+        int fd; /* Any fd from an upper layer. */
 	struct {
 	    struct evtchn_port_list ports;
 	} evtchn;
diff --git a/lib/sys.c b/lib/sys.c
index e1cea70..1da7401 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -258,7 +258,7 @@ int read(int fd, void *buf, size_t nbytes)
         }
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
-	    return lwip_read(files[fd].socket.fd, buf, nbytes);
+	    return lwip_read(files[fd].fd, buf, nbytes);
 #endif
 #ifdef CONFIG_NETFRONT
 	case FTYPE_TAP: {
@@ -335,7 +335,7 @@ int write(int fd, const void *buf, size_t nbytes)
 	    return nbytes;
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
-	    return lwip_write(files[fd].socket.fd, (void*) buf, nbytes);
+	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
 #endif
 #ifdef CONFIG_NETFRONT
 	case FTYPE_TAP:
@@ -428,7 +428,7 @@ int close(int fd)
 #endif
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET: {
-	    int res = lwip_close(files[fd].socket.fd);
+	    int res = lwip_close(files[fd].fd);
 	    files[fd].type = FTYPE_NONE;
 	    return res;
 	}
@@ -594,7 +594,7 @@ int fcntl(int fd, int cmd, ...)
 	    if (files[fd].type == FTYPE_SOCKET && !(arg & ~O_NONBLOCK)) {
 		/* Only flag supported: non-blocking mode */
 		uint32_t nblock = !!(arg & O_NONBLOCK);
-		return lwip_ioctl(files[fd].socket.fd, FIONBIO, &nblock);
+		return lwip_ioctl(files[fd].fd, FIONBIO, &nblock);
 	    }
 	    /* Fallthrough */
 #endif
@@ -732,15 +732,15 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
     for (i = 0; i < nfds; i++) {
 	if (files[i].type == FTYPE_SOCKET) {
 	    if (FD_ISSET(i, readfds)) {
-		FD_SET(files[i].socket.fd, &sock_readfds);
+		FD_SET(files[i].fd, &sock_readfds);
 		sock_nfds = i+1;
 	    }
 	    if (FD_ISSET(i, writefds)) {
-		FD_SET(files[i].socket.fd, &sock_writefds);
+		FD_SET(files[i].fd, &sock_writefds);
 		sock_nfds = i+1;
 	    }
 	    if (FD_ISSET(i, exceptfds)) {
-		FD_SET(files[i].socket.fd, &sock_exceptfds);
+		FD_SET(files[i].fd, &sock_exceptfds);
 		sock_nfds = i+1;
 	    }
 	}
@@ -803,19 +803,19 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 	case FTYPE_SOCKET:
 	    if (FD_ISSET(i, readfds)) {
 	        /* Optimize no-network-packet case.  */
-		if (sock_n && FD_ISSET(files[i].socket.fd, &sock_readfds))
+		if (sock_n && FD_ISSET(files[i].fd, &sock_readfds))
 		    n++;
 		else
 		    FD_CLR(i, readfds);
 	    }
             if (FD_ISSET(i, writefds)) {
-		if (sock_n && FD_ISSET(files[i].socket.fd, &sock_writefds))
+		if (sock_n && FD_ISSET(files[i].fd, &sock_writefds))
 		    n++;
 		else
 		    FD_CLR(i, writefds);
             }
             if (FD_ISSET(i, exceptfds)) {
-		if (sock_n && FD_ISSET(files[i].socket.fd, &sock_exceptfds))
+		if (sock_n && FD_ISSET(files[i].fd, &sock_exceptfds))
 		    n++;
 		else
 		    FD_CLR(i, exceptfds);
@@ -1112,7 +1112,7 @@ int socket(int domain, int type, int protocol)
 	return -1;
     res = alloc_fd(FTYPE_SOCKET);
     printk("socket -> %d\n", res);
-    files[res].socket.fd = fd;
+    files[res].fd = fd;
     return res;
 }
 
@@ -1124,11 +1124,11 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
 	errno = EBADF;
 	return -1;
     }
-    fd = lwip_accept(files[s].socket.fd, addr, addrlen);
+    fd = lwip_accept(files[s].fd, addr, addrlen);
     if (fd < 0)
 	return -1;
     res = alloc_fd(FTYPE_SOCKET);
-    files[res].socket.fd = fd;
+    files[res].fd = fd;
     printk("accepted on %d -> %d\n", s, res);
     return res;
 }
@@ -1141,7 +1141,7 @@ ret name proto \
 	errno = EBADF; \
 	return -1; \
     } \
-    s = files[s].socket.fd; \
+    s = files[s].fd; \
     return lwip_##name args; \
 }
 
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 14:58:35 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 14:58:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255779.438476 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Iba-0004NK-Vg; Tue, 11 Jan 2022 14:58:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255779.438476; Tue, 11 Jan 2022 14:58:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Iba-0004L8-Ad; Tue, 11 Jan 2022 14:58:34 +0000
Received: by outflank-mailman (input) for mailman id 255779;
 Tue, 11 Jan 2022 14:58:32 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7IbX-0002Oa-DA
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:31 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id eaa6c309-72ee-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 15:58:22 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 8B1AB212C5;
 Tue, 11 Jan 2022 14:58:20 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 63AD313DDD;
 Tue, 11 Jan 2022 14:58:20 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id mNItFwyb3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:20 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: eaa6c309-72ee-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913100; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=B1qIgvUq07hNrHG3qYVz9ZnwoNPkdqDFYkWrq9AIUhQ=;
	b=Hm+0JCHE/qFCO0PSAk6d7BkNGhNjVFHbFcBonMcRxLYHDPJf9AuEnTDIGW4d+8Glr7g2hn
	FH4Z2mIWkoOvxwp8LcedDRrPQeaej4OqKw+A/bVxTpdFbfenwQqcizECq/SLYRMGHXyC19
	lFAXftWBn3Ac8Cic1GjyT3P3igyPKVk=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 03/18] mini-os: make offset a common struct file member for all types
Date: Tue, 11 Jan 2022 15:58:02 +0100
Message-Id: <20220111145817.22170-4-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Currently 4 file types have an offset member in their private struct
file part. Make offset a common struct member shared by all file types.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 blkfront.c    |  5 ++---
 include/lib.h |  5 +----
 lib/sys.c     | 14 +++++---------
 tpm_tis.c     | 11 +++++------
 tpmfront.c    | 11 +++++------
 5 files changed, 18 insertions(+), 28 deletions(-)

diff --git a/blkfront.c b/blkfront.c
index 7c8eb74..8137106 100644
--- a/blkfront.c
+++ b/blkfront.c
@@ -563,14 +563,13 @@ int blkfront_open(struct blkfront_dev *dev)
     dev->fd = alloc_fd(FTYPE_BLK);
     printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
     files[dev->fd].blk.dev = dev;
-    files[dev->fd].blk.offset = 0;
     return dev->fd;
 }
 
 int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
 {
    struct blkfront_dev* dev = files[fd].blk.dev;
-   off_t offset = files[fd].blk.offset;
+   off_t offset = files[fd].offset;
    struct blkfront_aiocb aiocb;
    unsigned long long disksize = dev->info.sectors * dev->info.sector_size;
    unsigned int blocksize = dev->info.sector_size;
@@ -712,7 +711,7 @@ int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
    }
 
    free(copybuf);
-   files[fd].blk.offset += rc;
+   files[fd].offset += rc;
    return rc;
 
 }
diff --git a/include/lib.h b/include/lib.h
index df2de9e..4d9b14b 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -185,6 +185,7 @@ struct evtchn_port_info {
 struct file {
     enum fd_type type;
     bool read;	/* maybe available for read */
+    off_t offset;
     union {
 	struct {
             /* lwIP fd */
@@ -193,7 +194,6 @@ struct file {
 	struct {
             /* FS import fd */
 	    int fd;
-	    off_t offset;
 	} file;
 	struct {
 	    struct evtchn_port_list ports;
@@ -204,7 +204,6 @@ struct file {
 	} tap;
 	struct {
 	    struct blkfront_dev *dev;
-            off_t offset;
 	} blk;
 	struct {
 	    struct kbdfront_dev *dev;
@@ -219,14 +218,12 @@ struct file {
 	struct {
 	   struct tpmfront_dev *dev;
 	   int respgot;
-	   off_t offset;
 	} tpmfront;
 #endif
 #ifdef CONFIG_TPM_TIS
 	struct {
 	   struct tpm_chip *dev;
 	   int respgot;
-	   off_t offset;
 	} tpm_tis;
 #endif
 #ifdef CONFIG_XENBUS
diff --git a/lib/sys.c b/lib/sys.c
index e8d5eb2..e1cea70 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -107,6 +107,7 @@ int alloc_fd(enum fd_type type)
     for (i=0; i<NOFILE; i++) {
 	if (files[i].type == FTYPE_NONE) {
 	    files[i].type = type;
+            files[i].offset = 0;
 	    pthread_mutex_unlock(&fd_lock);
 	    return i;
 	}
@@ -363,25 +364,20 @@ int write(int fd, const void *buf, size_t nbytes)
 
 off_t lseek(int fd, off_t offset, int whence)
 {
-    off_t* target = NULL;
     switch(files[fd].type) {
 #ifdef CONFIG_BLKFRONT
        case FTYPE_BLK:
-          target = &files[fd].blk.offset;
           break;
 #endif
 #ifdef CONFIG_TPMFRONT
        case FTYPE_TPMFRONT:
-          target = &files[fd].tpmfront.offset;
           break;
 #endif
 #ifdef CONFIG_TPM_TIS
        case FTYPE_TPM_TIS:
-          target = &files[fd].tpm_tis.offset;
           break;
 #endif
        case FTYPE_FILE:
-          target = &files[fd].file.offset;
           break;
        default:
           /* Not implemented for this filetype */
@@ -391,10 +387,10 @@ off_t lseek(int fd, off_t offset, int whence)
 
     switch (whence) {
        case SEEK_SET:
-          *target = offset;
+          files[fd].offset = offset;
           break;
        case SEEK_CUR:
-          *target += offset;
+          files[fd].offset += offset;
           break;
        case SEEK_END:
           {
@@ -403,14 +399,14 @@ off_t lseek(int fd, off_t offset, int whence)
              ret = fstat(fd, &st);
              if (ret)
                 return -1;
-             *target = st.st_size + offset;
+             files[fd].offset = st.st_size + offset;
              break;
           }
        default:
           errno = EINVAL;
           return -1;
     }
-    return *target;
+    return files[fd].offset;
 }
 
 int fsync(int fd) {
diff --git a/tpm_tis.c b/tpm_tis.c
index 4a51027..8a632b1 100644
--- a/tpm_tis.c
+++ b/tpm_tis.c
@@ -847,7 +847,7 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
    if(tpm->fd >= 0) {
       files[tpm->fd].read = false;
       files[tpm->fd].tpm_tis.respgot = 0;
-      files[tpm->fd].tpm_tis.offset = 0;
+      files[tpm->fd].offset = 0;
    }
 #endif
    return len;
@@ -1290,7 +1290,6 @@ int tpm_tis_open(struct tpm_chip* tpm)
    tpm->fd = alloc_fd(FTYPE_TPM_TIS);
    printk("tpm_tis_open() -> %d\n", tpm->fd);
    files[tpm->fd].tpm_tis.dev = tpm;
-   files[tpm->fd].tpm_tis.offset = 0;
    files[tpm->fd].tpm_tis.respgot = 0;
    return tpm->fd;
 }
@@ -1340,13 +1339,13 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
 
 
    /* Handle EOF case */
-   if(files[fd].tpm_tis.offset >= tpm->data_len) {
+   if(files[fd].offset >= tpm->data_len) {
       rc = 0;
    } else {
-      rc = min(tpm->data_len - files[fd].tpm_tis.offset, count);
-      memcpy(buf, tpm->data_buffer + files[fd].tpm_tis.offset, rc);
+      rc = min(tpm->data_len - files[fd].offset, count);
+      memcpy(buf, tpm->data_buffer + files[fd].offset, rc);
    }
-   files[fd].tpm_tis.offset += rc;
+   files[fd].offset += rc;
    /* Reset the data pending flag */
    return rc;
 }
diff --git a/tpmfront.c b/tpmfront.c
index d825b49..8b2a910 100644
--- a/tpmfront.c
+++ b/tpmfront.c
@@ -440,7 +440,7 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
    if(dev->fd >= 0) {
       files[dev->fd].read = false;
       files[dev->fd].tpmfront.respgot = 0;
-      files[dev->fd].tpmfront.offset = 0;
+      files[dev->fd].offset = 0;
    }
 #endif
    wmb();
@@ -539,7 +539,6 @@ int tpmfront_open(struct tpmfront_dev* dev)
    dev->fd = alloc_fd(FTYPE_TPMFRONT);
    printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
    files[dev->fd].tpmfront.dev = dev;
-   files[dev->fd].tpmfront.offset = 0;
    files[dev->fd].tpmfront.respgot = 0;
    return dev->fd;
 }
@@ -589,14 +588,14 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
    }
 
    /* handle EOF case */
-   if(files[dev->fd].tpmfront.offset >= dev->resplen) {
+   if(files[dev->fd].offset >= dev->resplen) {
       return 0;
    }
 
    /* Compute the number of bytes and do the copy operation */
-   if((rc = min(count, dev->resplen - files[dev->fd].tpmfront.offset)) != 0) {
-      memcpy(buf, dev->respbuf + files[dev->fd].tpmfront.offset, rc);
-      files[dev->fd].tpmfront.offset += rc;
+   if((rc = min(count, dev->resplen - files[dev->fd].offset)) != 0) {
+      memcpy(buf, dev->respbuf + files[dev->fd].offset, rc);
+      files[dev->fd].offset += rc;
    }
 
    return rc;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 14:58:35 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 14:58:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255778.438474 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ibb-0004LS-0k; Tue, 11 Jan 2022 14:58:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255778.438474; Tue, 11 Jan 2022 14:58:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Iba-0004JH-6V; Tue, 11 Jan 2022 14:58:34 +0000
Received: by outflank-mailman (input) for mailman id 255778;
 Tue, 11 Jan 2022 14:58:31 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7IbX-0002OZ-Db
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:31 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id ec131df5-72ee-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 15:58:23 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id B94521F3C0;
 Tue, 11 Jan 2022 14:58:21 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 904D013DDD;
 Tue, 11 Jan 2022 14:58:21 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id MDb6IQ2b3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:21 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ec131df5-72ee-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913101; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=Y+cFyyKrZNtwGa8ajfw3LoYs6PEvCSgNiRQOqaGYZOo=;
	b=kE1dypH8RaMAizI9BnfmTJJoaByoAHqPkAxNRwEI1vXMOqIWuj+YZUzYdmhRKADy4ZaOiY
	4R4H27w8skxfiJR6EAUJ2mu/y+XEPU6Hs25S+lyB0eP5r1vbjSrpzRa+3dSbbpr+psrRD3
	kA1khR01z1NP+3Z4et6/Lz2djrkYWFQ=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 09/18] mini-os: eliminate kbdfront union member in struct file
Date: Tue, 11 Jan 2022 15:58:08 +0100
Message-Id: <20220111145817.22170-10-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the kbdfront specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 fbfront.c     | 2 +-
 include/lib.h | 3 ---
 lib/sys.c     | 4 ++--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fbfront.c b/fbfront.c
index c8410af..1e055fb 100644
--- a/fbfront.c
+++ b/fbfront.c
@@ -302,7 +302,7 @@ int kbdfront_open(struct kbdfront_dev *dev)
 {
     dev->fd = alloc_fd(FTYPE_KBD);
     printk("kbd_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].kbd.dev = dev;
+    files[dev->fd].dev = dev;
     return dev->fd;
 }
 #endif
diff --git a/include/lib.h b/include/lib.h
index 2a9a01c..5201ed7 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -196,9 +196,6 @@ struct file {
 	struct {
 	    struct netfront_dev *dev;
 	} tap;
-	struct {
-	    struct kbdfront_dev *dev;
-	} kbd;
 #ifdef CONFIG_TPMFRONT
 	struct {
 	   struct tpmfront_dev *dev;
diff --git a/lib/sys.c b/lib/sys.c
index 2d48657..8c7ea3c 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -275,7 +275,7 @@ int read(int fd, void *buf, size_t nbytes)
         case FTYPE_KBD: {
             int ret, n;
             n = nbytes / sizeof(union xenkbd_in_event);
-            ret = kbdfront_receive(files[fd].kbd.dev, buf, n);
+            ret = kbdfront_receive(files[fd].dev, buf, n);
 	    if (ret <= 0) {
 		errno = EAGAIN;
 		return -1;
@@ -474,7 +474,7 @@ int close(int fd)
 #endif
 #ifdef CONFIG_KBDFRONT
 	case FTYPE_KBD:
-            shutdown_kbdfront(files[fd].kbd.dev);
+            shutdown_kbdfront(files[fd].dev);
             files[fd].type = FTYPE_NONE;
             return 0;
 #endif
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:06:58 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:06:58 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255808.438565 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ijh-0003qR-Cs; Tue, 11 Jan 2022 15:06:57 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255808.438565; Tue, 11 Jan 2022 15:06:57 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ijh-0003qK-9f; Tue, 11 Jan 2022 15:06:57 +0000
Received: by outflank-mailman (input) for mailman id 255808;
 Tue, 11 Jan 2022 15:06:56 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ibb-0002Oa-DX
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:35 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ec17fb13-72ee-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 15:58:23 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 8B8721F3BF;
 Tue, 11 Jan 2022 14:58:21 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 60D931403F;
 Tue, 11 Jan 2022 14:58:21 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id cCpeFg2b3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:21 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ec17fb13-72ee-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913101; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=TCkN47zI3SYm+mHMLDmij+4Y00VWhhcxxyZlFlzzdgc=;
	b=OUTHaG7Za4OLcRVER+k9rsHzA3tJlldnWMM3DF4J9ecUKfFu3136R9mIRg4FghLkU13SvK
	uzc8EpFlxNG/8ZCXTvffr6d1eGq/uWfwpHHKPTcQLAuUO/910sYhoQSv4j9XwZ5PKLNP7i
	LfwrwgrT9OKljA6xK+yV5nNXDk3W3WA=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 08/18] mini-os: eliminate fbfront union member in struct file
Date: Tue, 11 Jan 2022 15:58:07 +0100
Message-Id: <20220111145817.22170-9-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the fbfront specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 fbfront.c     | 2 +-
 include/lib.h | 3 ---
 lib/sys.c     | 4 ++--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fbfront.c b/fbfront.c
index 6725da1..c8410af 100644
--- a/fbfront.c
+++ b/fbfront.c
@@ -703,7 +703,7 @@ int fbfront_open(struct fbfront_dev *dev)
 {
     dev->fd = alloc_fd(FTYPE_FB);
     printk("fb_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].fb.dev = dev;
+    files[dev->fd].dev = dev;
     return dev->fd;
 }
 #endif
diff --git a/include/lib.h b/include/lib.h
index 0cedae6..2a9a01c 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -199,9 +199,6 @@ struct file {
 	struct {
 	    struct kbdfront_dev *dev;
 	} kbd;
-	struct {
-	    struct fbfront_dev *dev;
-	} fb;
 #ifdef CONFIG_TPMFRONT
 	struct {
 	   struct tpmfront_dev *dev;
diff --git a/lib/sys.c b/lib/sys.c
index 62c2020..2d48657 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -287,7 +287,7 @@ int read(int fd, void *buf, size_t nbytes)
         case FTYPE_FB: {
             int ret, n;
             n = nbytes / sizeof(union xenfb_in_event);
-            ret = fbfront_receive(files[fd].fb.dev, buf, n);
+            ret = fbfront_receive(files[fd].dev, buf, n);
 	    if (ret <= 0) {
 		errno = EAGAIN;
 		return -1;
@@ -480,7 +480,7 @@ int close(int fd)
 #endif
 #ifdef CONFIG_FBFRONT
 	case FTYPE_FB:
-            shutdown_fbfront(files[fd].fb.dev);
+            shutdown_fbfront(files[fd].dev);
             files[fd].type = FTYPE_NONE;
             return 0;
 #endif
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:07:26 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:07:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255813.438569 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IkA-0003wa-GO; Tue, 11 Jan 2022 15:07:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255813.438569; Tue, 11 Jan 2022 15:07:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IkA-0003wT-DH; Tue, 11 Jan 2022 15:07:26 +0000
Received: by outflank-mailman (input) for mailman id 255813;
 Tue, 11 Jan 2022 15:07:25 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7IbZ-0002OZ-E6
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:33 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id ec22a130-72ee-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 15:58:23 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 525AD212CC;
 Tue, 11 Jan 2022 14:58:22 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2A2A313DDD;
 Tue, 11 Jan 2022 14:58:22 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id kPEGCQ6b3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:22 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ec22a130-72ee-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913102; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=bYu3u434xIrAQdgw8rYV9Jpr+7UfDsZfUtYVg6rlj/g=;
	b=J3rgPmuEtBeQvoQJca4UnYfrUOjV1xo9h6RDBETYShjI5hzhYdMG/c270TX5v9LPhSMqDM
	YL2NDZPvYuGIGysONZxLf7UT5uhAl+sjK0zISGCk+LQDI/+7r4wlKjIoqori+NZw5uKQqi
	cX5wL7HX68hb4SvSod2FFS0SUVnIZF8=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 12/18] mini-os: eliminate tpmfront union member in struct file
Date: Tue, 11 Jan 2022 15:58:11 +0100
Message-Id: <20220111145817.22170-13-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the tpmfront specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 include/lib.h | 5 -----
 lib/sys.c     | 2 +-
 tpmfront.c    | 8 ++++----
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index d740065..2ddc076 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -193,11 +193,6 @@ struct file {
 	    struct evtchn_port_list ports;
 	} evtchn;
 	struct gntmap gntmap;
-#ifdef CONFIG_TPMFRONT
-	struct {
-	   struct tpmfront_dev *dev;
-	} tpmfront;
-#endif
 #ifdef CONFIG_TPM_TIS
 	struct {
 	   struct tpm_chip *dev;
diff --git a/lib/sys.c b/lib/sys.c
index b35e433..b042bf5 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -462,7 +462,7 @@ int close(int fd)
 #endif
 #ifdef CONFIG_TPMFRONT
 	case FTYPE_TPMFRONT:
-            shutdown_tpmfront(files[fd].tpmfront.dev);
+            shutdown_tpmfront(files[fd].dev);
 	    files[fd].type = FTYPE_NONE;
 	    return 0;
 #endif
diff --git a/tpmfront.c b/tpmfront.c
index be671c2..0a2fefc 100644
--- a/tpmfront.c
+++ b/tpmfront.c
@@ -538,7 +538,7 @@ int tpmfront_open(struct tpmfront_dev* dev)
 
    dev->fd = alloc_fd(FTYPE_TPMFRONT);
    printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
-   files[dev->fd].tpmfront.dev = dev;
+   files[dev->fd].dev = dev;
    dev->respgot = false;
    return dev->fd;
 }
@@ -547,7 +547,7 @@ int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count)
 {
    int rc;
    struct tpmfront_dev* dev;
-   dev = files[fd].tpmfront.dev;
+   dev = files[fd].dev;
 
    if(count == 0) {
       return 0;
@@ -573,7 +573,7 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
    size_t dummysz;
    struct tpmfront_dev* dev;
 
-   dev = files[fd].tpmfront.dev;
+   dev = files[fd].dev;
 
    if(count == 0) {
       return 0;
@@ -606,7 +606,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
    uint8_t* dummybuf;
    size_t dummysz;
    int rc;
-   struct tpmfront_dev* dev = files[fd].tpmfront.dev;
+   struct tpmfront_dev* dev = files[fd].dev;
 
    /* If we have a response waiting, then read it now from the backend
     * so we can get its length*/
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:07:28 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:07:28 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255814.438573 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IkC-0003z3-Hr; Tue, 11 Jan 2022 15:07:28 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255814.438573; Tue, 11 Jan 2022 15:07:28 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IkC-0003yw-Et; Tue, 11 Jan 2022 15:07:28 +0000
Received: by outflank-mailman (input) for mailman id 255814;
 Tue, 11 Jan 2022 15:07:26 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7IbZ-0002Oa-DI
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:33 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ea895f7d-72ee-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 15:58:22 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 5D9031F3B9;
 Tue, 11 Jan 2022 14:58:20 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3681613DDD;
 Tue, 11 Jan 2022 14:58:20 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id AJUxDAyb3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:20 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ea895f7d-72ee-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913100; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=vzZzmPAjeVTU9pmfwYUWWND13ROdq/Dkiqf1Bikl8LY=;
	b=CQ7U6vS/PPESmcmYahKPhyhfyfDP9ZdiGATPqxGYb8u8pYMiD9FR3EZ70b2H41lPOyDFFt
	yHK1EnEMmR/k7RQQqVThpgoBFsBu9iLjCIq2UmPU2gfy/Qi42ajnUJDzm9vlT2XUCpfMtd
	V/RiFJrKrzqNiKcye5i6wKu2DkgQiwQ=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 02/18] mini-os: makes file.read bool and move it ahead of device specific part
Date: Tue, 11 Jan 2022 15:58:01 +0100
Message-Id: <20220111145817.22170-3-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

The read member of struct file should be bool.

In order to have the device specific part at the end of the structure
move "read" ahead of that.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 blkfront.c             |  4 ++--
 console/xencons_ring.c |  2 +-
 fbfront.c              | 12 ++++++------
 include/lib.h          |  3 ++-
 netfront.c             |  4 ++--
 tpm_tis.c              |  2 +-
 tpmfront.c             |  6 +++---
 7 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/blkfront.c b/blkfront.c
index 834a978..7c8eb74 100644
--- a/blkfront.c
+++ b/blkfront.c
@@ -62,7 +62,7 @@ void blkfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
     int fd = dev->fd;
 
     if (fd != -1)
-        files[fd].read = 1;
+        files[fd].read = true;
 #endif
     wake_up(&blkfront_queue);
 }
@@ -484,7 +484,7 @@ int blkfront_aio_poll(struct blkfront_dev *dev)
 moretodo:
 #ifdef HAVE_LIBC
     if (dev->fd != -1) {
-        files[dev->fd].read = 0;
+        files[dev->fd].read = false;
         mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
     }
 #endif
diff --git a/console/xencons_ring.c b/console/xencons_ring.c
index b6db74e..c348f3c 100644
--- a/console/xencons_ring.c
+++ b/console/xencons_ring.c
@@ -102,7 +102,7 @@ void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data)
         int fd = dev ? dev->fd : -1;
 
         if (fd != -1)
-            files[fd].read = 1;
+            files[fd].read = true;
 
         wake_up(&console_queue);
 #else
diff --git a/fbfront.c b/fbfront.c
index d3b3848..6725da1 100644
--- a/fbfront.c
+++ b/fbfront.c
@@ -45,7 +45,7 @@ void kbdfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
     int fd = dev->fd;
 
     if (fd != -1)
-        files[fd].read = 1;
+        files[fd].read = true;
 #endif
     wake_up(&kbdfront_queue);
 }
@@ -207,7 +207,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
 
 #ifdef HAVE_LIBC
     if (dev->fd != -1) {
-        files[dev->fd].read = 0;
+        files[dev->fd].read = false;
         mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
     }
 #endif
@@ -229,7 +229,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
 #ifdef HAVE_LIBC
     if (cons != prod && dev->fd != -1)
         /* still some events to read */
-        files[dev->fd].read = 1;
+        files[dev->fd].read = true;
 #endif
 
     return i;
@@ -349,7 +349,7 @@ void fbfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
     int fd = dev->fd;
 
     if (fd != -1)
-        files[fd].read = 1;
+        files[fd].read = true;
 #endif
     wake_up(&fbfront_queue);
 }
@@ -376,7 +376,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
 
 #ifdef HAVE_LIBC
     if (dev->fd != -1) {
-        files[dev->fd].read = 0;
+        files[dev->fd].read = false;
         mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
     }
 #endif
@@ -398,7 +398,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
 #ifdef HAVE_LIBC
     if (cons != prod && dev->fd != -1)
         /* still some events to read */
-        files[dev->fd].read = 1;
+        files[dev->fd].read = true;
 #endif
 
     return i;
diff --git a/include/lib.h b/include/lib.h
index a638bc9..df2de9e 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -49,6 +49,7 @@
 #define _LIB_H_
 
 #include <stdarg.h>
+#include <stdbool.h>
 #include <stddef.h>
 #include <xen/xen.h>
 #include <xen/event_channel.h>
@@ -183,6 +184,7 @@ struct evtchn_port_info {
 
 struct file {
     enum fd_type type;
+    bool read;	/* maybe available for read */
     union {
 	struct {
             /* lwIP fd */
@@ -235,7 +237,6 @@ struct file {
         } xenbus;
 #endif
     };
-    int read;	/* maybe available for read */
 };
 
 extern struct file files[];
diff --git a/netfront.c b/netfront.c
index dfe065b..a566e34 100644
--- a/netfront.c
+++ b/netfront.c
@@ -255,7 +255,7 @@ void netfront_select_handler(evtchn_port_t port, struct pt_regs *regs, void *dat
     local_irq_restore(flags);
 
     if (fd != -1)
-        files[fd].read = 1;
+        files[fd].read = true;
     wake_up(&netfront_queue);
 }
 #endif
@@ -783,7 +783,7 @@ ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t l
     network_rx(dev);
     if (!dev->rlen && fd != -1)
         /* No data for us, make select stop returning */
-        files[fd].read = 0;
+        files[fd].read = false;
     /* Before re-enabling the interrupts, in case a packet just arrived in the
      * meanwhile. */
     local_irq_restore(flags);
diff --git a/tpm_tis.c b/tpm_tis.c
index 475ac5d..4a51027 100644
--- a/tpm_tis.c
+++ b/tpm_tis.c
@@ -845,7 +845,7 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
    }
 #ifdef HAVE_LIBC
    if(tpm->fd >= 0) {
-      files[tpm->fd].read = 0;
+      files[tpm->fd].read = false;
       files[tpm->fd].tpm_tis.respgot = 0;
       files[tpm->fd].tpm_tis.offset = 0;
    }
diff --git a/tpmfront.c b/tpmfront.c
index 6049244..d825b49 100644
--- a/tpmfront.c
+++ b/tpmfront.c
@@ -66,7 +66,7 @@ void tpmfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) {
    dev->waiting = 0;
 #ifdef HAVE_LIBC
    if(dev->fd >= 0) {
-      files[dev->fd].read = 1;
+      files[dev->fd].read = true;
    }
 #endif
    wake_up(&dev->waitq);
@@ -438,7 +438,7 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
    dev->resplen = 0;
 #ifdef HAVE_LIBC
    if(dev->fd >= 0) {
-      files[dev->fd].read = 0;
+      files[dev->fd].read = false;
       files[dev->fd].tpmfront.respgot = 0;
       files[dev->fd].tpmfront.offset = 0;
    }
@@ -611,7 +611,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
 
    /* If we have a response waiting, then read it now from the backend
     * so we can get its length*/
-   if(dev->waiting || (files[dev->fd].read == 1 && !files[dev->fd].tpmfront.respgot)) {
+   if(dev->waiting || (files[dev->fd].read && !files[dev->fd].tpmfront.respgot)) {
       if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
 	 errno = EIO;
 	 return -1;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:08:25 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:08:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255822.438599 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Il7-0005CC-4Y; Tue, 11 Jan 2022 15:08:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255822.438599; Tue, 11 Jan 2022 15:08:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Il7-0005C5-1f; Tue, 11 Jan 2022 15:08:25 +0000
Received: by outflank-mailman (input) for mailman id 255822;
 Tue, 11 Jan 2022 15:08:24 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ibd-0002Oa-Dy
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:37 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ec28f894-72ee-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 15:58:23 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 7F4EF212FE;
 Tue, 11 Jan 2022 14:58:22 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 57EB513DDD;
 Tue, 11 Jan 2022 14:58:22 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 8ChLFA6b3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:22 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ec28f894-72ee-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913102; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=KvYWbjQdT5GoXtl6mz9SWgGWXv1kuFR3GbeV+mNScb0=;
	b=G5OptETgBTozBz2qWhqOixO5JISC2ALgWTGURLKUH6TNPZ/TK9D7pF1bqPq4UUBseMmSSu
	gsXy9+5mgYmu1NDAkInUF6fBIyqoUcAwHtU7cKZQoEQ4KJFY9bqhgpMmi1x40j0szk1Fm7
	0q7+NhNaWmWlQIgpZe7ICP/FqoBE5kI=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 13/18] mini-os: eliminate tpmtis union member in struct file
Date: Tue, 11 Jan 2022 15:58:12 +0100
Message-Id: <20220111145817.22170-14-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the tpmtis specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 include/lib.h | 5 -----
 lib/sys.c     | 2 +-
 tpm_tis.c     | 8 ++++----
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 2ddc076..d6a29ba 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -193,11 +193,6 @@ struct file {
 	    struct evtchn_port_list ports;
 	} evtchn;
 	struct gntmap gntmap;
-#ifdef CONFIG_TPM_TIS
-	struct {
-	   struct tpm_chip *dev;
-	} tpm_tis;
-#endif
 #ifdef CONFIG_XENBUS
         struct {
             /* To each xenbus FD is associated a queue of watch events for this
diff --git a/lib/sys.c b/lib/sys.c
index b042bf5..96fc769 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -468,7 +468,7 @@ int close(int fd)
 #endif
 #ifdef CONFIG_TPM_TIS
 	case FTYPE_TPM_TIS:
-            shutdown_tpm_tis(files[fd].tpm_tis.dev);
+            shutdown_tpm_tis(files[fd].dev);
 	    files[fd].type = FTYPE_NONE;
 	    return 0;
 #endif
diff --git a/tpm_tis.c b/tpm_tis.c
index 4127118..477f555 100644
--- a/tpm_tis.c
+++ b/tpm_tis.c
@@ -1288,14 +1288,14 @@ int tpm_tis_open(struct tpm_chip* tpm)
 
    tpm->fd = alloc_fd(FTYPE_TPM_TIS);
    printk("tpm_tis_open() -> %d\n", tpm->fd);
-   files[tpm->fd].tpm_tis.dev = tpm;
+   files[tpm->fd].dev = tpm;
    return tpm->fd;
 }
 
 int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count)
 {
    struct tpm_chip* tpm;
-   tpm = files[fd].tpm_tis.dev;
+   tpm = files[fd].dev;
 
    if(tpm->locality < 0) {
       printk("tpm_tis_posix_write() failed! locality not set!\n");
@@ -1323,7 +1323,7 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
 {
    int rc;
    struct tpm_chip* tpm;
-   tpm = files[fd].tpm_tis.dev;
+   tpm = files[fd].dev;
 
    if(count == 0) {
       return 0;
@@ -1350,7 +1350,7 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
 int tpm_tis_posix_fstat(int fd, struct stat* buf)
 {
    struct tpm_chip* tpm;
-   tpm = files[fd].tpm_tis.dev;
+   tpm = files[fd].dev;
 
    buf->st_mode = O_RDWR;
    buf->st_uid = 0;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:08:51 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:08:51 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255825.438613 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IlX-0005qt-Ih; Tue, 11 Jan 2022 15:08:51 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255825.438613; Tue, 11 Jan 2022 15:08:51 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IlX-0005qm-Fm; Tue, 11 Jan 2022 15:08:51 +0000
Received: by outflank-mailman (input) for mailman id 255825;
 Tue, 11 Jan 2022 15:08:50 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ibd-0002OZ-Eb
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:37 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id ec38fac3-72ee-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 15:58:23 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id ADCAD21637;
 Tue, 11 Jan 2022 14:58:22 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8537013DDD;
 Tue, 11 Jan 2022 14:58:22 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 4OZLHw6b3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:22 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ec38fac3-72ee-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913102; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=n40BkLdnJT4X941oqOUKglJdlkxVA0w5hYfz6J0OaY8=;
	b=ZjfrY70i0Pbr4czUKwgXjbY1iNrCDw3Vx6pB0YdsaGN7XkJEQRb6KDvlppTR00fiMkgicg
	b96gcYYWqzLUeAJWntujpY/xohdNP0T70OPGYx0tVAzuIvA29EQPP9efelRGjtJfBy8EA8
	R3CGUCNryEYA3V2yaKv5C6rJtjM1OBk=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 14/18] mini-os: eliminate xenbus union member in struct file
Date: Tue, 11 Jan 2022 15:58:13 +0100
Message-Id: <20220111145817.22170-15-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Replace the xenbus specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 include/lib.h |  7 -------
 lib/sys.c     |  2 +-
 lib/xs.c      | 13 +++++++------
 3 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index d6a29ba..91364ba 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -193,13 +193,6 @@ struct file {
 	    struct evtchn_port_list ports;
 	} evtchn;
 	struct gntmap gntmap;
-#ifdef CONFIG_XENBUS
-        struct {
-            /* To each xenbus FD is associated a queue of watch events for this
-             * FD.  */
-            xenbus_event_queue events;
-        } xenbus;
-#endif
     };
 };
 
diff --git a/lib/sys.c b/lib/sys.c
index 96fc769..6f2b026 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -776,7 +776,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 #ifdef CONFIG_XENBUS
 	case FTYPE_XENBUS:
 	    if (FD_ISSET(i, readfds)) {
-                if (files[i].xenbus.events)
+                if (files[i].dev)
 		    n++;
 		else
 		    FD_CLR(i, readfds);
diff --git a/lib/xs.c b/lib/xs.c
index 324bd05..0459f52 100644
--- a/lib/xs.c
+++ b/lib/xs.c
@@ -21,8 +21,8 @@ static inline int _xs_fileno(struct xs_handle *h) {
 struct xs_handle *xs_daemon_open()
 {
     int fd = alloc_fd(FTYPE_XENBUS);
-    files[fd].xenbus.events = NULL;
-    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].xenbus.events);
+    files[fd].dev = NULL;
+    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].dev);
     return (void*)(intptr_t) fd;
 }
 
@@ -30,7 +30,7 @@ void xs_daemon_close(struct xs_handle *h)
 {
     int fd = _xs_fileno(h);
     struct xenbus_event *event, *next;
-    for (event = files[fd].xenbus.events; event; event = next)
+    for (event = files[fd].dev; event; event = next)
     {
         next = event->next;
         free(event);
@@ -172,15 +172,16 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)
 {
     int fd = _xs_fileno(h);
     printk("xs_watch(%s, %s)\n", path, token);
-    return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token, &files[fd].xenbus.events));
+    return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token,
+                   (xenbus_event_queue *)&files[fd].dev));
 }
 
 char **xs_read_watch(struct xs_handle *h, unsigned int *num)
 {
     int fd = _xs_fileno(h);
     struct xenbus_event *event;
-    event = files[fd].xenbus.events;
-    files[fd].xenbus.events = event->next;
+    event = files[fd].dev;
+    files[fd].dev = event->next;
     printk("xs_read_watch() -> %s %s\n", event->path, event->token);
     *num = 2;
     return (char **) &event->path;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:09:06 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:09:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255830.438629 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ilm-0006Jn-UA; Tue, 11 Jan 2022 15:09:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255830.438629; Tue, 11 Jan 2022 15:09:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ilm-0006Jf-QT; Tue, 11 Jan 2022 15:09:06 +0000
Received: by outflank-mailman (input) for mailman id 255830;
 Tue, 11 Jan 2022 15:09:05 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ibf-0002Oa-EC
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:39 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ec3e09a2-72ee-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 15:58:23 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id DAF8921639;
 Tue, 11 Jan 2022 14:58:22 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B2F4A13DDD;
 Tue, 11 Jan 2022 14:58:22 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id SEeCKg6b3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:22 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ec3e09a2-72ee-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913102; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=C9AyKNzGKENy2BPxgLKGB+hFKK51Mm2oD341mOYK6aA=;
	b=R0GKkNi+dhG4W5lbRM9+2Frk+rVnQIdIdPOS8v8+F5cg1HTIkgQ6Y2/3UjnpFCRPAvzP5m
	B9FDuzQpDzsnvybo9xP0Yqg7Jru3vd1W3D73Ff6vapQ7YP1JmJxUeMmNHTjZs94re/0DP5
	8Q+Wk/oJuwX3UQnpVGwHfiG/VouWXf8=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 15/18] mini-os: introduce get_file_from_fd()
Date: Tue, 11 Jan 2022 15:58:14 +0100
Message-Id: <20220111145817.22170-16-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Exporting the files[] array especially for components outside the
mini-os source tree is limiting the ability to change any file handling
in mini-os.

Introduce a new function get_file_from_fd() to return the struct file
pointer (or NULL) for a given file descriptor.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 include/lib.h | 1 +
 lib/sys.c     | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/include/lib.h b/include/lib.h
index 91364ba..7a0546b 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -198,6 +198,7 @@ struct file {
 
 extern struct file files[];
 
+struct file *get_file_from_fd(int fd);
 int alloc_fd(enum fd_type type);
 void close_all_files(void);
 extern struct thread *main_thread;
diff --git a/lib/sys.c b/lib/sys.c
index 6f2b026..0e6fe5d 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -98,6 +98,14 @@ struct file files[NOFILE] = {
     { .type = FTYPE_CONSOLE }, /* stderr */
 };
 
+struct file *get_file_from_fd(int fd)
+{
+    if ( fd < 0 || fd >= NOFILE )
+        return NULL;
+
+    return (files[fd].type == FTYPE_NONE) ? NULL : files + fd;
+}
+
 DECLARE_WAIT_QUEUE_HEAD(event_queue);
 
 int alloc_fd(enum fd_type type)
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:09:41 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:09:41 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255841.438655 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7ImL-0007QS-H2; Tue, 11 Jan 2022 15:09:41 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255841.438655; Tue, 11 Jan 2022 15:09:41 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7ImL-0007QH-Dg; Tue, 11 Jan 2022 15:09:41 +0000
Received: by outflank-mailman (input) for mailman id 255841;
 Tue, 11 Jan 2022 15:09:40 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ibh-0002Oa-EK
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:41 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ec45faef-72ee-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 15:58:23 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 476361F3BB;
 Tue, 11 Jan 2022 14:58:23 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1B56813DDD;
 Tue, 11 Jan 2022 14:58:23 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 2Jl+BQ+b3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:23 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ec45faef-72ee-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913103; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=LhH/Bo3lirfkf7NoVUI5lwaB8z0a64DTHY6OLddxQ6Q=;
	b=N0yIni7CUgPltcFS9sVSL589r0Kj+q5S/ADpIDzeweucEGAEh95WRb6hVaOCFkGNvGKyMo
	GVSiEJ0yZ6jqAnsDEtRT39cSKfH7pD5P21357Md51nDjxBhuWFvRxsmHsPGLSgxXjyOg5T
	GJyQlwHB1lVrXjMeIUz3gngOpJs3REc=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 17/18] mini-os: use function vectors instead of switch for file operations
Date: Tue, 11 Jan 2022 15:58:16 +0100
Message-Id: <20220111145817.22170-18-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Introduce file type specific function vectors for all the needed file
operations which are file type specific in order to prepare replacing
the large switch statements in each generic file function.

Add a function to allocate a new file type dynamically in order to
prepare removing direct dependencies to external components in the
future. For this reason switch the file type from an enum to an
unsigned int. Prepare removal of some statically defines file types
by putting them at the end of the defined list.

Change the debug output for the file type from a single character to
a string in order to support a future removal of the file_types[]
array.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V2:
- new patch
---
 include/lib.h |  65 +++++++++++-----
 lib/sys.c     | 208 +++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 217 insertions(+), 56 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 7a0546b..b40e213 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -66,6 +66,7 @@
 
 #ifdef HAVE_LIBC
 #include <sys/queue.h>
+#include <sys/stat.h>
 #include <stdio.h>
 #include <string.h>
 #else
@@ -154,25 +155,51 @@ do {                                                           \
 void sanity_check(void);
 
 #ifdef HAVE_LIBC
-enum fd_type {
-    FTYPE_NONE = 0,
-    FTYPE_CONSOLE,
-    FTYPE_FILE,
-    FTYPE_XENBUS,
-    FTYPE_XC,
-    FTYPE_EVTCHN,
-    FTYPE_GNTMAP,
-    FTYPE_SOCKET,
-    FTYPE_TAP,
-    FTYPE_BLK,
-    FTYPE_KBD,
-    FTYPE_FB,
-    FTYPE_MEM,
-    FTYPE_SAVEFILE,
-    FTYPE_TPMFRONT,
-    FTYPE_TPM_TIS,
+#define FTYPE_NONE       0
+#define FTYPE_CONSOLE    1
+#define FTYPE_FILE       2
+#define FTYPE_SOCKET     3
+#define FTYPE_MEM        4
+#define FTYPE_SAVEFILE   5
+#define FTYPE_FB         6
+#define FTYPE_KBD        7
+#define FTYPE_TAP        8
+#define FTYPE_BLK        9
+#define FTYPE_TPMFRONT  10
+#define FTYPE_TPM_TIS   11
+#define FTYPE_XENBUS    12
+#define FTYPE_GNTMAP    13
+#define FTYPE_EVTCHN    14
+#define FTYPE_XC        15
+#define FTYPE_N         16
+#define FTYPE_SPARE     16
+
+typedef int file_read_func(int fd, void *buf, size_t nbytes);
+typedef int file_write_func(int fd, const void *buf, size_t nbytes);
+typedef off_t file_lseek_func(int fd, off_t offset, int whence);
+typedef int file_close_func(int fd);
+typedef int file_fstat_func(int fd, struct stat *buf);
+typedef int file_fcntl_func(int fd, int cmd, va_list args);
+typedef bool file_select_func(int fd);
+
+struct file_ops {
+    const char *name;
+    file_read_func *read;
+    file_write_func *write;
+    file_lseek_func *lseek;
+    file_close_func *close;
+    file_fstat_func *fstat;
+    file_fcntl_func *fcntl;
+    file_select_func *select_rd;
+    file_select_func *select_wr;
 };
 
+unsigned int alloc_file_type(struct file_ops *ops);
+
+off_t lseek_default(int fd, off_t offset, int whence);
+bool select_yes(int fd);
+bool select_read_flag(int fd);
+
 LIST_HEAD(evtchn_port_list, evtchn_port_info);
 
 struct evtchn_port_info {
@@ -183,7 +210,7 @@ struct evtchn_port_info {
 };
 
 struct file {
-    enum fd_type type;
+    unsigned int type;
     bool read;	/* maybe available for read */
     off_t offset;
     union {
@@ -199,7 +226,7 @@ struct file {
 extern struct file files[];
 
 struct file *get_file_from_fd(int fd);
-int alloc_fd(enum fd_type type);
+int alloc_fd(unsigned int type);
 void close_all_files(void);
 extern struct thread *main_thread;
 void sparse(unsigned long data, size_t size);
diff --git a/lib/sys.c b/lib/sys.c
index 323a7cd..c327247 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -98,6 +98,39 @@ struct file files[NOFILE] = {
     { .type = FTYPE_CONSOLE }, /* stderr */
 };
 
+static struct file_ops file_ops_none = {
+    .name = "none",
+};
+
+static struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
+    [FTYPE_NONE] = &file_ops_none,
+};
+
+unsigned int alloc_file_type(struct file_ops *ops)
+{
+    unsigned int i;
+
+    pthread_mutex_lock(&fd_lock);
+
+    for ( i = FTYPE_N; i < ARRAY_SIZE(file_ops) && file_ops[i]; i++ );
+    BUG_ON(i == ARRAY_SIZE(file_ops));
+    file_ops[i] = ops;
+
+    pthread_mutex_unlock(&fd_lock);
+
+    printk("New file type \"%s\"(%u) allocated\n", ops->name, i);
+
+    return i;
+}
+
+static struct file_ops *get_file_ops(unsigned int type)
+{
+    if ( type >= ARRAY_SIZE(file_ops) || !file_ops[type] )
+        return &file_ops_none;
+
+    return file_ops[type];
+}
+
 struct file *get_file_from_fd(int fd)
 {
     if ( fd < 0 || fd >= NOFILE )
@@ -108,7 +141,7 @@ struct file *get_file_from_fd(int fd)
 
 DECLARE_WAIT_QUEUE_HEAD(event_queue);
 
-int alloc_fd(enum fd_type type)
+int alloc_fd(unsigned int type)
 {
     int i;
     pthread_mutex_lock(&fd_lock);
@@ -249,6 +282,11 @@ int isatty(int fd)
 
 int read(int fd, void *buf, size_t nbytes)
 {
+    struct file_ops *ops = get_file_ops(files[fd].type);
+
+    if ( ops->read )
+        return ops->read(fd, buf, nbytes);
+
     switch (files[fd].type) {
         case FTYPE_SAVEFILE:
 	case FTYPE_CONSOLE: {
@@ -328,6 +366,11 @@ int read(int fd, void *buf, size_t nbytes)
 
 int write(int fd, const void *buf, size_t nbytes)
 {
+    struct file_ops *ops = get_file_ops(files[fd].type);
+
+    if ( ops->write )
+        return ops->write(fd, buf, nbytes);
+
     switch (files[fd].type) {
         case FTYPE_SAVEFILE: {
                 int ret = 0, tot = nbytes;
@@ -370,8 +413,45 @@ int write(int fd, const void *buf, size_t nbytes)
     return -1;
 }
 
+off_t lseek_default(int fd, off_t offset, int whence)
+{
+    switch ( whence )
+    {
+    case SEEK_SET:
+        files[fd].offset = offset;
+        break;
+
+    case SEEK_CUR:
+        files[fd].offset += offset;
+        break;
+
+    case SEEK_END:
+    {
+        struct stat st;
+        int ret;
+
+        ret = fstat(fd, &st);
+        if ( ret )
+            return -1;
+        files[fd].offset = st.st_size + offset;
+        break;
+    }
+
+    default:
+        errno = EINVAL;
+        return -1;
+    }
+
+    return files[fd].offset;
+}
+
 off_t lseek(int fd, off_t offset, int whence)
 {
+    struct file_ops *ops = get_file_ops(files[fd].type);
+
+    if ( ops->lseek )
+        return ops->lseek(fd, offset, whence);
+
     switch(files[fd].type) {
 #ifdef CONFIG_BLKFRONT
        case FTYPE_BLK:
@@ -393,28 +473,7 @@ off_t lseek(int fd, off_t offset, int whence)
           return (off_t) -1;
     }
 
-    switch (whence) {
-       case SEEK_SET:
-          files[fd].offset = offset;
-          break;
-       case SEEK_CUR:
-          files[fd].offset += offset;
-          break;
-       case SEEK_END:
-          {
-             struct stat st;
-             int ret;
-             ret = fstat(fd, &st);
-             if (ret)
-                return -1;
-             files[fd].offset = st.st_size + offset;
-             break;
-          }
-       default:
-          errno = EINVAL;
-          return -1;
-    }
-    return files[fd].offset;
+    return lseek_default(fd, offset, whence);
 }
 
 int fsync(int fd) {
@@ -425,8 +484,15 @@ int fsync(int fd) {
 int close(int fd)
 {
     int res = 0;
+    struct file_ops *ops = get_file_ops(files[fd].type);
 
     printk("close(%d)\n", fd);
+    if ( ops->close )
+    {
+        res = ops->close(fd);
+        goto out;
+    }
+
     switch (files[fd].type) {
         default:
             break;
@@ -497,6 +563,7 @@ int close(int fd)
             return -1;
     }
 
+ out:
     memset(files + fd, 0, sizeof(struct file));
     files[fd].type = FTYPE_NONE;
     return res;
@@ -521,7 +588,13 @@ int stat(const char *path, struct stat *buf)
 
 int fstat(int fd, struct stat *buf)
 {
+    struct file_ops *ops = get_file_ops(files[fd].type);
+
     init_stat(buf);
+
+    if ( ops->fstat )
+        return ops->fstat(fd, buf);
+
     switch (files[fd].type) {
 	case FTYPE_SAVEFILE:
 	case FTYPE_CONSOLE:
@@ -587,6 +660,18 @@ int fcntl(int fd, int cmd, ...)
 {
     long arg;
     va_list ap;
+    int res;
+    struct file_ops *ops = get_file_ops(files[fd].type);
+
+    if ( ops->fcntl )
+    {
+        va_start(ap, cmd);
+        res = ops->fcntl(fd, cmd, ap);
+        va_end(ap);
+
+        return res;
+    }
+
     va_start(ap, cmd);
     arg = va_arg(ap, long);
     va_end(ap);
@@ -640,18 +725,29 @@ int closedir(DIR *dir)
 /* We assume that only the main thread calls select(). */
 
 #if defined(LIBC_DEBUG) || defined(LIBC_VERBOSE)
-static const char file_types[] = {
-    [FTYPE_NONE]	= 'N',
-    [FTYPE_CONSOLE]	= 'C',
-    [FTYPE_XENBUS]	= 'S',
-    [FTYPE_XC]		= 'X',
-    [FTYPE_EVTCHN]	= 'E',
-    [FTYPE_SOCKET]	= 's',
-    [FTYPE_TAP]		= 'T',
-    [FTYPE_BLK]		= 'B',
-    [FTYPE_KBD]		= 'K',
-    [FTYPE_FB]		= 'G',
+static const char *file_types[] = {
+    [FTYPE_NONE]    = "none",
+    [FTYPE_CONSOLE] = "console",
+    [FTYPE_XENBUS]  = "xenbus",
+    [FTYPE_XC]      = "ctrl",
+    [FTYPE_EVTCHN]  = "evtchn",
+    [FTYPE_SOCKET]  = "socket",
+    [FTYPE_TAP]     = "net",
+    [FTYPE_BLK]     = "blk",
+    [FTYPE_KBD]     = "kbd",
+    [FTYPE_FB]      = "fb",
 };
+
+static char *get_type_name(unsigned int type)
+{
+    if ( type < ARRAY_SIZE(file_ops) && file_ops[type] )
+        return file_ops[type]->name;
+
+    if ( type < ARRAY_SIZE(file_types) && file_types[type] )
+        return file_types[type];
+
+    return "none";
+}
 #endif
 #ifdef LIBC_DEBUG
 static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
@@ -663,7 +759,7 @@ static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *except
 	if (FD_ISSET(i, set)) { \
 	    if (comma) \
 		printk(", "); \
-	    printk("%d(%c)", i, file_types[files[i].type]); \
+	    printk("%d(%s)", i, get_type_name(files[i].type)); \
 	    comma = 1; \
 	} \
     } \
@@ -697,7 +793,7 @@ static void dump_pollfds(struct pollfd *pfd, int nfds, int timeout)
         fd = pfd[i].fd;
         if (comma)
             printk(", ");
-        printk("%d(%c)/%02x", fd, file_types[files[fd].type],
+        printk("%d(%s)/%02x", fd, get_type_name(files[fd].type),
             pfd[i].events);
             comma = 1;
     }
@@ -709,6 +805,18 @@ static void dump_pollfds(struct pollfd *pfd, int nfds, int timeout)
 #define dump_pollfds(pfds, nfds, timeout)
 #endif
 
+bool select_yes(int fd)
+{
+    return true;
+}
+
+bool select_read_flag(int fd)
+{
+    struct file *file = get_file_from_fd(fd);
+
+    return file->read;
+}
+
 /* Just poll without blocking */
 static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
 {
@@ -762,9 +870,35 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
     for (i = 0; i < nfds; i++) {
 	switch(files[i].type) {
 	default:
+        {
+            struct file_ops *ops = file_ops[files[i].type];
+
+            if ( ops )
+            {
+                if ( FD_ISSET(i, readfds) )
+                {
+                    if ( ops->select_rd && ops->select_rd(i) )
+                        n++;
+                    else
+                        FD_CLR(i, readfds);
+                }
+                if ( FD_ISSET(i, writefds) )
+                {
+                    if ( ops->select_wr && ops->select_wr(i) )
+                        n++;
+                    else
+                        FD_CLR(i, writefds);
+                }
+	        FD_CLR(i, exceptfds);
+
+                break;
+            }
+
 	    if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
 		printk("bogus fd %d in select\n", i);
 	    /* Fallthrough.  */
+        }
+
 	case FTYPE_CONSOLE:
 	    if (FD_ISSET(i, readfds)) {
                 if (xencons_ring_avail(files[i].dev))
@@ -842,7 +976,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 	printk("%d(%d): ", nb, sock_n);
 	for (i = 0; i < nfds; i++) {
 	    if (nbread[i] || nbwrite[i] || nbexcept[i])
-		printk(" %d(%c):", i, file_types[files[i].type]);
+		printk(" %d(%c):", i, get_type_name(files[i].type));
 	    if (nbread[i])
 	    	printk(" %dR", nbread[i]);
 	    if (nbwrite[i])
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:09:44 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:09:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255843.438659 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7ImO-0007Xa-J3; Tue, 11 Jan 2022 15:09:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255843.438659; Tue, 11 Jan 2022 15:09:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7ImO-0007XT-FH; Tue, 11 Jan 2022 15:09:44 +0000
Received: by outflank-mailman (input) for mailman id 255843;
 Tue, 11 Jan 2022 15:09:43 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ibf-0002OZ-F5
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:39 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id ec5ddb25-72ee-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 15:58:23 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 75CCC212C3;
 Tue, 11 Jan 2022 14:58:23 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4E6D313DDD;
 Tue, 11 Jan 2022 14:58:23 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id cBnnEQ+b3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:23 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ec5ddb25-72ee-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913103; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=3MRu1fvGvRxSYETAwaGXHjdx6AuZiPRv8J9xLv9qXpA=;
	b=cE07+p9X7+a1mj4Yq/WttMObovohhvxLc1iNnnT+9yGsXpv/JCEv5uPOVrQkkzW+GVDEFD
	hHF+ZUGCyNqcCpqZuTDGXeowTB3PdeAJ6YPJvhD5e/ldwx7SRGZ5efDmP0zugqxIC+1crm
	4ANsHXOr9LvGgFLPD49G9lNF3CLgF48=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 18/18] mini-os: remove file type FTYPE_XC
Date: Tue, 11 Jan 2022 15:58:17 +0100
Message-Id: <20220111145817.22170-19-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

The only reason for the file type FTYPE_XC has been gone long time
ago: it was needed for xc_map_foreign_bulk(), which has been switched
to use libxenforeignmemory and doesn't need this special file any
more.

So remove everything related to FTYPE_XC.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V2:
- new patch
---
 Config.mk                     |  1 -
 arch/x86/testbuild/all-no     |  1 -
 arch/x86/testbuild/all-yes    |  1 -
 arch/x86/testbuild/newxen-yes |  1 -
 include/lib.h                 |  3 +--
 lib/sys.c                     | 13 -------------
 6 files changed, 1 insertion(+), 19 deletions(-)

diff --git a/Config.mk b/Config.mk
index 5e66089..1e08388 100644
--- a/Config.mk
+++ b/Config.mk
@@ -197,7 +197,6 @@ CONFIG-n += CONFIG_PARAVIRT
 endif
 # Support legacy CONFIG_XC value
 CONFIG_XC ?= $(libc)
-CONFIG-$(CONFIG_XC) += CONFIG_LIBXENCTRL
 CONFIG-$(CONFIG_XC) += CONFIG_LIBXENEVTCHN
 CONFIG-$(CONFIG_XC) += CONFIG_LIBXENGNTTAB
 
diff --git a/arch/x86/testbuild/all-no b/arch/x86/testbuild/all-no
index 7972ecd..d6fc260 100644
--- a/arch/x86/testbuild/all-no
+++ b/arch/x86/testbuild/all-no
@@ -13,7 +13,6 @@ CONFIG_FBFRONT = n
 CONFIG_KBDFRONT = n
 CONFIG_CONSFRONT = n
 CONFIG_XENBUS = n
-CONFIG_LIBXENCTRL = n
 CONFIG_LIBXENEVTCHN = n
 CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/arch/x86/testbuild/all-yes b/arch/x86/testbuild/all-yes
index bc8eea5..98bbfeb 100644
--- a/arch/x86/testbuild/all-yes
+++ b/arch/x86/testbuild/all-yes
@@ -16,7 +16,6 @@ CONFIG_XENBUS = y
 CONFIG_BALLOON = y
 CONFIG_USE_XEN_CONSOLE = y
 # The following are special: they need support from outside
-CONFIG_LIBXENCTRL = n
 CONFIG_LIBXENEVTCHN = n
 CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/arch/x86/testbuild/newxen-yes b/arch/x86/testbuild/newxen-yes
index f72123b..0603200 100644
--- a/arch/x86/testbuild/newxen-yes
+++ b/arch/x86/testbuild/newxen-yes
@@ -17,7 +17,6 @@ CONFIG_BALLOON = y
 CONFIG_USE_XEN_CONSOLE = y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
 # The following are special: they need support from outside
-CONFIG_LIBXENCTRL = n
 CONFIG_LIBXENEVTCHN = n
 CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/include/lib.h b/include/lib.h
index b40e213..4892320 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -170,8 +170,7 @@ void sanity_check(void);
 #define FTYPE_XENBUS    12
 #define FTYPE_GNTMAP    13
 #define FTYPE_EVTCHN    14
-#define FTYPE_XC        15
-#define FTYPE_N         16
+#define FTYPE_N         15
 #define FTYPE_SPARE     16
 
 typedef int file_read_func(int fd, void *buf, size_t nbytes);
diff --git a/lib/sys.c b/lib/sys.c
index c327247..52876e0 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -87,7 +87,6 @@
     }
 
 #define NOFILE 32
-extern void minios_interface_close_fd(int fd);
 extern void minios_evtchn_close_fd(int fd);
 extern void minios_gnttab_close_fd(int fd);
 
@@ -506,11 +505,6 @@ int close(int fd)
 	    res = lwip_close(files[fd].fd);
             break;
 #endif
-#ifdef CONFIG_LIBXENCTRL
-	case FTYPE_XC:
-	    minios_interface_close_fd(fd);
-            break;
-#endif
 #ifdef CONFIG_LIBXENEVTCHN
 	case FTYPE_EVTCHN:
 	    minios_evtchn_close_fd(fd);
@@ -729,7 +723,6 @@ static const char *file_types[] = {
     [FTYPE_NONE]    = "none",
     [FTYPE_CONSOLE] = "console",
     [FTYPE_XENBUS]  = "xenbus",
-    [FTYPE_XC]      = "ctrl",
     [FTYPE_EVTCHN]  = "evtchn",
     [FTYPE_SOCKET]  = "socket",
     [FTYPE_TAP]     = "net",
@@ -1510,12 +1503,6 @@ void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset
 
     if (fd == -1)
         return map_zero(n, 1);
-#ifdef CONFIG_LIBXENCTRL
-    else if (files[fd].type == FTYPE_XC) {
-        unsigned long zero = 0;
-        return map_frames_ex(&zero, n, 0, 0, 1, DOMID_SELF, NULL, 0);
-    }
-#endif
     else if (files[fd].type == FTYPE_MEM) {
         unsigned long first_mfn = offset >> PAGE_SHIFT;
         return map_frames_ex(&first_mfn, n, 0, 1, 1, DOMID_IO, NULL, _PAGE_PRESENT|_PAGE_RW);
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:09:54 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:09:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255847.438685 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7ImY-0008R1-7a; Tue, 11 Jan 2022 15:09:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255847.438685; Tue, 11 Jan 2022 15:09:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7ImY-0008Qs-3b; Tue, 11 Jan 2022 15:09:54 +0000
Received: by outflank-mailman (input) for mailman id 255847;
 Tue, 11 Jan 2022 15:09:52 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ibc-0002OZ-Ew
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:36 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id ec1fdd83-72ee-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 15:58:23 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 140D51F3B1;
 Tue, 11 Jan 2022 14:58:23 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E0D4013DDD;
 Tue, 11 Jan 2022 14:58:22 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id sJu6NQ6b3WH9eQAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 14:58:22 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ec1fdd83-72ee-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913103; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=knuLUyCcfoEXY1jmZHvU06lOttBFfXuiA3Ntm0yi0WI=;
	b=EFpQEMzDRCsLhCQBXwK2k2H3BhcEPZ6mVmlXCvtDA/t5hqCYWRSifDDghM0bRqeB/Qviyh
	226/HA9B/EhvS77A5nxG4pPc5UV+IDGh3+e2NK89RF4Bd1b3r8ng47I4kh+vQxhzdzkNbt
	nPZY+aEIcM6SVKcxKbIOD8iDXcpP6Ks=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 16/18] mini-os: reset file type in close() in one place only
Date: Tue, 11 Jan 2022 15:58:15 +0100
Message-Id: <20220111145817.22170-17-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
References: <20220111145817.22170-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Today the file type in struct file is set to FTYPE_NONE for each
file type individually. Do that at the end of close() handling for
all types.

While at it wipe the complete struct file, too, in order to avoid
old data creeping into a new allocated struct file.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V2:
- new patch
---
 lib/sys.c | 53 ++++++++++++++++++++++++-----------------------------
 lib/xs.c  |  1 -
 2 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/lib/sys.c b/lib/sys.c
index 0e6fe5d..323a7cd 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -424,87 +424,82 @@ int fsync(int fd) {
 
 int close(int fd)
 {
+    int res = 0;
+
     printk("close(%d)\n", fd);
     switch (files[fd].type) {
         default:
-	    files[fd].type = FTYPE_NONE;
-	    return 0;
+            break;
 #ifdef CONFIG_XENBUS
 	case FTYPE_XENBUS:
             xs_daemon_close((void*)(intptr_t) fd);
-            return 0;
+            break;
 #endif
 #ifdef HAVE_LWIP
-	case FTYPE_SOCKET: {
-	    int res = lwip_close(files[fd].fd);
-	    files[fd].type = FTYPE_NONE;
-	    return res;
-	}
+	case FTYPE_SOCKET:
+	    res = lwip_close(files[fd].fd);
+            break;
 #endif
 #ifdef CONFIG_LIBXENCTRL
 	case FTYPE_XC:
 	    minios_interface_close_fd(fd);
-	    return 0;
+            break;
 #endif
 #ifdef CONFIG_LIBXENEVTCHN
 	case FTYPE_EVTCHN:
 	    minios_evtchn_close_fd(fd);
-            return 0;
+            break;
 #endif
 #ifdef CONFIG_LIBXENGNTTAB
 	case FTYPE_GNTMAP:
 	    minios_gnttab_close_fd(fd);
-	    return 0;
+            break;
 #endif
 #ifdef CONFIG_NETFRONT
 	case FTYPE_TAP:
 	    shutdown_netfront(files[fd].dev);
-	    files[fd].type = FTYPE_NONE;
-	    return 0;
+            break;
 #endif
 #ifdef CONFIG_BLKFRONT
 	case FTYPE_BLK:
             shutdown_blkfront(files[fd].dev);
-	    files[fd].type = FTYPE_NONE;
-	    return 0;
+            break;
 #endif
 #ifdef CONFIG_TPMFRONT
 	case FTYPE_TPMFRONT:
             shutdown_tpmfront(files[fd].dev);
-	    files[fd].type = FTYPE_NONE;
-	    return 0;
+            break;
 #endif
 #ifdef CONFIG_TPM_TIS
 	case FTYPE_TPM_TIS:
             shutdown_tpm_tis(files[fd].dev);
-	    files[fd].type = FTYPE_NONE;
-	    return 0;
+            break;
 #endif
 #ifdef CONFIG_KBDFRONT
 	case FTYPE_KBD:
             shutdown_kbdfront(files[fd].dev);
-            files[fd].type = FTYPE_NONE;
-            return 0;
+            break;
 #endif
 #ifdef CONFIG_FBFRONT
 	case FTYPE_FB:
             shutdown_fbfront(files[fd].dev);
-            files[fd].type = FTYPE_NONE;
-            return 0;
+            break;
 #endif
 #ifdef CONFIG_CONSFRONT
         case FTYPE_SAVEFILE:
         case FTYPE_CONSOLE:
             fini_consfront(files[fd].dev);
-            files[fd].type = FTYPE_NONE;
-            return 0;
+            break;
 #endif
 	case FTYPE_NONE:
-	    break;
+            printk("close(%d): Bad descriptor\n", fd);
+            errno = EBADF;
+            return -1;
     }
-    printk("close(%d): Bad descriptor\n", fd);
-    errno = EBADF;
-    return -1;
+
+    memset(files + fd, 0, sizeof(struct file));
+    files[fd].type = FTYPE_NONE;
+    return res;
 }
 
 static void init_stat(struct stat *buf)
diff --git a/lib/xs.c b/lib/xs.c
index 0459f52..4af0f96 100644
--- a/lib/xs.c
+++ b/lib/xs.c
@@ -35,7 +35,6 @@ void xs_daemon_close(struct xs_handle *h)
         next = event->next;
         free(event);
     }
-    files[fd].type = FTYPE_NONE;
 }
 
 int xs_fileno(struct xs_handle *h)
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:12:21 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:12:21 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255862.438710 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Iou-0002WH-3m; Tue, 11 Jan 2022 15:12:20 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255862.438710; Tue, 11 Jan 2022 15:12:20 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Iou-0002WA-0I; Tue, 11 Jan 2022 15:12:20 +0000
Received: by outflank-mailman (input) for mailman id 255862;
 Tue, 11 Jan 2022 15:12:18 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ios-0002Fw-Ik
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 15:12:18 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id dd43726e-72f0-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 16:12:17 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 258AF212C2;
 Tue, 11 Jan 2022 15:12:17 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F1B0F1404B;
 Tue, 11 Jan 2022 15:12:16 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id QOfQOVCe3WG8AwAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 15:12:16 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: dd43726e-72f0-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913937; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=DjsZaSOIcJ6iFahsf84mXvc0XkEk+3Mf01A/EmIC1Ic=;
	b=SunZVRlMBMQ3pF24OyRoCstzJwKxSJCyqCjGXv45rBsLO5hncikrQd1hFjeYQYTbe65f1b
	j7YVDhEm4/KrPjfX5hXdCXlxftCzURRb4u6dYwLVS9XUGgcpmowd7zp4zR7njak382zbOJ
	m9iIHn/cRS6SIi26mR9kVwyOPi5SfBA=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 01/12] mini-os: remove event channel specific struct file definitions
Date: Tue, 11 Jan 2022 16:12:04 +0100
Message-Id: <20220111151215.22955-2-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111151215.22955-1-jgross@suse.com>
References: <20220111151215.22955-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

The event channel specific union member in struct file is no longer
needed, so remove it together with the associated structure
definitions.

The event channel file type and its associated handling can be removed,
too, as libxenevtchn is now supplying a struct file_ops via a call of
alloc_file_type().

This removes all contents of CONFIG_LIBXENEVTCHN guarded sections, so
this config option can be removed.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 Config.mk                     |  1 -
 arch/x86/testbuild/all-no     |  1 -
 arch/x86/testbuild/all-yes    |  1 -
 arch/x86/testbuild/newxen-yes |  1 -
 include/lib.h                 | 15 +--------------
 lib/sys.c                     |  7 -------
 6 files changed, 1 insertion(+), 25 deletions(-)

diff --git a/Config.mk b/Config.mk
index 1e08388..c244adc 100644
--- a/Config.mk
+++ b/Config.mk
@@ -197,7 +197,6 @@ CONFIG-n += CONFIG_PARAVIRT
 endif
 # Support legacy CONFIG_XC value
 CONFIG_XC ?= $(libc)
-CONFIG-$(CONFIG_XC) += CONFIG_LIBXENEVTCHN
 CONFIG-$(CONFIG_XC) += CONFIG_LIBXENGNTTAB
 
 CONFIG-$(lwip) += CONFIG_LWIP
diff --git a/arch/x86/testbuild/all-no b/arch/x86/testbuild/all-no
index d6fc260..202c317 100644
--- a/arch/x86/testbuild/all-no
+++ b/arch/x86/testbuild/all-no
@@ -13,7 +13,6 @@ CONFIG_FBFRONT = n
 CONFIG_KBDFRONT = n
 CONFIG_CONSFRONT = n
 CONFIG_XENBUS = n
-CONFIG_LIBXENEVTCHN = n
 CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
 CONFIG_BALLOON = n
diff --git a/arch/x86/testbuild/all-yes b/arch/x86/testbuild/all-yes
index 98bbfeb..eb495a4 100644
--- a/arch/x86/testbuild/all-yes
+++ b/arch/x86/testbuild/all-yes
@@ -16,6 +16,5 @@ CONFIG_XENBUS = y
 CONFIG_BALLOON = y
 CONFIG_USE_XEN_CONSOLE = y
 # The following are special: they need support from outside
-CONFIG_LIBXENEVTCHN = n
 CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/arch/x86/testbuild/newxen-yes b/arch/x86/testbuild/newxen-yes
index 0603200..bf25ace 100644
--- a/arch/x86/testbuild/newxen-yes
+++ b/arch/x86/testbuild/newxen-yes
@@ -17,6 +17,5 @@ CONFIG_BALLOON = y
 CONFIG_USE_XEN_CONSOLE = y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
 # The following are special: they need support from outside
-CONFIG_LIBXENEVTCHN = n
 CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/include/lib.h b/include/lib.h
index 4892320..df972ef 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -169,8 +169,7 @@ void sanity_check(void);
 #define FTYPE_TPM_TIS   11
 #define FTYPE_XENBUS    12
 #define FTYPE_GNTMAP    13
-#define FTYPE_EVTCHN    14
-#define FTYPE_N         15
+#define FTYPE_N         14
 #define FTYPE_SPARE     16
 
 typedef int file_read_func(int fd, void *buf, size_t nbytes);
@@ -199,15 +198,6 @@ off_t lseek_default(int fd, off_t offset, int whence);
 bool select_yes(int fd);
 bool select_read_flag(int fd);
 
-LIST_HEAD(evtchn_port_list, evtchn_port_info);
-
-struct evtchn_port_info {
-        LIST_ENTRY(evtchn_port_info) list;
-        evtchn_port_t port;
-        unsigned long pending;
-        int bound;
-};
-
 struct file {
     unsigned int type;
     bool read;	/* maybe available for read */
@@ -215,9 +205,6 @@ struct file {
     union {
         int fd; /* Any fd from an upper layer. */
         void *dev;
-	struct {
-	    struct evtchn_port_list ports;
-	} evtchn;
 	struct gntmap gntmap;
     };
 };
diff --git a/lib/sys.c b/lib/sys.c
index 52876e0..8fa1fee 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -505,11 +505,6 @@ int close(int fd)
 	    res = lwip_close(files[fd].fd);
             break;
 #endif
-#ifdef CONFIG_LIBXENEVTCHN
-	case FTYPE_EVTCHN:
-	    minios_evtchn_close_fd(fd);
-            break;
-#endif
 #ifdef CONFIG_LIBXENGNTTAB
 	case FTYPE_GNTMAP:
 	    minios_gnttab_close_fd(fd);
@@ -723,7 +718,6 @@ static const char *file_types[] = {
     [FTYPE_NONE]    = "none",
     [FTYPE_CONSOLE] = "console",
     [FTYPE_XENBUS]  = "xenbus",
-    [FTYPE_EVTCHN]  = "evtchn",
     [FTYPE_SOCKET]  = "socket",
     [FTYPE_TAP]     = "net",
     [FTYPE_BLK]     = "blk",
@@ -915,7 +909,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 	    FD_CLR(i, exceptfds);
 	    break;
 #endif
-	case FTYPE_EVTCHN:
 	case FTYPE_TAP:
 	case FTYPE_BLK:
 	case FTYPE_KBD:
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:12:21 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:12:21 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255863.438713 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Iou-0002WZ-8U; Tue, 11 Jan 2022 15:12:20 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255863.438713; Tue, 11 Jan 2022 15:12:20 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Iou-0002WO-3B; Tue, 11 Jan 2022 15:12:20 +0000
Received: by outflank-mailman (input) for mailman id 255863;
 Tue, 11 Jan 2022 15:12:19 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ios-0002Fv-Us
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 15:12:18 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id dd3b7a4b-72f0-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 16:12:17 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id F24DF21112;
 Tue, 11 Jan 2022 15:12:16 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C2C5213DDD;
 Tue, 11 Jan 2022 15:12:16 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 5WmrLVCe3WG8AwAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 15:12:16 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: dd3b7a4b-72f0-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913936; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:  content-transfer-encoding:content-transfer-encoding;
	bh=yeuY0drNiNl4kEQVrhTlT4kDcZq8w1z+MQQqf9GMpmM=;
	b=aZXWA9BgLmZAj/I3kveShb3xBHXKBZTmT8tlcHIuxZgosZeeNQD/U7coIYjgU9ijBW3BPJ
	ceKc1dfnGddUgVQlh0CgJgHwOzFGjSSKR2sFCOk+LU+4uQ++zGrU9igsMJKrPeSgyv8JO5
	8f1Vp5XOHuz9HqXSB1Sh/O0CibyJFYI=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 00/12] mini-os: remove device specific struct file members
Date: Tue, 11 Jan 2022 16:12:03 +0100
Message-Id: <20220111151215.22955-1-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

This small series is a followup to the series sent recently:

https://lists.xen.org/archives/html/xen-devel/2022-01/threads.html#00347

It contains the last cleanups related to struct file and can only be
applied after the Xen libraries have stopped using the related union
members:

https://lists.xen.org/archives/html/xen-devel/2022-01/threads.html#00355

The three series applied have been tested to work with:

- xenstorepvh-stubdom
- pv-grub
- ioemu-stubdom

Changes in V2:
- add many patches for using alloc_file_type() and struct file_ops

Juergen Gross (12):
  mini-os: remove event channel specific struct file definitions
  mini-os: remove gnttab specific member from struct file
  mini-os: use alloc_file_type() and get_file_from_fd() in xs
  mini-os: use alloc_file_type() and get_file_from_fd() in tpm_tis
  mini-os: use alloc_file_type() and get_file_from_fd() in tpmfront
  mini-os: use alloc_file_type() and get_file_from_fd() in blkfront
  mini-os: use get_file_from_fd() in netfront
  mini-os: use alloc_file_type() and get_file_from_fd() in fbfront
  mini-os: use file_ops and get_file_from_fd() for console
  mini-os: add struct file_ops for file type socket
  mini-os: add struct file_ops for FTYPE_FILE
  mini-os: make files array private to sys.c

 Config.mk                     |   2 -
 arch/x86/testbuild/all-no     |   2 -
 arch/x86/testbuild/all-yes    |   2 -
 arch/x86/testbuild/newxen-yes |   2 -
 blkfront.c                    |  92 ++++++--
 console/xenbus.c              | 125 ++++++++++
 console/xencons_ring.c        |   6 +-
 fbfront.c                     | 125 ++++++++--
 gntmap.c                      |   2 +-
 include/blkfront.h            |   5 -
 include/console.h             |   5 +
 include/lib.h                 |  27 +--
 include/tpm_tis.h             |   6 -
 include/tpmfront.h            |   5 -
 lib/sys.c                     | 429 ++++++++--------------------------
 lib/xs.c                      |  64 +++--
 netfront.c                    |  64 ++++-
 tpm_tis.c                     | 120 ++++++----
 tpmfront.c                    | 100 +++++---
 xenbus/xenbus.c               |   1 +
 20 files changed, 664 insertions(+), 520 deletions(-)

-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:12:21 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:12:21 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255865.438730 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Iov-0002qZ-R4; Tue, 11 Jan 2022 15:12:21 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255865.438730; Tue, 11 Jan 2022 15:12:21 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Iov-0002qK-Jf; Tue, 11 Jan 2022 15:12:21 +0000
Received: by outflank-mailman (input) for mailman id 255865;
 Tue, 11 Jan 2022 15:12:20 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Iot-0002Fv-V8
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 15:12:20 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id dd8042dd-72f0-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 16:12:17 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 7BC961F3B8;
 Tue, 11 Jan 2022 15:12:17 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5665A13DDD;
 Tue, 11 Jan 2022 15:12:17 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id UNUCFFGe3WG8AwAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 15:12:17 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: dd8042dd-72f0-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913937; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=gTPeNHy0AVh7duIevs+xqjLxKhkGSrZIz5TiPB1taxY=;
	b=IRkL3v6k2KUYC2e1crbEs0Lw5Izu4d+fHlophfX9cPw76G/pbv0YqXKfbEwbqEysaBI8xa
	Q3Fo82RyLoSralVP088j9JE1wfo/qBNlvFtKyVN6d2H2Bhtkk/28Xo3pLB6EP57ilJhV0p
	4p7xRiGRrlwFAt+8mBeLO3eHtsG1gLM=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 03/12] mini-os: use alloc_file_type() and get_file_from_fd() in xs
Date: Tue, 11 Jan 2022 16:12:06 +0100
Message-Id: <20220111151215.22955-4-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111151215.22955-1-jgross@suse.com>
References: <20220111151215.22955-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Allocate the needed file type via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h   |  3 +--
 lib/sys.c       | 18 --------------
 lib/xs.c        | 64 +++++++++++++++++++++++++++++++++++++------------
 xenbus/xenbus.c |  1 +
 4 files changed, 51 insertions(+), 35 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 283abb8..05c7de5 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -167,8 +167,7 @@ void sanity_check(void);
 #define FTYPE_BLK        9
 #define FTYPE_TPMFRONT  10
 #define FTYPE_TPM_TIS   11
-#define FTYPE_XENBUS    12
-#define FTYPE_N         13
+#define FTYPE_N         12
 #define FTYPE_SPARE     16
 
 typedef int file_read_func(int fd, void *buf, size_t nbytes);
diff --git a/lib/sys.c b/lib/sys.c
index 9540410..d213ae5 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -495,11 +495,6 @@ int close(int fd)
     switch (files[fd].type) {
         default:
             break;
-#ifdef CONFIG_XENBUS
-	case FTYPE_XENBUS:
-            xs_daemon_close((void*)(intptr_t) fd);
-            break;
-#endif
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
 	    res = lwip_close(files[fd].fd);
@@ -712,7 +707,6 @@ int closedir(DIR *dir)
 static const char *file_types[] = {
     [FTYPE_NONE]    = "none",
     [FTYPE_CONSOLE] = "console",
-    [FTYPE_XENBUS]  = "xenbus",
     [FTYPE_SOCKET]  = "socket",
     [FTYPE_TAP]     = "net",
     [FTYPE_BLK]     = "blk",
@@ -892,18 +886,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
                 n++;
 	    FD_CLR(i, exceptfds);
 	    break;
-#ifdef CONFIG_XENBUS
-	case FTYPE_XENBUS:
-	    if (FD_ISSET(i, readfds)) {
-                if (files[i].dev)
-		    n++;
-		else
-		    FD_CLR(i, readfds);
-	    }
-	    FD_CLR(i, writefds);
-	    FD_CLR(i, exceptfds);
-	    break;
-#endif
 	case FTYPE_TAP:
 	case FTYPE_BLK:
 	case FTYPE_KBD:
diff --git a/lib/xs.c b/lib/xs.c
index 4af0f96..ac830d2 100644
--- a/lib/xs.c
+++ b/lib/xs.c
@@ -18,23 +18,55 @@ static inline int _xs_fileno(struct xs_handle *h) {
     return (intptr_t) h;
 }
 
+static int xs_close_fd(int fd)
+{
+    struct xenbus_event *event, *next;
+    struct file *file = get_file_from_fd(fd);
+
+    for (event = file->dev; event; event = next)
+    {
+        next = event->next;
+        free(event);
+    }
+
+    return 0;
+}
+
+static bool xs_can_read(int fd)
+{
+    struct file *file = get_file_from_fd(fd);
+
+    return file && file->dev;
+}
+
+static struct file_ops xenbus_ops = {
+    .name = "xenbus",
+    .close = xs_close_fd,
+    .select_rd = xs_can_read,
+};
+
 struct xs_handle *xs_daemon_open()
 {
-    int fd = alloc_fd(FTYPE_XENBUS);
-    files[fd].dev = NULL;
-    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].dev);
+    int fd;
+    struct file *file;
+    static unsigned int ftype_xenbus;
+
+    if ( !ftype_xenbus )
+        ftype_xenbus = alloc_file_type(&xenbus_ops);
+
+    fd = alloc_fd(ftype_xenbus);
+    file = get_file_from_fd(fd);
+    if ( !file )
+        return NULL;
+
+    file->dev = NULL;
+    printk("xs_daemon_open -> %d, %p\n", fd, &file->dev);
     return (void*)(intptr_t) fd;
 }
 
 void xs_daemon_close(struct xs_handle *h)
 {
-    int fd = _xs_fileno(h);
-    struct xenbus_event *event, *next;
-    for (event = files[fd].dev; event; event = next)
-    {
-        next = event->next;
-        free(event);
-    }
+    close(_xs_fileno(h));
 }
 
 int xs_fileno(struct xs_handle *h)
@@ -169,18 +201,20 @@ char **xs_directory(struct xs_handle *h, xs_transaction_t t,
 
 bool xs_watch(struct xs_handle *h, const char *path, const char *token)
 {
-    int fd = _xs_fileno(h);
+    struct file *file = get_file_from_fd(_xs_fileno(h));
+
     printk("xs_watch(%s, %s)\n", path, token);
     return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token,
-                   (xenbus_event_queue *)&files[fd].dev));
+                   (xenbus_event_queue *)&file->dev));
 }
 
 char **xs_read_watch(struct xs_handle *h, unsigned int *num)
 {
-    int fd = _xs_fileno(h);
     struct xenbus_event *event;
-    event = files[fd].dev;
-    files[fd].dev = event->next;
+    struct file *file = get_file_from_fd(_xs_fileno(h));
+
+    event = file->dev;
+    file->dev = event->next;
     printk("xs_read_watch() -> %s %s\n", event->path, event->token);
     *num = 2;
     return (char **) &event->path;
diff --git a/xenbus/xenbus.c b/xenbus/xenbus.c
index b687678..785389f 100644
--- a/xenbus/xenbus.c
+++ b/xenbus/xenbus.c
@@ -393,6 +393,7 @@ static int allocate_xenbus_id(void)
 void init_xenbus(void)
 {
     int err;
+
     DEBUG("init_xenbus called.\n");
     create_thread("xenstore", xenbus_thread_func, NULL);
     DEBUG("buf at %p.\n", xenstore_buf);
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:12:21 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:12:21 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255866.438733 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Iov-0002rC-Tr; Tue, 11 Jan 2022 15:12:21 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255866.438733; Tue, 11 Jan 2022 15:12:21 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Iov-0002qj-La; Tue, 11 Jan 2022 15:12:21 +0000
Received: by outflank-mailman (input) for mailman id 255866;
 Tue, 11 Jan 2022 15:12:20 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Iou-0002Fw-CY
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 15:12:20 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id dd5d2c65-72f0-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 16:12:17 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 517B51F3B1;
 Tue, 11 Jan 2022 15:12:17 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2BB1213DDD;
 Tue, 11 Jan 2022 15:12:17 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id OI96CVGe3WG8AwAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 15:12:17 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: dd5d2c65-72f0-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913937; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=w1Lvr7st24bBGrZRxVwRlwFD2dxAwXVMl1+mfqeQNHE=;
	b=OZ0R2DCXa0L+ZUY2zZfTfxLjFTERlfqtPNXSkOfG19TQKIHgl69CgBeKlUz6peY6TRp2/G
	DFHQsTIY9bhNip/NE8/MESgTTBB1SQru9Acq+eimfagktjBzkoKmoURGNK5bA/9TJzkK3f
	k/Ids5H5XRPG9IpqldgDlUCVIH5LkCs=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 02/12] mini-os: remove gnttab specific member from struct file
Date: Tue, 11 Jan 2022 16:12:05 +0100
Message-Id: <20220111151215.22955-3-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111151215.22955-1-jgross@suse.com>
References: <20220111151215.22955-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

The event channel specific union member in struct file is no longer
needed, so remove it.

The gnttab file type and its associated handling can be removed, too,
as libxengnttab is now supplying a struct file_ops via a call of
alloc_file_type().

This removes all contents of CONFIG_LIBXENGNTTAB guarded sections, so
this config option can be removed.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 Config.mk                     | 1 -
 arch/x86/testbuild/all-no     | 1 -
 arch/x86/testbuild/all-yes    | 1 -
 arch/x86/testbuild/newxen-yes | 1 -
 gntmap.c                      | 2 +-
 include/lib.h                 | 4 +---
 lib/sys.c                     | 5 -----
 7 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/Config.mk b/Config.mk
index c244adc..eb84515 100644
--- a/Config.mk
+++ b/Config.mk
@@ -197,7 +197,6 @@ CONFIG-n += CONFIG_PARAVIRT
 endif
 # Support legacy CONFIG_XC value
 CONFIG_XC ?= $(libc)
-CONFIG-$(CONFIG_XC) += CONFIG_LIBXENGNTTAB
 
 CONFIG-$(lwip) += CONFIG_LWIP
 
diff --git a/arch/x86/testbuild/all-no b/arch/x86/testbuild/all-no
index 202c317..c429354 100644
--- a/arch/x86/testbuild/all-no
+++ b/arch/x86/testbuild/all-no
@@ -13,7 +13,6 @@ CONFIG_FBFRONT = n
 CONFIG_KBDFRONT = n
 CONFIG_CONSFRONT = n
 CONFIG_XENBUS = n
-CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
 CONFIG_BALLOON = n
 CONFIG_USE_XEN_CONSOLE = n
diff --git a/arch/x86/testbuild/all-yes b/arch/x86/testbuild/all-yes
index eb495a4..6c6096b 100644
--- a/arch/x86/testbuild/all-yes
+++ b/arch/x86/testbuild/all-yes
@@ -16,5 +16,4 @@ CONFIG_XENBUS = y
 CONFIG_BALLOON = y
 CONFIG_USE_XEN_CONSOLE = y
 # The following are special: they need support from outside
-CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/arch/x86/testbuild/newxen-yes b/arch/x86/testbuild/newxen-yes
index bf25ace..88094fc 100644
--- a/arch/x86/testbuild/newxen-yes
+++ b/arch/x86/testbuild/newxen-yes
@@ -17,5 +17,4 @@ CONFIG_BALLOON = y
 CONFIG_USE_XEN_CONSOLE = y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
 # The following are special: they need support from outside
-CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/gntmap.c b/gntmap.c
index 6fa1dac..3422ab2 100644
--- a/gntmap.c
+++ b/gntmap.c
@@ -3,7 +3,7 @@
  *
  * Diego Ongaro <diego.ongaro@citrix.com>, July 2008
  *
- * Files of type FTYPE_GNTMAP contain a gntmap, which is an array of
+ * Files of libxengnttab contain a gntmap, which is an array of
  * (host address, grant handle) pairs. Grant handles come from a hypervisor map
  * operation and are needed for the corresponding unmap.
  *
diff --git a/include/lib.h b/include/lib.h
index df972ef..283abb8 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -168,8 +168,7 @@ void sanity_check(void);
 #define FTYPE_TPMFRONT  10
 #define FTYPE_TPM_TIS   11
 #define FTYPE_XENBUS    12
-#define FTYPE_GNTMAP    13
-#define FTYPE_N         14
+#define FTYPE_N         13
 #define FTYPE_SPARE     16
 
 typedef int file_read_func(int fd, void *buf, size_t nbytes);
@@ -205,7 +204,6 @@ struct file {
     union {
         int fd; /* Any fd from an upper layer. */
         void *dev;
-	struct gntmap gntmap;
     };
 };
 
diff --git a/lib/sys.c b/lib/sys.c
index 8fa1fee..9540410 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -505,11 +505,6 @@ int close(int fd)
 	    res = lwip_close(files[fd].fd);
             break;
 #endif
-#ifdef CONFIG_LIBXENGNTTAB
-	case FTYPE_GNTMAP:
-	    minios_gnttab_close_fd(fd);
-            break;
-#endif
 #ifdef CONFIG_NETFRONT
 	case FTYPE_TAP:
 	    shutdown_netfront(files[fd].dev);
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:12:24 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:12:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255869.438748 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Iox-00036t-Sm; Tue, 11 Jan 2022 15:12:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255869.438748; Tue, 11 Jan 2022 15:12:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Iox-00034x-ET; Tue, 11 Jan 2022 15:12:23 +0000
Received: by outflank-mailman (input) for mailman id 255869;
 Tue, 11 Jan 2022 15:12:22 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Iov-0002Fv-VO
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 15:12:22 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ddbbbb2d-72f0-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 16:12:18 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id D9E20212C5;
 Tue, 11 Jan 2022 15:12:17 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B24D913DDD;
 Tue, 11 Jan 2022 15:12:17 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 4LNQKlGe3WG8AwAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 15:12:17 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ddbbbb2d-72f0-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913937; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=HfQh4OZ9az0A9qjPS5wm3iwxm7DBwhvFq6/vq3hHx4c=;
	b=d+2fCrxpZ86Dc+7cN3OiQiG9EGz1BKXAhrYJF71rPwQ8i4kjMPvAVxGZPTUl9n/L3qsiRc
	wTEby7tMgtDOedTFArOZVMMsYt9vYyotw7EhP2R9SzKXvUrXb54IPu2U/kIppdSeUkwYlQ
	Lj19uGCFkMYW8wXcigeeSEVUDLbad6Y=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 05/12] mini-os: use alloc_file_type() and get_file_from_fd() in tpmfront
Date: Tue, 11 Jan 2022 16:12:08 +0100
Message-Id: <20220111151215.22955-6-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111151215.22955-1-jgross@suse.com>
References: <20220111151215.22955-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Allocate a file type dynamically via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h      |   3 +-
 include/tpmfront.h |   5 ---
 lib/sys.c          |  23 -----------
 tpmfront.c         | 100 ++++++++++++++++++++++++++++++++-------------
 4 files changed, 72 insertions(+), 59 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index d94d142..f6478de 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -165,8 +165,7 @@ void sanity_check(void);
 #define FTYPE_KBD        7
 #define FTYPE_TAP        8
 #define FTYPE_BLK        9
-#define FTYPE_TPMFRONT  10
-#define FTYPE_N         11
+#define FTYPE_N         10
 #define FTYPE_SPARE     16
 
 typedef int file_read_func(int fd, void *buf, size_t nbytes);
diff --git a/include/tpmfront.h b/include/tpmfront.h
index b7da50e..a527371 100644
--- a/include/tpmfront.h
+++ b/include/tpmfront.h
@@ -81,7 +81,6 @@ int tpmfront_cmd(struct tpmfront_dev* dev, uint8_t* req, size_t reqlen, uint8_t*
 int tpmfront_set_locality(struct tpmfront_dev* dev, int locality);
 
 #ifdef HAVE_LIBC
-#include <sys/stat.h>
 /* POSIX IO functions:
  * use tpmfront_open() to get a file descriptor to the tpm device
  * use write() on the fd to send a command to the backend. You must
@@ -90,10 +89,6 @@ int tpmfront_set_locality(struct tpmfront_dev* dev, int locality);
  * fstat() to get the size of the response and lseek() to seek on it.
  */
 int tpmfront_open(struct tpmfront_dev* dev);
-int tpmfront_posix_read(int fd, uint8_t* buf, size_t count);
-int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count);
-int tpmfront_posix_fstat(int fd, struct stat* buf);
 #endif
 
-
 #endif
diff --git a/lib/sys.c b/lib/sys.c
index 4060b42..ff6be52 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -28,7 +28,6 @@
 #include <netfront.h>
 #include <blkfront.h>
 #include <fbfront.h>
-#include <tpmfront.h>
 #include <xenbus.h>
 #include <xenstore.h>
 #include <poll.h>
@@ -343,11 +342,6 @@ int read(int fd, void *buf, size_t nbytes)
         case FTYPE_BLK: {
 	    return blkfront_posix_read(fd, buf, nbytes);
         }
-#endif
-#ifdef CONFIG_TPMFRONT
-        case FTYPE_TPMFRONT: {
-	    return tpmfront_posix_read(fd, buf, nbytes);
-        }
 #endif
 	default:
 	    break;
@@ -389,10 +383,6 @@ int write(int fd, const void *buf, size_t nbytes)
 #ifdef CONFIG_BLKFRONT
 	case FTYPE_BLK:
 	    return blkfront_posix_write(fd, buf, nbytes);
-#endif
-#ifdef CONFIG_TPMFRONT
-	case FTYPE_TPMFRONT:
-	    return tpmfront_posix_write(fd, buf, nbytes);
 #endif
 	default:
 	    break;
@@ -445,10 +435,6 @@ off_t lseek(int fd, off_t offset, int whence)
 #ifdef CONFIG_BLKFRONT
        case FTYPE_BLK:
           break;
-#endif
-#ifdef CONFIG_TPMFRONT
-       case FTYPE_TPMFRONT:
-          break;
 #endif
        case FTYPE_FILE:
           break;
@@ -496,11 +482,6 @@ int close(int fd)
             shutdown_blkfront(files[fd].dev);
             break;
 #endif
-#ifdef CONFIG_TPMFRONT
-	case FTYPE_TPMFRONT:
-            shutdown_tpmfront(files[fd].dev);
-            break;
-#endif
 #ifdef CONFIG_KBDFRONT
 	case FTYPE_KBD:
             shutdown_kbdfront(files[fd].dev);
@@ -576,10 +557,6 @@ int fstat(int fd, struct stat *buf)
 #ifdef CONFIG_BLKFRONT
 	case FTYPE_BLK:
 	   return blkfront_posix_fstat(fd, buf);
-#endif
-#ifdef CONFIG_TPMFRONT
-	case FTYPE_TPMFRONT:
-	   return tpmfront_posix_fstat(fd, buf);
 #endif
 	default:
 	    break;
diff --git a/tpmfront.c b/tpmfront.c
index 0a2fefc..a19a052 100644
--- a/tpmfront.c
+++ b/tpmfront.c
@@ -49,6 +49,10 @@
 void tpmfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) {
    struct tpmfront_dev* dev = (struct tpmfront_dev*) data;
    tpmif_shared_page_t *shr = dev->page;
+#ifdef HAVE_LIBC
+    struct file *file = get_file_from_fd(dev->fd);
+#endif
+
    /*If we get a response when we didnt make a request, just ignore it */
    if(!dev->waiting) {
       return;
@@ -65,8 +69,9 @@ void tpmfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) {
 
    dev->waiting = 0;
 #ifdef HAVE_LIBC
-   if(dev->fd >= 0) {
-      files[dev->fd].read = true;
+   if ( file )
+   {
+      file->read = true;
    }
 #endif
    wake_up(&dev->waitq);
@@ -405,6 +410,10 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
 #ifdef TPMFRONT_PRINT_DEBUG
    int i;
 #endif
+#ifdef HAVE_LIBC
+    struct file *file = dev ? get_file_from_fd(dev->fd) : NULL;
+#endif
+
    /* Error Checking */
    if(dev == NULL || dev->state != XenbusStateConnected) {
       TPMFRONT_ERR("Tried to send message through disconnected frontend\n");
@@ -437,9 +446,10 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
    dev->waiting = 1;
    dev->resplen = 0;
 #ifdef HAVE_LIBC
-   if(dev->fd >= 0) {
-      files[dev->fd].read = false;
-      files[dev->fd].offset = 0;
+   if ( file )
+   {
+      file->read = false;
+      file->offset = 0;
       dev->respgot = false;
    }
 #endif
@@ -529,25 +539,14 @@ int tpmfront_set_locality(struct tpmfront_dev* dev, int locality)
 
 #ifdef HAVE_LIBC
 #include <errno.h>
-int tpmfront_open(struct tpmfront_dev* dev)
-{
-   /* Silently prevent multiple opens */
-   if(dev->fd != -1) {
-      return dev->fd;
-   }
 
-   dev->fd = alloc_fd(FTYPE_TPMFRONT);
-   printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
-   files[dev->fd].dev = dev;
-   dev->respgot = false;
-   return dev->fd;
-}
-
-int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count)
+static int tpmfront_posix_write(int fd, const void *buf, size_t count)
 {
    int rc;
    struct tpmfront_dev* dev;
-   dev = files[fd].dev;
+   struct file *file = get_file_from_fd(fd);
+
+   dev = file->dev;
 
    if(count == 0) {
       return 0;
@@ -566,14 +565,15 @@ int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count)
    return count;
 }
 
-int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
+static int tpmfront_posix_read(int fd, void *buf, size_t count)
 {
    int rc;
    uint8_t* dummybuf;
    size_t dummysz;
    struct tpmfront_dev* dev;
+   struct file *file = get_file_from_fd(fd);
 
-   dev = files[fd].dev;
+   dev = file->dev;
 
    if(count == 0) {
       return 0;
@@ -588,29 +588,33 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
    }
 
    /* handle EOF case */
-   if(files[dev->fd].offset >= dev->resplen) {
+   if ( file->offset >= dev->resplen )
+   {
       return 0;
    }
 
    /* Compute the number of bytes and do the copy operation */
-   if((rc = min(count, dev->resplen - files[dev->fd].offset)) != 0) {
-      memcpy(buf, dev->respbuf + files[dev->fd].offset, rc);
-      files[dev->fd].offset += rc;
+   if ( (rc = min(count, dev->resplen - file->offset)) != 0 )
+   {
+      memcpy(buf, dev->respbuf + file->offset, rc);
+      file->offset += rc;
    }
 
    return rc;
 }
 
-int tpmfront_posix_fstat(int fd, struct stat* buf)
+static int tpmfront_posix_fstat(int fd, struct stat *buf)
 {
    uint8_t* dummybuf;
    size_t dummysz;
    int rc;
-   struct tpmfront_dev* dev = files[fd].dev;
+   struct file *file = get_file_from_fd(fd);
+   struct tpmfront_dev* dev = file->dev;
 
    /* If we have a response waiting, then read it now from the backend
     * so we can get its length*/
-   if(dev->waiting || (files[dev->fd].read && !dev->respgot)) {
+   if ( dev->waiting || (file->read && !dev->respgot) )
+   {
       if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
 	 errno = EIO;
 	 return -1;
@@ -626,5 +630,43 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
    return 0;
 }
 
+static int tpmfront_close_fd(int fd)
+{
+    struct file *file = get_file_from_fd(fd);
+
+    shutdown_tpmfront(file->dev);
+
+    return 0;
+}
+
+static struct file_ops tpmfront_ops = {
+    .name = "tpmfront",
+    .read = tpmfront_posix_read,
+    .write = tpmfront_posix_write,
+    .lseek = lseek_default,
+    .close = tpmfront_close_fd,
+    .fstat = tpmfront_posix_fstat,
+};
+
+int tpmfront_open(struct tpmfront_dev* dev)
+{
+   struct file *file;
+   static unsigned int ftype_tpmfront;
+
+   /* Silently prevent multiple opens */
+   if(dev->fd != -1) {
+      return dev->fd;
+   }
+
+   if ( !ftype_tpmfront )
+       ftype_tpmfront = alloc_file_type(&tpmfront_ops);
+
+   dev->fd = alloc_fd(ftype_tpmfront);
+   printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
+   file = get_file_from_fd(dev->fd);
+   file->dev = dev;
+   dev->respgot = false;
+   return dev->fd;
+}
 
 #endif
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:12:24 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:12:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255870.438752 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ioy-00038T-1C; Tue, 11 Jan 2022 15:12:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255870.438752; Tue, 11 Jan 2022 15:12:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Iox-00037C-Iq; Tue, 11 Jan 2022 15:12:23 +0000
Received: by outflank-mailman (input) for mailman id 255870;
 Tue, 11 Jan 2022 15:12:22 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Iow-0002Fw-Cs
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 15:12:22 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id dd9e2654-72f0-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 16:12:17 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id AD0541F3B9;
 Tue, 11 Jan 2022 15:12:17 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8267513DDD;
 Tue, 11 Jan 2022 15:12:17 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id SDGkHlGe3WG8AwAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 15:12:17 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: dd9e2654-72f0-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913937; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=eq4fsjhW0m7VHOVVZWDwPf/Gn+LXzVDVgJADrNIM91s=;
	b=FDtBICD7vyqfzoRiSbB6nV7XftvZkWYIFMeuVc5+9fV3rGDtUgTfeYw006aodWNadVzBmS
	XJoOBBnYPvbG12gledkxWBAfdK5nM52NyosKVH1RQst5dGnd4frHMDvRf9wqLogqzRsGqY
	d/a9+2dSa8rnH6xP6Oj6M3P0xZGoI10=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 04/12] mini-os: use alloc_file_type() and get_file_from_fd() in tpm_tis
Date: Tue, 11 Jan 2022 16:12:07 +0100
Message-Id: <20220111151215.22955-5-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111151215.22955-1-jgross@suse.com>
References: <20220111151215.22955-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Allocate a file type dynamically via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Make some now local functions static and modify their prototypes to
match the file_ops requirements.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h     |   3 +-
 include/tpm_tis.h |   6 ---
 lib/sys.c         |  23 ---------
 tpm_tis.c         | 120 ++++++++++++++++++++++++++++++----------------
 4 files changed, 80 insertions(+), 72 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 05c7de5..d94d142 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -166,8 +166,7 @@ void sanity_check(void);
 #define FTYPE_TAP        8
 #define FTYPE_BLK        9
 #define FTYPE_TPMFRONT  10
-#define FTYPE_TPM_TIS   11
-#define FTYPE_N         12
+#define FTYPE_N         11
 #define FTYPE_SPARE     16
 
 typedef int file_read_func(int fd, void *buf, size_t nbytes);
diff --git a/include/tpm_tis.h b/include/tpm_tis.h
index 86e83f1..2af974d 100644
--- a/include/tpm_tis.h
+++ b/include/tpm_tis.h
@@ -37,14 +37,11 @@ struct tpm_chip;
 
 struct tpm_chip* init_tpm_tis(unsigned long baseaddr, int localities, unsigned int irq);
 struct tpm_chip* init_tpm2_tis(unsigned long baseaddr, int localities, unsigned int irq);
-void shutdown_tpm_tis(struct tpm_chip* tpm);
 
 int tpm_tis_request_locality(struct tpm_chip* tpm, int locality);
 int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** resp, size_t* resplen);
 
 #ifdef HAVE_LIBC
-#include <sys/stat.h>
-#include <fcntl.h>
 /* POSIX IO functions:
  * use tpm_tis_open() to get a file descriptor to the tpm device
  * use write() on the fd to send a command to the backend. You must
@@ -53,9 +50,6 @@ int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** res
  * fstat() to get the size of the response and lseek() to seek on it.
  */
 int tpm_tis_open(struct tpm_chip* tpm);
-int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count);
-int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count);
-int tpm_tis_posix_fstat(int fd, struct stat* buf);
 #endif
 
 #endif
diff --git a/lib/sys.c b/lib/sys.c
index d213ae5..4060b42 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -29,7 +29,6 @@
 #include <blkfront.h>
 #include <fbfront.h>
 #include <tpmfront.h>
-#include <tpm_tis.h>
 #include <xenbus.h>
 #include <xenstore.h>
 #include <poll.h>
@@ -349,11 +348,6 @@ int read(int fd, void *buf, size_t nbytes)
         case FTYPE_TPMFRONT: {
 	    return tpmfront_posix_read(fd, buf, nbytes);
         }
-#endif
-#ifdef CONFIG_TPM_TIS
-        case FTYPE_TPM_TIS: {
-	    return tpm_tis_posix_read(fd, buf, nbytes);
-        }
 #endif
 	default:
 	    break;
@@ -399,10 +393,6 @@ int write(int fd, const void *buf, size_t nbytes)
 #ifdef CONFIG_TPMFRONT
 	case FTYPE_TPMFRONT:
 	    return tpmfront_posix_write(fd, buf, nbytes);
-#endif
-#ifdef CONFIG_TPM_TIS
-	case FTYPE_TPM_TIS:
-	    return tpm_tis_posix_write(fd, buf, nbytes);
 #endif
 	default:
 	    break;
@@ -459,10 +449,6 @@ off_t lseek(int fd, off_t offset, int whence)
 #ifdef CONFIG_TPMFRONT
        case FTYPE_TPMFRONT:
           break;
-#endif
-#ifdef CONFIG_TPM_TIS
-       case FTYPE_TPM_TIS:
-          break;
 #endif
        case FTYPE_FILE:
           break;
@@ -515,11 +501,6 @@ int close(int fd)
             shutdown_tpmfront(files[fd].dev);
             break;
 #endif
-#ifdef CONFIG_TPM_TIS
-	case FTYPE_TPM_TIS:
-            shutdown_tpm_tis(files[fd].dev);
-            break;
-#endif
 #ifdef CONFIG_KBDFRONT
 	case FTYPE_KBD:
             shutdown_kbdfront(files[fd].dev);
@@ -599,10 +580,6 @@ int fstat(int fd, struct stat *buf)
 #ifdef CONFIG_TPMFRONT
 	case FTYPE_TPMFRONT:
 	   return tpmfront_posix_fstat(fd, buf);
-#endif
-#ifdef CONFIG_TPM_TIS
-	case FTYPE_TPM_TIS:
-	   return tpm_tis_posix_fstat(fd, buf);
 #endif
 	default:
 	    break;
diff --git a/tpm_tis.c b/tpm_tis.c
index 477f555..abea7a1 100644
--- a/tpm_tis.c
+++ b/tpm_tis.c
@@ -792,6 +792,9 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
    int status, burstcnt = 0;
    int count = 0;
    uint32_t ordinal;
+#ifdef HAVE_LIBC
+   struct file *file = get_file_from_fd(tpm->fd);
+#endif
 
    if(tpm_tis_request_locality(tpm, tpm->locality) < 0) {
       return -EBUSY;
@@ -844,9 +847,10 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
       }
    }
 #ifdef HAVE_LIBC
-   if(tpm->fd >= 0) {
-      files[tpm->fd].read = false;
-      files[tpm->fd].offset = 0;
+   if ( file )
+   {
+      file->read = false;
+      file->offset = 0;
    }
 #endif
    return len;
@@ -1093,6 +1097,23 @@ ssize_t tpm_getcap(struct tpm_chip *chip, uint32_t subcap_id, cap_t *cap,
         return rc;
 }
 
+static void shutdown_tpm_tis(struct tpm_chip* tpm){
+   int i;
+
+   printk("Shutting down tpm_tis device\n");
+
+   iowrite32(TPM_INT_ENABLE(tpm, tpm->locality), ~TPM_GLOBAL_INT_ENABLE);
+
+   /*Unmap all of the mmio pages */
+   for(i = 0; i < 5; ++i) {
+      if(tpm->pages[i] != NULL) {
+	 iounmap(tpm->pages[i], PAGE_SIZE);
+	 tpm->pages[i] = NULL;
+      }
+   }
+   free(tpm);
+   return;
+}
 
 struct tpm_chip* init_tpm_tis(unsigned long baseaddr, int localities, unsigned int irq)
 {
@@ -1242,25 +1263,6 @@ abort_egress:
    return NULL;
 }
 
-void shutdown_tpm_tis(struct tpm_chip* tpm){
-   int i;
-
-   printk("Shutting down tpm_tis device\n");
-
-   iowrite32(TPM_INT_ENABLE(tpm, tpm->locality), ~TPM_GLOBAL_INT_ENABLE);
-
-   /*Unmap all of the mmio pages */
-   for(i = 0; i < 5; ++i) {
-      if(tpm->pages[i] != NULL) {
-	 iounmap(tpm->pages[i], PAGE_SIZE);
-	 tpm->pages[i] = NULL;
-      }
-   }
-   free(tpm);
-   return;
-}
-
-
 int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** resp, size_t* resplen)
 {
    if(tpm->locality < 0) {
@@ -1279,23 +1281,24 @@ int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** res
 }
 
 #ifdef HAVE_LIBC
-int tpm_tis_open(struct tpm_chip* tpm)
+#include <sys/stat.h>
+#include <fcntl.h>
+
+static int tpm_tis_close(int fd)
 {
-   /* Silently prevent multiple opens */
-   if(tpm->fd != -1) {
-      return tpm->fd;
-   }
+    struct file *file = get_file_from_fd(fd);
 
-   tpm->fd = alloc_fd(FTYPE_TPM_TIS);
-   printk("tpm_tis_open() -> %d\n", tpm->fd);
-   files[tpm->fd].dev = tpm;
-   return tpm->fd;
+    shutdown_tpm_tis(file->dev);
+
+    return 0;
 }
 
-int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count)
+static int tpm_tis_posix_write(int fd, const void *buf, size_t count)
 {
    struct tpm_chip* tpm;
-   tpm = files[fd].dev;
+   struct file *file = get_file_from_fd(fd);
+
+   tpm = file->dev;
 
    if(tpm->locality < 0) {
       printk("tpm_tis_posix_write() failed! locality not set!\n");
@@ -1319,11 +1322,13 @@ int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count)
    return count;
 }
 
-int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
+static int tpm_tis_posix_read(int fd, void *buf, size_t count)
 {
    int rc;
    struct tpm_chip* tpm;
-   tpm = files[fd].dev;
+   struct file *file = get_file_from_fd(fd);
+
+   tpm = file->dev;
 
    if(count == 0) {
       return 0;
@@ -1337,20 +1342,24 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
 
 
    /* Handle EOF case */
-   if(files[fd].offset >= tpm->data_len) {
+   if ( file->offset >= tpm->data_len )
+   {
       rc = 0;
    } else {
-      rc = min(tpm->data_len - files[fd].offset, count);
-      memcpy(buf, tpm->data_buffer + files[fd].offset, rc);
+      rc = min(tpm->data_len - file->offset, count);
+      memcpy(buf, tpm->data_buffer + file->offset, rc);
    }
-   files[fd].offset += rc;
+   file->offset += rc;
    /* Reset the data pending flag */
    return rc;
 }
-int tpm_tis_posix_fstat(int fd, struct stat* buf)
+
+static int tpm_tis_posix_fstat(int fd, struct stat *buf)
 {
    struct tpm_chip* tpm;
-   tpm = files[fd].dev;
+   struct file *file = get_file_from_fd(fd);
+
+   tpm = file->dev;
 
    buf->st_mode = O_RDWR;
    buf->st_uid = 0;
@@ -1360,6 +1369,35 @@ int tpm_tis_posix_fstat(int fd, struct stat* buf)
    return 0;
 }
 
+static struct file_ops tpm_tis_ops = {
+    .name = "tpm_tis",
+    .read = tpm_tis_posix_read,
+    .write = tpm_tis_posix_write,
+    .lseek = lseek_default,
+    .close = tpm_tis_close,
+    .fstat = tpm_tis_posix_fstat,
+};
+
+int tpm_tis_open(struct tpm_chip* tpm)
+{
+   struct file *file;
+   static unsigned int ftype_tis;
+
+   /* Silently prevent multiple opens */
+   if(tpm->fd != -1) {
+      return tpm->fd;
+   }
+
+   if ( !ftype_tis )
+       ftype_tis = alloc_file_type(&tpm_tis_ops);
+
+   tpm->fd = alloc_fd(ftype_tis);
+   printk("tpm_tis_open() -> %d\n", tpm->fd);
+   file = get_file_from_fd(tpm->fd);
+   file->dev = tpm;
+   return tpm->fd;
+}
+
 /* TPM 2.0 */
 
 /*TPM2.0 Selftest*/
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:12:27 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:12:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255873.438779 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ip1-0003nL-FX; Tue, 11 Jan 2022 15:12:27 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255873.438779; Tue, 11 Jan 2022 15:12:27 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ip0-0003ji-HA; Tue, 11 Jan 2022 15:12:26 +0000
Received: by outflank-mailman (input) for mailman id 255873;
 Tue, 11 Jan 2022 15:12:24 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Iox-0002Fv-Vj
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 15:12:24 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id de399b05-72f0-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 16:12:18 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id ACD45212C2;
 Tue, 11 Jan 2022 15:12:18 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 83AD913DDD;
 Tue, 11 Jan 2022 15:12:18 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 0D8NH1Ke3WG8AwAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 15:12:18 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: de399b05-72f0-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913938; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=akdaLVPdVVzqXtx9FHY3lThrxd9OOCJ2dYlEWLvAp9o=;
	b=hFWZo2ZPpBfkt/xOEsSkJtcF45r7YhT6Rwk/zWLc48g4sHIdpaPaCyAx8tdwLIjRWoL/WN
	3Ygu1RZv/8rkWLAhHWwddGdUynqq1UgVcWpOUPU8dKMXbNMjUt/HsUVLkN9HmQ3xKO476k
	2Gzy8RBUEXvdKHhTx48Ecxrvk/6ZxxA=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 09/12] mini-os: use file_ops and get_file_from_fd() for console
Date: Tue, 11 Jan 2022 16:12:12 +0100
Message-Id: <20220111151215.22955-10-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111151215.22955-1-jgross@suse.com>
References: <20220111151215.22955-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Add struct file_ops for the console related file types (FTYPE_CONSOLE
and savefile). FTYPE_CONSOLE remains statically defined, as it is used
to statically init stdin, stdout and stderr.

Instead of directly accessing the files[] array use get_file_from_fd().

With CONSOLE now handled via file_ops the bogus file descriptor case in
select_poll() now needs to be handled more explicit instead of dropping
into console handling, assuming that this case was basically meant to
cover SAVEFILE.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 console/xenbus.c       | 125 +++++++++++++++++++++++++++++++++++++++++
 console/xencons_ring.c |   6 +-
 include/console.h      |   5 ++
 include/lib.h          |   3 +-
 lib/sys.c              |  87 +++++++---------------------
 5 files changed, 155 insertions(+), 71 deletions(-)

diff --git a/console/xenbus.c b/console/xenbus.c
index 05fc31c..b856c84 100644
--- a/console/xenbus.c
+++ b/console/xenbus.c
@@ -192,3 +192,128 @@ void fini_consfront(struct consfront_dev *dev)
 {
     if (dev) free_consfront(dev);
 }
+
+#ifdef HAVE_LIBC
+static int consfront_read(int fd, void *buf, size_t nbytes)
+{
+    int ret;
+    struct file *file = get_file_from_fd(fd);
+    DEFINE_WAIT(w);
+
+    while ( 1 )
+    {
+        add_waiter(w, console_queue);
+        ret = xencons_ring_recv(file->dev, buf, nbytes);
+        if ( ret )
+            break;
+        schedule();
+    }
+
+    remove_waiter(w, console_queue);
+
+    return ret;
+}
+
+static int savefile_write(int fd, const void *buf, size_t nbytes)
+{
+    int ret = 0, tot = nbytes;
+    struct file *file = get_file_from_fd(fd);
+
+    while ( nbytes > 0 )
+    {
+        ret = xencons_ring_send(file->dev, (char *)buf, nbytes);
+        nbytes -= ret;
+        buf = (char *)buf + ret;
+    }
+
+    return tot - nbytes;
+}
+
+static int console_write(int fd, const void *buf, size_t nbytes)
+{
+    struct file *file = get_file_from_fd(fd);
+
+    console_print(file->dev, (char *)buf, nbytes);
+
+    return nbytes;
+}
+
+static int consfront_close_fd(int fd)
+{
+    struct file *file = get_file_from_fd(fd);
+
+    fini_consfront(file->dev);
+
+    return 0;
+}
+
+static int consfront_fstat(int fd, struct stat *buf)
+{
+    struct file *file = get_file_from_fd(fd);
+
+    buf->st_mode = S_IRUSR | S_IWUSR;
+    buf->st_mode |= (file->type == FTYPE_CONSOLE) ? S_IFCHR : S_IFREG;
+    buf->st_atime = buf->st_mtime = buf->st_ctime = time(NULL);
+
+    return 0;
+}
+
+static bool consfront_select_rd(int fd)
+{
+    struct file *file = get_file_from_fd(fd);
+
+    return xencons_ring_avail(file->dev);
+}
+
+static struct file_ops savefile_ops = {
+    .name = "savefile",
+    .read = consfront_read,
+    .write = savefile_write,
+    .close = consfront_close_fd,
+    .fstat = consfront_fstat,
+    .select_rd = consfront_select_rd,
+    .select_wr = select_yes,
+};
+
+struct file_ops console_ops = {
+    .name = "console",
+    .read = consfront_read,
+    .write = console_write,
+    .close = consfront_close_fd,
+    .fstat = consfront_fstat,
+    .select_rd = consfront_select_rd,
+    .select_wr = select_yes,
+};
+
+int open_consfront(char *nodename)
+{
+    struct consfront_dev *dev;
+    static unsigned int ftype_savefile;
+    unsigned int ftype;
+    struct file *file;
+
+    dev = init_consfront(nodename);
+    if ( !dev )
+        return -1;
+
+    if ( nodename )
+    {
+        if ( !ftype_savefile )
+            ftype_savefile = alloc_file_type(&savefile_ops);
+        ftype = ftype_savefile;
+    }
+    else
+        ftype = FTYPE_CONSOLE;
+
+    dev->fd = alloc_fd(ftype);
+    file = get_file_from_fd(dev->fd);
+    if ( !file )
+    {
+        fini_consfront(dev);
+        return -1;
+    }
+    file->dev = dev;
+
+    return dev->fd;
+}
+#endif
diff --git a/console/xencons_ring.c b/console/xencons_ring.c
index c348f3c..efedf46 100644
--- a/console/xencons_ring.c
+++ b/console/xencons_ring.c
@@ -99,10 +99,10 @@ void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data)
 {
 	struct consfront_dev *dev = (struct consfront_dev *) data;
 #ifdef HAVE_LIBC
-        int fd = dev ? dev->fd : -1;
+        struct file *file = dev ? get_file_from_fd(dev->fd) : NULL;
 
-        if (fd != -1)
-            files[fd].read = true;
+        if ( file )
+            file->read = true;
 
         wake_up(&console_queue);
 #else
diff --git a/include/console.h b/include/console.h
index 0d7bf07..8c615d0 100644
--- a/include/console.h
+++ b/include/console.h
@@ -39,6 +39,7 @@
 #include <mini-os/os.h>
 #include <mini-os/traps.h>
 #include <mini-os/types.h>
+#include <mini-os/lib.h>
 #include <xen/grant_table.h>
 #include <xenbus.h>
 #include <xen/io/console.h>
@@ -93,5 +94,9 @@ int xencons_ring_send_no_notify(struct consfront_dev *dev, const char *data, uns
 int xencons_ring_avail(struct consfront_dev *dev);
 int xencons_ring_recv(struct consfront_dev *dev, char *data, unsigned len);
 void free_consfront(struct consfront_dev *dev);
+#ifdef HAVE_LIBC
+extern struct file_ops console_ops;
+int open_consfront(char *nodename);
+#endif
 
 #endif /* _LIB_CONSOLE_H_ */
diff --git a/include/lib.h b/include/lib.h
index 653a16e..c171fe8 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -160,8 +160,7 @@ void sanity_check(void);
 #define FTYPE_FILE       2
 #define FTYPE_SOCKET     3
 #define FTYPE_MEM        4
-#define FTYPE_SAVEFILE   5
-#define FTYPE_N          6
+#define FTYPE_N          5
 #define FTYPE_SPARE     16
 
 typedef int file_read_func(int fd, void *buf, size_t nbytes);
diff --git a/lib/sys.c b/lib/sys.c
index 4fb844f..3a8aa68 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -101,6 +101,9 @@ static struct file_ops file_ops_none = {
 
 static struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
     [FTYPE_NONE] = &file_ops_none,
+#ifdef CONFIG_CONSFRONT
+    [FTYPE_CONSOLE] = &console_ops,
+#endif
 };
 
 unsigned int alloc_file_type(struct file_ops *ops)
@@ -211,31 +214,26 @@ int mkdir(const char *pathname, mode_t mode)
 #ifdef CONFIG_CONSFRONT
 int posix_openpt(int flags)
 {
-    struct consfront_dev *dev;
+    int fd;
 
     /* Ignore flags */
+    fd = open_consfront(NULL);
+    printk("fd(%d) = posix_openpt\n", fd);
 
-    dev = init_consfront(NULL);
-    dev->fd = alloc_fd(FTYPE_CONSOLE);
-    files[dev->fd].dev = dev;
-
-    printk("fd(%d) = posix_openpt\n", dev->fd);
-    return(dev->fd);
+    return fd;
 }
 
 int open_savefile(const char *path, int save)
 {
-    struct consfront_dev *dev;
+    int fd;
     char nodename[64];
 
     snprintf(nodename, sizeof(nodename), "device/console/%d", save ? SAVE_CONSOLE : RESTORE_CONSOLE);
 
-    dev = init_consfront(nodename);
-    dev->fd = alloc_fd(FTYPE_SAVEFILE);
-    files[dev->fd].dev = dev;
+    fd = open_consfront(nodename);
+    printk("fd(%d) = open_savefile\n", fd);
 
-    printk("fd(%d) = open_savefile\n", dev->fd);
-    return(dev->fd);
+    return fd;
 }
 #else
 int posix_openpt(int flags)
@@ -285,20 +283,6 @@ int read(int fd, void *buf, size_t nbytes)
         return ops->read(fd, buf, nbytes);
 
     switch (files[fd].type) {
-        case FTYPE_SAVEFILE:
-	case FTYPE_CONSOLE: {
-	    int ret;
-            DEFINE_WAIT(w);
-            while(1) {
-                add_waiter(w, console_queue);
-                ret = xencons_ring_recv(files[fd].dev, buf, nbytes);
-                if (ret)
-                    break;
-                schedule();
-            }
-            remove_waiter(w, console_queue);
-            return ret;
-        }
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
 	    return lwip_read(files[fd].fd, buf, nbytes);
@@ -319,18 +303,6 @@ int write(int fd, const void *buf, size_t nbytes)
         return ops->write(fd, buf, nbytes);
 
     switch (files[fd].type) {
-        case FTYPE_SAVEFILE: {
-                int ret = 0, tot = nbytes;
-                while (nbytes > 0) {
-                    ret = xencons_ring_send(files[fd].dev, (char *)buf, nbytes);
-                    nbytes -= ret;
-                    buf = (char *)buf + ret;
-                }
-                return tot - nbytes;
-            }
-	case FTYPE_CONSOLE:
-	    console_print(files[fd].dev, (char *)buf, nbytes);
-	    return nbytes;
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
 	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
@@ -418,12 +390,6 @@ int close(int fd)
 	case FTYPE_SOCKET:
 	    res = lwip_close(files[fd].fd);
             break;
-#endif
-#ifdef CONFIG_CONSFRONT
-        case FTYPE_SAVEFILE:
-        case FTYPE_CONSOLE:
-            fini_consfront(files[fd].dev);
-            break;
 #endif
 	case FTYPE_NONE:
             printk("close(%d): Bad descriptor\n", fd);
@@ -464,15 +430,8 @@ int fstat(int fd, struct stat *buf)
         return ops->fstat(fd, buf);
 
     switch (files[fd].type) {
-	case FTYPE_SAVEFILE:
-	case FTYPE_CONSOLE:
 	case FTYPE_SOCKET: {
-            if (files[fd].type == FTYPE_CONSOLE)
-                buf->st_mode = S_IFCHR|S_IRUSR|S_IWUSR;
-            else if (files[fd].type == FTYPE_SOCKET)
-                buf->st_mode = S_IFSOCK|S_IRUSR|S_IWUSR;
-            else if (files[fd].type == FTYPE_SAVEFILE)
-                buf->st_mode = S_IFREG|S_IRUSR|S_IWUSR;
+            buf->st_mode = S_IFSOCK|S_IRUSR|S_IWUSR;
 	    buf->st_uid = 0;
 	    buf->st_gid = 0;
 	    buf->st_size = 0;
@@ -583,7 +542,6 @@ int closedir(DIR *dir)
 #if defined(LIBC_DEBUG) || defined(LIBC_VERBOSE)
 static const char *file_types[] = {
     [FTYPE_NONE]    = "none",
-    [FTYPE_CONSOLE] = "console",
     [FTYPE_SOCKET]  = "socket",
 };
 
@@ -744,21 +702,18 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
             }
 
 	    if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
+            {
 		printk("bogus fd %d in select\n", i);
-	    /* Fallthrough.  */
-        }
-
-	case FTYPE_CONSOLE:
-	    if (FD_ISSET(i, readfds)) {
-                if (xencons_ring_avail(files[i].dev))
-		    n++;
-		else
-		    FD_CLR(i, readfds);
+                if ( FD_ISSET(i, readfds) )
+                    FD_CLR(i, readfds);
+                if ( FD_ISSET(i, writefds) )
+                    FD_CLR(i, writefds);
+                if ( FD_ISSET(i, exceptfds) )
+                    FD_CLR(i, exceptfds);
             }
-	    if (FD_ISSET(i, writefds))
-                n++;
-	    FD_CLR(i, exceptfds);
 	    break;
+        }
+
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
 	    if (FD_ISSET(i, readfds)) {
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:12:27 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:12:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255874.438783 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ip1-0003qa-OU; Tue, 11 Jan 2022 15:12:27 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255874.438783; Tue, 11 Jan 2022 15:12:27 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ip0-0003mU-ML; Tue, 11 Jan 2022 15:12:26 +0000
Received: by outflank-mailman (input) for mailman id 255874;
 Tue, 11 Jan 2022 15:12:24 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ioy-0002Fw-DI
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 15:12:24 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id ddef8a1b-72f0-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 16:12:18 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 43AEB1F3B1;
 Tue, 11 Jan 2022 15:12:18 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1886213DDD;
 Tue, 11 Jan 2022 15:12:18 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id EL60BFKe3WG8AwAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 15:12:18 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ddef8a1b-72f0-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913938; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=jVhuzq1ru9rCdLBgGyz4Ec9Qdw5HVMOj866c/uvvnJ8=;
	b=fyJ4xFFUjaB4MnesIRmrqRCUyyfsdRLZi/4jAokXUD4t39jqDelNiYROsMocP1Jn8duNF5
	3aXoFY79DAEDfznK9s5FKTjKbNTmsAm4DM/K6s+zw14+ofdru7KNAIy+Y4wnFdCIr+Zlo6
	tgL1v0m2i/UlH2Hrb05Ko68zCifDARI=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 07/12] mini-os: use get_file_from_fd() in netfront
Date: Tue, 11 Jan 2022 16:12:10 +0100
Message-Id: <20220111151215.22955-8-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111151215.22955-1-jgross@suse.com>
References: <20220111151215.22955-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h |  3 +--
 lib/sys.c     | 23 ------------------
 netfront.c    | 64 ++++++++++++++++++++++++++++++++++++++++++++-------
 3 files changed, 57 insertions(+), 33 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 05f5083..aa8036e 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -163,8 +163,7 @@ void sanity_check(void);
 #define FTYPE_SAVEFILE   5
 #define FTYPE_FB         6
 #define FTYPE_KBD        7
-#define FTYPE_TAP        8
-#define FTYPE_N          9
+#define FTYPE_N          8
 #define FTYPE_SPARE     16
 
 typedef int file_read_func(int fd, void *buf, size_t nbytes);
diff --git a/lib/sys.c b/lib/sys.c
index f84fedd..7f2e11f 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -303,17 +303,6 @@ int read(int fd, void *buf, size_t nbytes)
 	case FTYPE_SOCKET:
 	    return lwip_read(files[fd].fd, buf, nbytes);
 #endif
-#ifdef CONFIG_NETFRONT
-	case FTYPE_TAP: {
-	    ssize_t ret;
-	    ret = netfront_receive(files[fd].dev, buf, nbytes);
-	    if (ret <= 0) {
-		errno = EAGAIN;
-		return -1;
-	    }
-	    return ret;
-	}
-#endif
 #ifdef CONFIG_KBDFRONT
         case FTYPE_KBD: {
             int ret, n;
@@ -369,11 +358,6 @@ int write(int fd, const void *buf, size_t nbytes)
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
 	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
-#endif
-#ifdef CONFIG_NETFRONT
-	case FTYPE_TAP:
-	    netfront_xmit(files[fd].dev, (void*) buf, nbytes);
-	    return nbytes;
 #endif
 	default:
 	    break;
@@ -459,11 +443,6 @@ int close(int fd)
 	    res = lwip_close(files[fd].fd);
             break;
 #endif
-#ifdef CONFIG_NETFRONT
-	case FTYPE_TAP:
-	    shutdown_netfront(files[fd].dev);
-            break;
-#endif
 #ifdef CONFIG_KBDFRONT
 	case FTYPE_KBD:
             shutdown_kbdfront(files[fd].dev);
@@ -640,7 +619,6 @@ static const char *file_types[] = {
     [FTYPE_NONE]    = "none",
     [FTYPE_CONSOLE] = "console",
     [FTYPE_SOCKET]  = "socket",
-    [FTYPE_TAP]     = "net",
     [FTYPE_KBD]     = "kbd",
     [FTYPE_FB]      = "fb",
 };
@@ -817,7 +795,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
                 n++;
 	    FD_CLR(i, exceptfds);
 	    break;
-	case FTYPE_TAP:
 	case FTYPE_KBD:
 	case FTYPE_FB:
 	    if (FD_ISSET(i, readfds)) {
diff --git a/netfront.c b/netfront.c
index 7696451..f86c6a2 100644
--- a/netfront.c
+++ b/netfront.c
@@ -248,14 +248,14 @@ void netfront_select_handler(evtchn_port_t port, struct pt_regs *regs, void *dat
 {
     int flags;
     struct netfront_dev *dev = data;
-    int fd = dev->fd;
+    struct file *file = get_file_from_fd(dev->fd);
 
     local_irq_save(flags);
     network_tx_buf_gc(dev);
     local_irq_restore(flags);
 
-    if (fd != -1)
-        files[fd].read = true;
+    if ( file )
+        file->read = true;
     wake_up(&netfront_queue);
 }
 #endif
@@ -565,8 +565,54 @@ error:
 }
 
 #ifdef HAVE_LIBC
+static int netfront_read(int fd, void *buf, size_t nbytes)
+{
+    ssize_t ret;
+    struct file *file = get_file_from_fd(fd);
+
+    ret = netfront_receive(file->dev, buf, nbytes);
+    if ( ret <= 0 )
+    {
+        errno = EAGAIN;
+        return -1;
+    }
+
+    return ret;
+}
+
+static int netfront_write(int fd, const void *buf, size_t nbytes)
+{
+    struct file *file = get_file_from_fd(fd);
+
+    netfront_xmit(file->dev, (void *)buf, nbytes);
+
+    return nbytes;
+}
+
+static int netfront_close_fd(int fd)
+{
+    struct file *file = get_file_from_fd(fd);
+
+    shutdown_netfront(file->dev);
+
+    return 0;
+}
+
+static struct file_ops netfront_ops = {
+    .name = "net",
+    .read = netfront_read,
+    .write = netfront_write,
+    .close = netfront_close_fd,
+    .select_rd = select_read_flag,
+};
+
 int netfront_tap_open(char *nodename) {
     struct netfront_dev *dev;
+    struct file *file;
+    static unsigned int ftype_netfront;
+
+    if ( !ftype_netfront )
+        ftype_netfront = alloc_file_type(&netfront_ops);
 
     dev = init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL);
     if (!dev) {
@@ -574,9 +620,10 @@ int netfront_tap_open(char *nodename) {
 	errno = EIO;
 	return -1;
     }
-    dev->fd = alloc_fd(FTYPE_TAP);
+    dev->fd = alloc_fd(ftype_netfront);
     printk("tap_open(%s) -> %d\n", nodename, dev->fd);
-    files[dev->fd].dev = dev;
+    file = get_file_from_fd(dev->fd);
+    file->dev = dev;
     return dev->fd;
 }
 #endif
@@ -772,7 +819,8 @@ void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len)
 ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t len)
 {
     unsigned long flags;
-    int fd = dev->fd;
+    struct file *file = get_file_from_fd(dev->fd);
+
     ASSERT(current == main_thread);
 
     dev->rlen = 0;
@@ -781,9 +829,9 @@ ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t l
 
     local_irq_save(flags);
     network_rx(dev);
-    if (!dev->rlen && fd != -1)
+    if ( !dev->rlen && file )
         /* No data for us, make select stop returning */
-        files[fd].read = false;
+        file->read = false;
     /* Before re-enabling the interrupts, in case a packet just arrived in the
      * meanwhile. */
     local_irq_restore(flags);
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:12:31 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:12:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255878.438803 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ip5-0004XX-5g; Tue, 11 Jan 2022 15:12:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255878.438803; Tue, 11 Jan 2022 15:12:30 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ip4-0004U5-Cw; Tue, 11 Jan 2022 15:12:30 +0000
Received: by outflank-mailman (input) for mailman id 255878;
 Tue, 11 Jan 2022 15:12:26 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ip0-0002Fw-Dk
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 15:12:26 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id ddce9212-72f0-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 16:12:18 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 10C69212CA;
 Tue, 11 Jan 2022 15:12:18 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DECFF13DDD;
 Tue, 11 Jan 2022 15:12:17 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 0FpANVGe3WG8AwAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 15:12:17 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ddce9212-72f0-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913938; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=THtUtk0c0qdaxelPl/C+8VH9LB692eb/zBc/uFOuwwQ=;
	b=vKJEN28JIArVqpWVZTeqYRy4g4OU9gH+pS+WPLnZmfXn4JtfTQnaXR4xV1gx1rOmKlrH7j
	mQBXhesIVlqrukqW5u5OqsQpmcAF9tRbuQ6CqiRH7FtEKMPRc6L0+MF+1ED1KtsJ1BFNpB
	/0SYyHP/lOWL8f4N6KqIurpds9GOLqg=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 06/12] mini-os: use alloc_file_type() and get_file_from_fd() in blkfront
Date: Tue, 11 Jan 2022 16:12:09 +0100
Message-Id: <20220111151215.22955-7-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111151215.22955-1-jgross@suse.com>
References: <20220111151215.22955-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Allocate the file type dynamically via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 blkfront.c         | 92 ++++++++++++++++++++++++++++++++++------------
 include/blkfront.h |  5 ---
 include/lib.h      |  3 +-
 lib/sys.c          | 24 ------------
 4 files changed, 69 insertions(+), 55 deletions(-)

diff --git a/blkfront.c b/blkfront.c
index e3f42be..b7ea1d7 100644
--- a/blkfront.c
+++ b/blkfront.c
@@ -59,10 +59,10 @@ void blkfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
 {
 #ifdef HAVE_LIBC
     struct blkfront_dev *dev = data;
-    int fd = dev->fd;
+    struct file *file = get_file_from_fd(dev->fd);
 
-    if (fd != -1)
-        files[fd].read = true;
+    if ( file )
+        file->read = true;
 #endif
     wake_up(&blkfront_queue);
 }
@@ -483,9 +483,13 @@ int blkfront_aio_poll(struct blkfront_dev *dev)
 
 moretodo:
 #ifdef HAVE_LIBC
-    if (dev->fd != -1) {
-        files[dev->fd].read = false;
-        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
+    {
+        struct file *file = get_file_from_fd(dev->fd);
+
+        if ( file ) {
+            file->read = false;
+            mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
+        }
     }
 #endif
 
@@ -554,22 +558,11 @@ moretodo:
 }
 
 #ifdef HAVE_LIBC
-int blkfront_open(struct blkfront_dev *dev)
-{
-    /* Silently prevent multiple opens */
-    if(dev->fd != -1) {
-       return dev->fd;
-    }
-    dev->fd = alloc_fd(FTYPE_BLK);
-    printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].dev = dev;
-    return dev->fd;
-}
-
-int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
+static int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
 {
-   struct blkfront_dev* dev = files[fd].dev;
-   off_t offset = files[fd].offset;
+   struct file *file = get_file_from_fd(fd);
+   struct blkfront_dev* dev = file->dev;
+   off_t offset = file->offset;
    struct blkfront_aiocb aiocb;
    unsigned long long disksize = dev->info.sectors * dev->info.sector_size;
    unsigned int blocksize = dev->info.sector_size;
@@ -711,14 +704,25 @@ int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
    }
 
    free(copybuf);
-   files[fd].offset += rc;
+   file->offset += rc;
    return rc;
 
 }
 
-int blkfront_posix_fstat(int fd, struct stat* buf)
+static int blkfront_posix_read(int fd, void *buf, size_t nbytes)
+{
+    return blkfront_posix_rwop(fd, buf, nbytes, 0);
+}
+
+static int blkfront_posix_write(int fd, const void *buf, size_t nbytes)
 {
-   struct blkfront_dev* dev = files[fd].dev;
+    return blkfront_posix_rwop(fd, (void *)buf, nbytes, 1);
+}
+
+static int blkfront_posix_fstat(int fd, struct stat *buf)
+{
+   struct file *file = get_file_from_fd(fd);
+   struct blkfront_dev* dev = file->dev;
 
    buf->st_mode = dev->info.mode;
    buf->st_uid = 0;
@@ -728,4 +732,44 @@ int blkfront_posix_fstat(int fd, struct stat* buf)
 
    return 0;
 }
+
+static int blkfront_close_fd(int fd)
+{
+    struct file *file = get_file_from_fd(fd);
+
+    shutdown_blkfront(file->dev);
+
+    return 0;
+}
+
+static struct file_ops blk_ops = {
+    .name = "blk",
+    .read = blkfront_posix_read,
+    .write = blkfront_posix_write,
+    .lseek = lseek_default,
+    .close = blkfront_close_fd,
+    .fstat = blkfront_posix_fstat,
+    .select_rd = select_read_flag,
+};
+
+int blkfront_open(struct blkfront_dev *dev)
+{
+    struct file *file;
+    static unsigned int ftype_blk;
+
+    /* Silently prevent multiple opens */
+    if(dev->fd != -1) {
+       return dev->fd;
+    }
+
+    if ( !ftype_blk )
+        ftype_blk = alloc_file_type(&blk_ops);
+
+    dev->fd = alloc_fd(ftype_blk);
+    printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
+    file = get_file_from_fd(dev->fd);
+    file->dev = dev;
+
+    return dev->fd;
+}
 #endif
diff --git a/include/blkfront.h b/include/blkfront.h
index 3528af9..7f84a0a 100644
--- a/include/blkfront.h
+++ b/include/blkfront.h
@@ -28,17 +28,12 @@ struct blkfront_info
 };
 struct blkfront_dev *init_blkfront(char *nodename, struct blkfront_info *info);
 #ifdef HAVE_LIBC
-#include <sys/stat.h>
 /* POSIX IO functions:
  * use blkfront_open() to get a file descriptor to the block device
  * Don't use the other blkfront posix functions here directly, instead use
  * read(), write(), lseek() and fstat() on the file descriptor
  */
 int blkfront_open(struct blkfront_dev *dev);
-int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write);
-#define blkfront_posix_write(fd, buf, count) blkfront_posix_rwop(fd, (uint8_t*)buf, count, 1)
-#define blkfront_posix_read(fd, buf, count) blkfront_posix_rwop(fd, (uint8_t*)buf, count, 0)
-int blkfront_posix_fstat(int fd, struct stat* buf);
 #endif
 void blkfront_aio(struct blkfront_aiocb *aiocbp, int write);
 #define blkfront_aio_read(aiocbp) blkfront_aio(aiocbp, 0)
diff --git a/include/lib.h b/include/lib.h
index f6478de..05f5083 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -164,8 +164,7 @@ void sanity_check(void);
 #define FTYPE_FB         6
 #define FTYPE_KBD        7
 #define FTYPE_TAP        8
-#define FTYPE_BLK        9
-#define FTYPE_N         10
+#define FTYPE_N          9
 #define FTYPE_SPARE     16
 
 typedef int file_read_func(int fd, void *buf, size_t nbytes);
diff --git a/lib/sys.c b/lib/sys.c
index ff6be52..f84fedd 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -337,11 +337,6 @@ int read(int fd, void *buf, size_t nbytes)
 	    }
 	    return ret * sizeof(union xenfb_in_event);
         }
-#endif
-#ifdef CONFIG_BLKFRONT
-        case FTYPE_BLK: {
-	    return blkfront_posix_read(fd, buf, nbytes);
-        }
 #endif
 	default:
 	    break;
@@ -379,10 +374,6 @@ int write(int fd, const void *buf, size_t nbytes)
 	case FTYPE_TAP:
 	    netfront_xmit(files[fd].dev, (void*) buf, nbytes);
 	    return nbytes;
-#endif
-#ifdef CONFIG_BLKFRONT
-	case FTYPE_BLK:
-	    return blkfront_posix_write(fd, buf, nbytes);
 #endif
 	default:
 	    break;
@@ -432,10 +423,6 @@ off_t lseek(int fd, off_t offset, int whence)
         return ops->lseek(fd, offset, whence);
 
     switch(files[fd].type) {
-#ifdef CONFIG_BLKFRONT
-       case FTYPE_BLK:
-          break;
-#endif
        case FTYPE_FILE:
           break;
        default:
@@ -477,11 +464,6 @@ int close(int fd)
 	    shutdown_netfront(files[fd].dev);
             break;
 #endif
-#ifdef CONFIG_BLKFRONT
-	case FTYPE_BLK:
-            shutdown_blkfront(files[fd].dev);
-            break;
-#endif
 #ifdef CONFIG_KBDFRONT
 	case FTYPE_KBD:
             shutdown_kbdfront(files[fd].dev);
@@ -554,10 +536,6 @@ int fstat(int fd, struct stat *buf)
 	    buf->st_ctime = time(NULL);
 	    return 0;
 	}
-#ifdef CONFIG_BLKFRONT
-	case FTYPE_BLK:
-	   return blkfront_posix_fstat(fd, buf);
-#endif
 	default:
 	    break;
     }
@@ -663,7 +641,6 @@ static const char *file_types[] = {
     [FTYPE_CONSOLE] = "console",
     [FTYPE_SOCKET]  = "socket",
     [FTYPE_TAP]     = "net",
-    [FTYPE_BLK]     = "blk",
     [FTYPE_KBD]     = "kbd",
     [FTYPE_FB]      = "fb",
 };
@@ -841,7 +818,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 	    FD_CLR(i, exceptfds);
 	    break;
 	case FTYPE_TAP:
-	case FTYPE_BLK:
 	case FTYPE_KBD:
 	case FTYPE_FB:
 	    if (FD_ISSET(i, readfds)) {
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:12:31 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:12:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255877.438807 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ip5-0004Vg-K1; Tue, 11 Jan 2022 15:12:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255877.438807; Tue, 11 Jan 2022 15:12:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ip4-0004Qp-6p; Tue, 11 Jan 2022 15:12:30 +0000
Received: by outflank-mailman (input) for mailman id 255877;
 Tue, 11 Jan 2022 15:12:26 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ioz-0002Fv-W1
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 15:12:26 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id de7324e1-72f0-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 16:12:19 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 1802F1F3B9;
 Tue, 11 Jan 2022 15:12:19 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E27A913DDD;
 Tue, 11 Jan 2022 15:12:18 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id MH/eNVKe3WG8AwAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 15:12:18 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: de7324e1-72f0-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913939; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=LT7y4F0rIJkzgfg3Wqk+kFvoECYDkYG0U0o/MY4F4aI=;
	b=J3Y9NA+QaK3CF8Btdh7yERlbdXYM4SHcMGD4DBHtgKs4C1sRKVE81UI0g2nNwB9bek+8ly
	Gx+PHio0I06zucoyCKZq/DjGp0OJMqhiLm1Ei/YJVqbBkKTwIFK8d7ACGJ6G5qp147LkSC
	2znecvy9nwsbg1LkPq6Hmb1Ni3fLgtw=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 11/12] mini-os: add struct file_ops for FTYPE_FILE
Date: Tue, 11 Jan 2022 16:12:14 +0100
Message-Id: <20220111151215.22955-12-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111151215.22955-1-jgross@suse.com>
References: <20220111151215.22955-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

FTYPE_FILE is the last relevant file type without a struct file_ops.
Add it.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 lib/sys.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/lib/sys.c b/lib/sys.c
index 12deaed..0f42e97 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -99,6 +99,11 @@ static struct file_ops file_ops_none = {
     .name = "none",
 };
 
+static struct file_ops file_file_ops = {
+    .name = "file",
+    .lseek = lseek_default,
+};
+
 #ifdef HAVE_LWIP
 static int socket_read(int fd, void *buf, size_t nbytes)
 {
@@ -160,6 +165,7 @@ static struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
 #ifdef CONFIG_CONSFRONT
     [FTYPE_CONSOLE] = &console_ops,
 #endif
+    [FTYPE_FILE] = &file_file_ops,
 #ifdef HAVE_LWIP
     [FTYPE_SOCKET] = &socket_ops,
 #endif
@@ -397,16 +403,9 @@ off_t lseek(int fd, off_t offset, int whence)
     if ( ops->lseek )
         return ops->lseek(fd, offset, whence);
 
-    switch(files[fd].type) {
-       case FTYPE_FILE:
-          break;
-       default:
-          /* Not implemented for this filetype */
-          errno = ESPIPE;
-          return (off_t) -1;
-    }
-
-    return lseek_default(fd, offset, whence);
+    /* Not implemented for this filetype */
+    errno = ESPIPE;
+    return (off_t) -1;
 }
 
 int fsync(int fd) {
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:19:29 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:19:29 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255904.438872 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ivo-0001q6-1c; Tue, 11 Jan 2022 15:19:28 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255904.438872; Tue, 11 Jan 2022 15:19:28 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ivn-0001pz-Uf; Tue, 11 Jan 2022 15:19:27 +0000
Received: by outflank-mailman (input) for mailman id 255904;
 Tue, 11 Jan 2022 15:19:26 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ip6-0002Fw-FF
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 15:12:32 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id de878388-72f0-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 16:12:19 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 466151F3BA;
 Tue, 11 Jan 2022 15:12:19 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1F80B13DDD;
 Tue, 11 Jan 2022 15:12:19 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 6JqoBlOe3WG8AwAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 15:12:19 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: de878388-72f0-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913939; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=cFwpD60ZcJNKwT6VpP/TNivSPE9GLBBs9qy9595IhG4=;
	b=Zl160vCEssZCDKXNooVkVMdF+ZGxizKNsTLHQIHyHoirX1qQQpo57vSIKxqXGstRXLF0FM
	4nabICwSmWFWby2PVJnme7m2SpFZJrFSM/4KnosLnIoyDCWZoToEhmpqN1jLOfs/xTUeqU
	2WRjo1La8bfIpj1bKgVtvaVaq7nswWc=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 12/12] mini-os: make files array private to sys.c
Date: Tue, 11 Jan 2022 16:12:15 +0100
Message-Id: <20220111151215.22955-13-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111151215.22955-1-jgross@suse.com>
References: <20220111151215.22955-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

There is no user of the files[] array outside of lib/sys.c left, so
it can be made static.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h | 2 --
 lib/sys.c     | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index c171fe8..80e804b 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -199,8 +199,6 @@ struct file {
     };
 };
 
-extern struct file files[];
-
 struct file *get_file_from_fd(int fd);
 int alloc_fd(unsigned int type);
 void close_all_files(void);
diff --git a/lib/sys.c b/lib/sys.c
index 0f42e97..c0cad87 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -89,7 +89,7 @@ extern void minios_evtchn_close_fd(int fd);
 extern void minios_gnttab_close_fd(int fd);
 
 pthread_mutex_t fd_lock = PTHREAD_MUTEX_INITIALIZER;
-struct file files[NOFILE] = {
+static struct file files[NOFILE] = {
     { .type = FTYPE_CONSOLE }, /* stdin */
     { .type = FTYPE_CONSOLE }, /* stdout */
     { .type = FTYPE_CONSOLE }, /* stderr */
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:22:57 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:22:57 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255928.438916 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IzA-0004r0-7k; Tue, 11 Jan 2022 15:22:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255928.438916; Tue, 11 Jan 2022 15:22:56 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7IzA-0004qs-4d; Tue, 11 Jan 2022 15:22:56 +0000
Received: by outflank-mailman (input) for mailman id 255928;
 Tue, 11 Jan 2022 15:22:54 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ip4-0002Fw-Ec
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 15:12:30 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id de4d45f5-72f0-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 16:12:19 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id DBC7B1F3B8;
 Tue, 11 Jan 2022 15:12:18 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B2E1813DDD;
 Tue, 11 Jan 2022 15:12:18 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id SOJ9KlKe3WG8AwAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 15:12:18 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: de4d45f5-72f0-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913938; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=/J7Pbzy4bEMLs1Zfn02zqrQKoe12Kbt0uIHiCf5rrSk=;
	b=jRefBonpoL7Y3znlLNWa9M4TFpzlRZgE9MInSr2UJlJjav+cOsfGIENNqmwfxbIwkiCE0f
	grByPAHUcFc8WpgtefmOUQnilaHoq3aZTTO/yd163GJ7UfkwpckSX0VxO6mgoSJ/mNwO0A
	b4Tc4nZMc0y/ZgNUEgjRMXOdYxelxYU=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 10/12] mini-os: add struct file_ops for file type socket
Date: Tue, 11 Jan 2022 16:12:13 +0100
Message-Id: <20220111151215.22955-11-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111151215.22955-1-jgross@suse.com>
References: <20220111151215.22955-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Even with some special handling needed in select_poll(), add a struct
file_ops for FTYPE_SOCKET. Due to the need of the special handling it
isn't possible to use a dynamically allocated file type.

Most functions calling the file_ops methods can be simplified a lot now
that no file type specific handling is left. Same applies to the file
type name printing in debug/verbose mode.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 lib/sys.c | 153 +++++++++++++++++++++++++-----------------------------
 1 file changed, 70 insertions(+), 83 deletions(-)

diff --git a/lib/sys.c b/lib/sys.c
index 3a8aa68..12deaed 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -99,11 +99,70 @@ static struct file_ops file_ops_none = {
     .name = "none",
 };
 
+#ifdef HAVE_LWIP
+static int socket_read(int fd, void *buf, size_t nbytes)
+{
+    return lwip_read(fd, buf, nbytes);
+}
+
+static int socket_write(int fd, const void *buf, size_t nbytes)
+{
+    return lwip_write(fd, (void *)buf, nbytes);
+}
+
+static int close_socket_fd(int fd)
+{
+    struct file *file = get_file_from_fd(fd);
+
+    return lwip_close(file->fd);
+}
+
+static int socket_fstat(int fd, struct stat *buf)
+{
+    buf->st_mode = S_IFSOCK | S_IRUSR | S_IWUSR;
+    buf->st_atime = buf->st_mtime = buf->st_ctime = time(NULL);
+
+    return 0;
+}
+
+static int socket_fcntl(int fd, int cmd, va_list args)
+{
+    long arg;
+    struct file *file = get_file_from_fd(fd);
+
+    arg = va_arg(args, long);
+
+    if ( cmd == F_SETFL && !(arg & ~O_NONBLOCK) )
+    {
+        /* Only flag supported: non-blocking mode */
+        uint32_t nblock = !!(arg & O_NONBLOCK);
+
+        return lwip_ioctl(file->fd, FIONBIO, &nblock);
+    }
+
+    printk("fcntl(%d, %d, %lx/%lo)\n", fd, cmd, arg, arg);
+    errno = ENOSYS;
+    return -1;
+}
+
+static struct file_ops socket_ops = {
+    .name = "socket",
+    .read = socket_read,
+    .write = socket_write,
+    .close = close_socket_fd,
+    .fstat = socket_fstat,
+    .fcntl = socket_fcntl,
+};
+#endif
+
 static struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
     [FTYPE_NONE] = &file_ops_none,
 #ifdef CONFIG_CONSFRONT
     [FTYPE_CONSOLE] = &console_ops,
 #endif
+#ifdef HAVE_LWIP
+    [FTYPE_SOCKET] = &socket_ops,
+#endif
 };
 
 unsigned int alloc_file_type(struct file_ops *ops)
@@ -282,14 +341,6 @@ int read(int fd, void *buf, size_t nbytes)
     if ( ops->read )
         return ops->read(fd, buf, nbytes);
 
-    switch (files[fd].type) {
-#ifdef HAVE_LWIP
-	case FTYPE_SOCKET:
-	    return lwip_read(files[fd].fd, buf, nbytes);
-#endif
-	default:
-	    break;
-    }
     printk("read(%d): Bad descriptor\n", fd);
     errno = EBADF;
     return -1;
@@ -302,14 +353,6 @@ int write(int fd, const void *buf, size_t nbytes)
     if ( ops->write )
         return ops->write(fd, buf, nbytes);
 
-    switch (files[fd].type) {
-#ifdef HAVE_LWIP
-	case FTYPE_SOCKET:
-	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
-#endif
-	default:
-	    break;
-    }
     printk("write(%d): Bad descriptor\n", fd);
     errno = EBADF;
     return -1;
@@ -378,26 +421,14 @@ int close(int fd)
 
     printk("close(%d)\n", fd);
     if ( ops->close )
-    {
         res = ops->close(fd);
-        goto out;
-    }
-
-    switch (files[fd].type) {
-        default:
-            break;
-#ifdef HAVE_LWIP
-	case FTYPE_SOCKET:
-	    res = lwip_close(files[fd].fd);
-            break;
-#endif
-	case FTYPE_NONE:
-            printk("close(%d): Bad descriptor\n", fd);
-            errno = EBADF;
-            return -1;
+    else if ( files[fd].type == FTYPE_NONE )
+    {
+        printk("close(%d): Bad descriptor\n", fd);
+        errno = EBADF;
+        return -1;
     }
 
- out:
     memset(files + fd, 0, sizeof(struct file));
     files[fd].type = FTYPE_NONE;
     return res;
@@ -429,21 +460,6 @@ int fstat(int fd, struct stat *buf)
     if ( ops->fstat )
         return ops->fstat(fd, buf);
 
-    switch (files[fd].type) {
-	case FTYPE_SOCKET: {
-            buf->st_mode = S_IFSOCK|S_IRUSR|S_IWUSR;
-	    buf->st_uid = 0;
-	    buf->st_gid = 0;
-	    buf->st_size = 0;
-	    buf->st_atime = 
-	    buf->st_mtime = 
-	    buf->st_ctime = time(NULL);
-	    return 0;
-	}
-	default:
-	    break;
-    }
-
     printk("statf(%d): Bad descriptor\n", fd);
     errno = EBADF;
     return -1;
@@ -491,21 +507,9 @@ int fcntl(int fd, int cmd, ...)
     arg = va_arg(ap, long);
     va_end(ap);
 
-    switch (cmd) {
-#ifdef HAVE_LWIP
-	case F_SETFL:
-	    if (files[fd].type == FTYPE_SOCKET && !(arg & ~O_NONBLOCK)) {
-		/* Only flag supported: non-blocking mode */
-		uint32_t nblock = !!(arg & O_NONBLOCK);
-		return lwip_ioctl(files[fd].fd, FIONBIO, &nblock);
-	    }
-	    /* Fallthrough */
-#endif
-	default:
-	    printk("fcntl(%d, %d, %lx/%lo)\n", fd, cmd, arg, arg);
-	    errno = ENOSYS;
-	    return -1;
-    }
+    printk("fcntl(%d, %d, %lx/%lo)\n", fd, cmd, arg, arg);
+    errno = ENOSYS;
+    return -1;
 }
 
 DIR *opendir(const char *name)
@@ -539,23 +543,6 @@ int closedir(DIR *dir)
 
 /* We assume that only the main thread calls select(). */
 
-#if defined(LIBC_DEBUG) || defined(LIBC_VERBOSE)
-static const char *file_types[] = {
-    [FTYPE_NONE]    = "none",
-    [FTYPE_SOCKET]  = "socket",
-};
-
-static char *get_type_name(unsigned int type)
-{
-    if ( type < ARRAY_SIZE(file_ops) && file_ops[type] )
-        return file_ops[type]->name;
-
-    if ( type < ARRAY_SIZE(file_types) && file_types[type] )
-        return file_types[type];
-
-    return "none";
-}
-#endif
 #ifdef LIBC_DEBUG
 static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
 {
@@ -566,7 +553,7 @@ static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *except
 	if (FD_ISSET(i, set)) { \
 	    if (comma) \
 		printk(", "); \
-	    printk("%d(%s)", i, get_type_name(files[i].type)); \
+	    printk("%d(%s)", i, get_file_ops(files[i].type)->name); \
 	    comma = 1; \
 	} \
     } \
@@ -600,7 +587,7 @@ static void dump_pollfds(struct pollfd *pfd, int nfds, int timeout)
         fd = pfd[i].fd;
         if (comma)
             printk(", ");
-        printk("%d(%s)/%02x", fd, get_type_name(files[fd].type),
+        printk("%d(%s)/%02x", fd, get_file_ops(files[fd].type)->name,
             pfd[i].events);
             comma = 1;
     }
@@ -754,7 +741,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 	printk("%d(%d): ", nb, sock_n);
 	for (i = 0; i < nfds; i++) {
 	    if (nbread[i] || nbwrite[i] || nbexcept[i])
-		printk(" %d(%c):", i, get_type_name(files[i].type));
+		printk(" %d(%c):", i, get_file_ops(files[i].type)->name);
 	    if (nbread[i])
 	    	printk(" %dR", nbread[i]);
 	    if (nbwrite[i])
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:24:12 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:24:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255931.438919 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7J0O-00051Y-CC; Tue, 11 Jan 2022 15:24:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255931.438919; Tue, 11 Jan 2022 15:24:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7J0O-00051R-8z; Tue, 11 Jan 2022 15:24:12 +0000
Received: by outflank-mailman (input) for mailman id 255931;
 Tue, 11 Jan 2022 15:24:10 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zHlr=R3=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ip2-0002Fw-ER
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 15:12:28 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id de12afa8-72f0-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 16:12:18 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 7E4B521112;
 Tue, 11 Jan 2022 15:12:18 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 46D881404B;
 Tue, 11 Jan 2022 15:12:18 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id oA8dEFKe3WG8AwAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 11 Jan 2022 15:12:18 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: de12afa8-72f0-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641913938; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=5MnAj8jgvGSVnTnQHkjtzzsrohe+jN87xvuOdqS22Ok=;
	b=KcLdTKRrhcktZcEEJ6Esn2gpSF88MuhbhNCD6QM3AustEX6MZ7SEVx4suCWZ3nVunF2TwJ
	lxSkdKdsjnuM5NTc9Zgmuhr9S0Rhgc05Q5hLhJr7xTTLOyvHJNM6p5tOqwd8dtMKnbXjwr
	/ARKUb/i+ujsZCsXg4NZTT7DQITZ2YM=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH v2 08/12] mini-os: use alloc_file_type() and get_file_from_fd() in fbfront
Date: Tue, 11 Jan 2022 16:12:11 +0100
Message-Id: <20220111151215.22955-9-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220111151215.22955-1-jgross@suse.com>
References: <20220111151215.22955-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Allocate file types dynamically via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 fbfront.c     | 125 ++++++++++++++++++++++++++++++++++++++++++--------
 include/lib.h |   4 +-
 lib/sys.c     |  47 -------------------
 3 files changed, 106 insertions(+), 70 deletions(-)

diff --git a/fbfront.c b/fbfront.c
index 1e055fb..9c96963 100644
--- a/fbfront.c
+++ b/fbfront.c
@@ -14,6 +14,9 @@
 #include <mini-os/xmalloc.h>
 #include <mini-os/fbfront.h>
 #include <mini-os/lib.h>
+#ifdef HAVE_LIBC
+#include <errno.h>
+#endif
 
 DECLARE_WAIT_QUEUE_HEAD(kbdfront_queue);
 
@@ -42,10 +45,10 @@ void kbdfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
 {
 #ifdef HAVE_LIBC
     struct kbdfront_dev *dev = data;
-    int fd = dev->fd;
+    struct file *file = get_file_from_fd(dev->fd);
 
-    if (fd != -1)
-        files[fd].read = true;
+    if ( file )
+        file->read = true;
 #endif
     wake_up(&kbdfront_queue);
 }
@@ -204,10 +207,12 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
     struct xenkbd_page *page = dev->page;
     uint32_t prod, cons;
     int i;
-
 #ifdef HAVE_LIBC
-    if (dev->fd != -1) {
-        files[dev->fd].read = false;
+    struct file *file = get_file_from_fd(dev->fd);
+
+    if ( file )
+    {
+        file->read = false;
         mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
     }
 #endif
@@ -227,9 +232,9 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
     notify_remote_via_evtchn(dev->evtchn);
 
 #ifdef HAVE_LIBC
-    if (cons != prod && dev->fd != -1)
+    if ( cons != prod && file )
         /* still some events to read */
-        files[dev->fd].read = true;
+        file->read = true;
 #endif
 
     return i;
@@ -298,11 +303,50 @@ close_kbdfront:
 }
 
 #ifdef HAVE_LIBC
+static int kbd_read(int fd, void *buf, size_t nbytes)
+{
+    struct file *file = get_file_from_fd(fd);
+    int ret, n;
+
+    n = nbytes / sizeof(union xenkbd_in_event);
+    ret = kbdfront_receive(file->dev, buf, n);
+    if ( ret <= 0 )
+    {
+        errno = EAGAIN;
+        return -1;
+    }
+
+    return ret * sizeof(union xenkbd_in_event);
+}
+
+static int kbd_close_fd(int fd)
+{
+    struct file *file = get_file_from_fd(fd);
+
+    shutdown_kbdfront(file->dev);
+
+    return 0;
+}
+
+static struct file_ops kbd_ops = {
+    .name = "kbd",
+    .read = kbd_read,
+    .close = kbd_close_fd,
+    .select_rd = select_read_flag,
+};
+
 int kbdfront_open(struct kbdfront_dev *dev)
 {
-    dev->fd = alloc_fd(FTYPE_KBD);
+    struct file *file;
+    static unsigned int ftype_kbd;
+
+    if ( !ftype_kbd )
+        ftype_kbd = alloc_file_type(&kbd_ops);
+
+    dev->fd = alloc_fd(ftype_kbd);
     printk("kbd_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].dev = dev;
+    file = get_file_from_fd(dev->fd);
+    file->dev = dev;
     return dev->fd;
 }
 #endif
@@ -346,10 +390,10 @@ void fbfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
 {
 #ifdef HAVE_LIBC
     struct fbfront_dev *dev = data;
-    int fd = dev->fd;
+    struct file *file = get_file_from_fd(dev->fd);
 
-    if (fd != -1)
-        files[fd].read = true;
+    if ( file )
+        file->read = true;
 #endif
     wake_up(&fbfront_queue);
 }
@@ -373,10 +417,12 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
     struct xenfb_page *page = dev->page;
     uint32_t prod, cons;
     int i;
-
 #ifdef HAVE_LIBC
-    if (dev->fd != -1) {
-        files[dev->fd].read = false;
+    struct file *file = get_file_from_fd(dev->fd);
+
+    if ( file )
+    {
+        file->read = false;
         mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
     }
 #endif
@@ -396,9 +442,9 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
     notify_remote_via_evtchn(dev->evtchn);
 
 #ifdef HAVE_LIBC
-    if (cons != prod && dev->fd != -1)
+    if ( cons != prod && file )
         /* still some events to read */
-        files[dev->fd].read = true;
+        file->read = true;
 #endif
 
     return i;
@@ -699,11 +745,50 @@ close_fbfront:
 }
 
 #ifdef HAVE_LIBC
+static int fbfront_read(int fd, void *buf, size_t nbytes)
+{
+    struct file *file = get_file_from_fd(fd);
+    int ret, n;
+
+    n = nbytes / sizeof(union xenfb_in_event);
+    ret = fbfront_receive(file->dev, buf, n);
+    if ( ret <= 0 )
+    {
+        errno = EAGAIN;
+        return -1;
+    }
+
+    return ret * sizeof(union xenfb_in_event);
+}
+
+static int fbfront_close_fd(int fd)
+{
+    struct file *file = get_file_from_fd(fd);
+
+    shutdown_fbfront(file->dev);
+
+    return 0;
+}
+
+static struct file_ops fb_ops = {
+    .name = ".fb",
+    .read = fbfront_read,
+    .close = fbfront_close_fd,
+    .select_rd = select_read_flag,
+};
+
 int fbfront_open(struct fbfront_dev *dev)
 {
-    dev->fd = alloc_fd(FTYPE_FB);
+    struct file *file;
+    static unsigned int ftype_fb;
+
+    if ( !ftype_fb )
+        ftype_fb = alloc_file_type(&fb_ops);
+
+    dev->fd = alloc_fd(ftype_fb);
     printk("fb_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].dev = dev;
+    file = get_file_from_fd(dev->fd);
+    file->dev = dev;
     return dev->fd;
 }
 #endif
diff --git a/include/lib.h b/include/lib.h
index aa8036e..653a16e 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -161,9 +161,7 @@ void sanity_check(void);
 #define FTYPE_SOCKET     3
 #define FTYPE_MEM        4
 #define FTYPE_SAVEFILE   5
-#define FTYPE_FB         6
-#define FTYPE_KBD        7
-#define FTYPE_N          8
+#define FTYPE_N          6
 #define FTYPE_SPARE     16
 
 typedef int file_read_func(int fd, void *buf, size_t nbytes);
diff --git a/lib/sys.c b/lib/sys.c
index 7f2e11f..4fb844f 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -302,30 +302,6 @@ int read(int fd, void *buf, size_t nbytes)
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
 	    return lwip_read(files[fd].fd, buf, nbytes);
-#endif
-#ifdef CONFIG_KBDFRONT
-        case FTYPE_KBD: {
-            int ret, n;
-            n = nbytes / sizeof(union xenkbd_in_event);
-            ret = kbdfront_receive(files[fd].dev, buf, n);
-	    if (ret <= 0) {
-		errno = EAGAIN;
-		return -1;
-	    }
-	    return ret * sizeof(union xenkbd_in_event);
-        }
-#endif
-#ifdef CONFIG_FBFRONT
-        case FTYPE_FB: {
-            int ret, n;
-            n = nbytes / sizeof(union xenfb_in_event);
-            ret = fbfront_receive(files[fd].dev, buf, n);
-	    if (ret <= 0) {
-		errno = EAGAIN;
-		return -1;
-	    }
-	    return ret * sizeof(union xenfb_in_event);
-        }
 #endif
 	default:
 	    break;
@@ -443,16 +419,6 @@ int close(int fd)
 	    res = lwip_close(files[fd].fd);
             break;
 #endif
-#ifdef CONFIG_KBDFRONT
-	case FTYPE_KBD:
-            shutdown_kbdfront(files[fd].dev);
-            break;
-#endif
-#ifdef CONFIG_FBFRONT
-	case FTYPE_FB:
-            shutdown_fbfront(files[fd].dev);
-            break;
-#endif
 #ifdef CONFIG_CONSFRONT
         case FTYPE_SAVEFILE:
         case FTYPE_CONSOLE:
@@ -619,8 +585,6 @@ static const char *file_types[] = {
     [FTYPE_NONE]    = "none",
     [FTYPE_CONSOLE] = "console",
     [FTYPE_SOCKET]  = "socket",
-    [FTYPE_KBD]     = "kbd",
-    [FTYPE_FB]      = "fb",
 };
 
 static char *get_type_name(unsigned int type)
@@ -795,17 +759,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
                 n++;
 	    FD_CLR(i, exceptfds);
 	    break;
-	case FTYPE_KBD:
-	case FTYPE_FB:
-	    if (FD_ISSET(i, readfds)) {
-		if (files[i].read)
-		    n++;
-		else
-		    FD_CLR(i, readfds);
-	    }
-	    FD_CLR(i, writefds);
-	    FD_CLR(i, exceptfds);
-	    break;
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
 	    if (FD_ISSET(i, readfds)) {
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 15:28:53 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 15:28:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255940.438934 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7J4v-0005WN-0j; Tue, 11 Jan 2022 15:28:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255940.438934; Tue, 11 Jan 2022 15:28:52 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7J4u-0005WG-U1; Tue, 11 Jan 2022 15:28:52 +0000
Received: by outflank-mailman (input) for mailman id 255940;
 Tue, 11 Jan 2022 15:28:51 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7J4t-0005GU-27
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 15:28:51 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 2b487324-72f3-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 16:28:47 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 96F1B6E6;
 Tue, 11 Jan 2022 16:28:46 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id YXgaV6rWjL-c; Tue, 11 Jan 2022 16:28:46 +0100 (CET)
Received: from begin.home (unknown
 [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id E7D111D7;
 Tue, 11 Jan 2022 16:28:45 +0100 (CET)
Received: from samy by begin.home with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7J4m-00EYY4-N8;
 Tue, 11 Jan 2022 16:28:44 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 2b487324-72f3-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 16:28:44 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 16/18] mini-os: reset file type in close() in one
 place only
Message-ID: <20220111152844.4hrbw6bnxlk3thrt@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-17-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20220111145817.22170-17-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 96F1B6E6
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 15:58:15 +0100, a ecrit:
> Today the file type in struct file is set to FTYPE_NONE for each
> file type individually. Do that at the end of close() handling for
> all types.
> 
> While at it wipe the complete struct file, too, in order to avoid
> old data creeping into a new allocated struct file.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Thanks!

> ---
> V2:
> - new patch
> ---
>  lib/sys.c | 53 ++++++++++++++++++++++++-----------------------------
>  lib/xs.c  |  1 -
>  2 files changed, 24 insertions(+), 30 deletions(-)
> 
> diff --git a/lib/sys.c b/lib/sys.c
> index 0e6fe5d..323a7cd 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -424,87 +424,82 @@ int fsync(int fd) {
>  
>  int close(int fd)
>  {
> +    int res = 0;
> +
>      printk("close(%d)\n", fd);
>      switch (files[fd].type) {
>          default:
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #ifdef CONFIG_XENBUS
>  	case FTYPE_XENBUS:
>              xs_daemon_close((void*)(intptr_t) fd);
> -            return 0;
> +            break;
>  #endif
>  #ifdef HAVE_LWIP
> -	case FTYPE_SOCKET: {
> -	    int res = lwip_close(files[fd].fd);
> -	    files[fd].type = FTYPE_NONE;
> -	    return res;
> -	}
> +	case FTYPE_SOCKET:
> +	    res = lwip_close(files[fd].fd);
> +            break;
>  #endif
>  #ifdef CONFIG_LIBXENCTRL
>  	case FTYPE_XC:
>  	    minios_interface_close_fd(fd);
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_LIBXENEVTCHN
>  	case FTYPE_EVTCHN:
>  	    minios_evtchn_close_fd(fd);
> -            return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_LIBXENGNTTAB
>  	case FTYPE_GNTMAP:
>  	    minios_gnttab_close_fd(fd);
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_NETFRONT
>  	case FTYPE_TAP:
>  	    shutdown_netfront(files[fd].dev);
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_BLKFRONT
>  	case FTYPE_BLK:
>              shutdown_blkfront(files[fd].dev);
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_TPMFRONT
>  	case FTYPE_TPMFRONT:
>              shutdown_tpmfront(files[fd].dev);
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_TPM_TIS
>  	case FTYPE_TPM_TIS:
>              shutdown_tpm_tis(files[fd].dev);
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_KBDFRONT
>  	case FTYPE_KBD:
>              shutdown_kbdfront(files[fd].dev);
> -            files[fd].type = FTYPE_NONE;
> -            return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_FBFRONT
>  	case FTYPE_FB:
>              shutdown_fbfront(files[fd].dev);
> -            files[fd].type = FTYPE_NONE;
> -            return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_CONSFRONT
>          case FTYPE_SAVEFILE:
>          case FTYPE_CONSOLE:
>              fini_consfront(files[fd].dev);
> -            files[fd].type = FTYPE_NONE;
> -            return 0;
> +            break;
>  #endif
>  	case FTYPE_NONE:
> -	    break;
> +            printk("close(%d): Bad descriptor\n", fd);
> +            errno = EBADF;
> +            return -1;
>      }
> -    printk("close(%d): Bad descriptor\n", fd);
> -    errno = EBADF;
> -    return -1;
> +
> +    memset(files + fd, 0, sizeof(struct file));
> +    files[fd].type = FTYPE_NONE;
> +    return res;
>  }
>  
>  static void init_stat(struct stat *buf)
> diff --git a/lib/xs.c b/lib/xs.c
> index 0459f52..4af0f96 100644
> --- a/lib/xs.c
> +++ b/lib/xs.c
> @@ -35,7 +35,6 @@ void xs_daemon_close(struct xs_handle *h)
>          next = event->next;
>          free(event);
>      }
> -    files[fd].type = FTYPE_NONE;
>  }
>  
>  int xs_fileno(struct xs_handle *h)
> -- 
> 2.26.2
> 

-- 
Samuel
Pour un père, autant mourir que de faire plein de calculs et pas s'occuper
de son fils
 -+- y sur #ens-mim - sombres histoires de zombies -+-


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 19:40:08 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 19:40:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256019.439087 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Mzz-00032D-OZ; Tue, 11 Jan 2022 19:40:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256019.439087; Tue, 11 Jan 2022 19:40:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Mzz-00031s-L0; Tue, 11 Jan 2022 19:40:03 +0000
Received: by outflank-mailman (input) for mailman id 256019;
 Tue, 11 Jan 2022 19:40:02 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7Mzy-0002n5-Bf
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 19:40:02 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 43ab366c-7316-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 20:40:00 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id AA4EF6E6;
 Tue, 11 Jan 2022 20:39:59 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id WfAGvK-wgJ29; Tue, 11 Jan 2022 20:39:59 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id BBD90F2;
 Tue, 11 Jan 2022 20:39:58 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7Mzs-00FEjk-S9;
 Tue, 11 Jan 2022 20:39:56 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 43ab366c-7316-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 20:39:56 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Andrew Cooper <amc96@srcf.net>
Cc: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
Subject: Re: [PATCH v2 17/18] mini-os: use function vectors instead of switch
 for file operations
Message-ID: <20220111193956.5jidxzw3kecz3h4i@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Andrew Cooper <amc96@srcf.net>, Juergen Gross <jgross@suse.com>,
	minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-18-jgross@suse.com>
 <a2d4c905-c477-8553-85a7-90168d914b6e@srcf.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <a2d4c905-c477-8553-85a7-90168d914b6e@srcf.net>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: AA4EF6E6
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 RCPT_COUNT_FIVE(0.00)[5];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Andrew Cooper, le mar. 11 janv. 2022 18:08:27 +0000, a ecrit:
> On 11/01/2022 14:58, Juergen Gross wrote:
> > +typedef int file_read_func(int fd, void *buf, size_t nbytes);
> > +typedef int file_write_func(int fd, const void *buf, size_t nbytes);
> > +typedef off_t file_lseek_func(int fd, off_t offset, int whence);
> > +typedef int file_close_func(int fd);
> > +typedef int file_fstat_func(int fd, struct stat *buf);
> > +typedef int file_fcntl_func(int fd, int cmd, va_list args);
> > +typedef bool file_select_func(int fd);
> 
> Are these typedef's useful?  I don't see them used anywhere other than
> the file_ops structure.
> 
> > +
> > +struct file_ops {
> > +    const char *name;
> > +    file_read_func *read;
> > +    file_write_func *write;
> > +    file_lseek_func *lseek;
> > +    file_close_func *close;
> > +    file_fstat_func *fstat;
> > +    file_fcntl_func *fcntl;
> > +    file_select_func *select_rd;
> > +    file_select_func *select_wr;
> >  };

I agree, I'd rather see the protoypes inside the struct itself.

Samuel


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 19:50:30 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 19:50:30 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256034.439127 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NA5-0005pV-I5; Tue, 11 Jan 2022 19:50:29 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256034.439127; Tue, 11 Jan 2022 19:50:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NA5-0005ow-E1; Tue, 11 Jan 2022 19:50:29 +0000
Received: by outflank-mailman (input) for mailman id 256034;
 Tue, 11 Jan 2022 19:50:29 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7NA4-0005mm-RY
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 19:50:28 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id b7f20f2f-7317-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 20:50:26 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 768B9678;
 Tue, 11 Jan 2022 20:50:24 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id JUBhp6cf7x8j; Tue, 11 Jan 2022 20:50:23 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id C287F140;
 Tue, 11 Jan 2022 20:50:22 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7N9x-00FF8O-Ru;
 Tue, 11 Jan 2022 20:50:21 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: b7f20f2f-7317-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 20:50:21 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 01/12] mini-os: remove event channel specific struct
 file definitions
Message-ID: <20220111195021.zekcnopxvr4fb4r4@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-2-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111151215.22955-2-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 768B9678
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 16:12:04 +0100, a ecrit:
> The event channel specific union member in struct file is no longer
> needed, so remove it together with the associated structure
> definitions.
> 
> The event channel file type and its associated handling can be removed,
> too, as libxenevtchn is now supplying a struct file_ops via a call of
> alloc_file_type().
> 
> This removes all contents of CONFIG_LIBXENEVTCHN guarded sections, so
> this config option can be removed.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  Config.mk                     |  1 -
>  arch/x86/testbuild/all-no     |  1 -
>  arch/x86/testbuild/all-yes    |  1 -
>  arch/x86/testbuild/newxen-yes |  1 -
>  include/lib.h                 | 15 +--------------
>  lib/sys.c                     |  7 -------
>  6 files changed, 1 insertion(+), 25 deletions(-)
> 
> diff --git a/Config.mk b/Config.mk
> index 1e08388..c244adc 100644
> --- a/Config.mk
> +++ b/Config.mk
> @@ -197,7 +197,6 @@ CONFIG-n += CONFIG_PARAVIRT
>  endif
>  # Support legacy CONFIG_XC value
>  CONFIG_XC ?= $(libc)
> -CONFIG-$(CONFIG_XC) += CONFIG_LIBXENEVTCHN
>  CONFIG-$(CONFIG_XC) += CONFIG_LIBXENGNTTAB
>  
>  CONFIG-$(lwip) += CONFIG_LWIP
> diff --git a/arch/x86/testbuild/all-no b/arch/x86/testbuild/all-no
> index d6fc260..202c317 100644
> --- a/arch/x86/testbuild/all-no
> +++ b/arch/x86/testbuild/all-no
> @@ -13,7 +13,6 @@ CONFIG_FBFRONT = n
>  CONFIG_KBDFRONT = n
>  CONFIG_CONSFRONT = n
>  CONFIG_XENBUS = n
> -CONFIG_LIBXENEVTCHN = n
>  CONFIG_LIBXENGNTTAB = n
>  CONFIG_LWIP = n
>  CONFIG_BALLOON = n
> diff --git a/arch/x86/testbuild/all-yes b/arch/x86/testbuild/all-yes
> index 98bbfeb..eb495a4 100644
> --- a/arch/x86/testbuild/all-yes
> +++ b/arch/x86/testbuild/all-yes
> @@ -16,6 +16,5 @@ CONFIG_XENBUS = y
>  CONFIG_BALLOON = y
>  CONFIG_USE_XEN_CONSOLE = y
>  # The following are special: they need support from outside
> -CONFIG_LIBXENEVTCHN = n
>  CONFIG_LIBXENGNTTAB = n
>  CONFIG_LWIP = n
> diff --git a/arch/x86/testbuild/newxen-yes b/arch/x86/testbuild/newxen-yes
> index 0603200..bf25ace 100644
> --- a/arch/x86/testbuild/newxen-yes
> +++ b/arch/x86/testbuild/newxen-yes
> @@ -17,6 +17,5 @@ CONFIG_BALLOON = y
>  CONFIG_USE_XEN_CONSOLE = y
>  XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
>  # The following are special: they need support from outside
> -CONFIG_LIBXENEVTCHN = n
>  CONFIG_LIBXENGNTTAB = n
>  CONFIG_LWIP = n
> diff --git a/include/lib.h b/include/lib.h
> index 4892320..df972ef 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -169,8 +169,7 @@ void sanity_check(void);
>  #define FTYPE_TPM_TIS   11
>  #define FTYPE_XENBUS    12
>  #define FTYPE_GNTMAP    13
> -#define FTYPE_EVTCHN    14
> -#define FTYPE_N         15
> +#define FTYPE_N         14
>  #define FTYPE_SPARE     16
>  
>  typedef int file_read_func(int fd, void *buf, size_t nbytes);
> @@ -199,15 +198,6 @@ off_t lseek_default(int fd, off_t offset, int whence);
>  bool select_yes(int fd);
>  bool select_read_flag(int fd);
>  
> -LIST_HEAD(evtchn_port_list, evtchn_port_info);
> -
> -struct evtchn_port_info {
> -        LIST_ENTRY(evtchn_port_info) list;
> -        evtchn_port_t port;
> -        unsigned long pending;
> -        int bound;
> -};
> -
>  struct file {
>      unsigned int type;
>      bool read;	/* maybe available for read */
> @@ -215,9 +205,6 @@ struct file {
>      union {
>          int fd; /* Any fd from an upper layer. */
>          void *dev;
> -	struct {
> -	    struct evtchn_port_list ports;
> -	} evtchn;
>  	struct gntmap gntmap;
>      };
>  };
> diff --git a/lib/sys.c b/lib/sys.c
> index 52876e0..8fa1fee 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -505,11 +505,6 @@ int close(int fd)
>  	    res = lwip_close(files[fd].fd);
>              break;
>  #endif
> -#ifdef CONFIG_LIBXENEVTCHN
> -	case FTYPE_EVTCHN:
> -	    minios_evtchn_close_fd(fd);
> -            break;
> -#endif
>  #ifdef CONFIG_LIBXENGNTTAB
>  	case FTYPE_GNTMAP:
>  	    minios_gnttab_close_fd(fd);
> @@ -723,7 +718,6 @@ static const char *file_types[] = {
>      [FTYPE_NONE]    = "none",
>      [FTYPE_CONSOLE] = "console",
>      [FTYPE_XENBUS]  = "xenbus",
> -    [FTYPE_EVTCHN]  = "evtchn",
>      [FTYPE_SOCKET]  = "socket",
>      [FTYPE_TAP]     = "net",
>      [FTYPE_BLK]     = "blk",
> @@ -915,7 +909,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  	    FD_CLR(i, exceptfds);
>  	    break;
>  #endif
> -	case FTYPE_EVTCHN:
>  	case FTYPE_TAP:
>  	case FTYPE_BLK:
>  	case FTYPE_KBD:
> -- 
> 2.26.2
> 

-- 
Samuel
<h> t: bah c'est tendre le pattern pour se faire matcher, hein


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 19:55:31 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 19:55:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256037.439138 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NEv-0006VP-Tl; Tue, 11 Jan 2022 19:55:29 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256037.439138; Tue, 11 Jan 2022 19:55:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NEv-0006VI-Ql; Tue, 11 Jan 2022 19:55:29 +0000
Received: by outflank-mailman (input) for mailman id 256037;
 Tue, 11 Jan 2022 19:55:29 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7NEv-0006VC-9Q
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 19:55:29 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 6c88fe59-7318-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 20:55:28 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 5A1B8678;
 Tue, 11 Jan 2022 20:55:27 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id DRJwrHkXCUFE; Tue, 11 Jan 2022 20:55:26 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id DFBEC261;
 Tue, 11 Jan 2022 20:55:25 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7NEr-00FFHq-4g;
 Tue, 11 Jan 2022 20:55:25 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 6c88fe59-7318-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 20:55:25 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 02/12] mini-os: remove gnttab specific member from
 struct file
Message-ID: <20220111195525.qnn2kixvrsb3fjqa@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-3-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20220111151215.22955-3-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 5A1B8678
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 16:12:05 +0100, a ecrit:
> The event channel specific union member in struct file is no longer
> needed, so remove it.
> 
> The gnttab file type and its associated handling can be removed, too,
> as libxengnttab is now supplying a struct file_ops via a call of
> alloc_file_type().
> 
> This removes all contents of CONFIG_LIBXENGNTTAB guarded sections, so
> this config option can be removed.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  Config.mk                     | 1 -
>  arch/x86/testbuild/all-no     | 1 -
>  arch/x86/testbuild/all-yes    | 1 -
>  arch/x86/testbuild/newxen-yes | 1 -
>  gntmap.c                      | 2 +-
>  include/lib.h                 | 4 +---
>  lib/sys.c                     | 5 -----
>  7 files changed, 2 insertions(+), 13 deletions(-)
> 
> diff --git a/Config.mk b/Config.mk
> index c244adc..eb84515 100644
> --- a/Config.mk
> +++ b/Config.mk
> @@ -197,7 +197,6 @@ CONFIG-n += CONFIG_PARAVIRT
>  endif
>  # Support legacy CONFIG_XC value
>  CONFIG_XC ?= $(libc)
> -CONFIG-$(CONFIG_XC) += CONFIG_LIBXENGNTTAB
>  
>  CONFIG-$(lwip) += CONFIG_LWIP
>  
> diff --git a/arch/x86/testbuild/all-no b/arch/x86/testbuild/all-no
> index 202c317..c429354 100644
> --- a/arch/x86/testbuild/all-no
> +++ b/arch/x86/testbuild/all-no
> @@ -13,7 +13,6 @@ CONFIG_FBFRONT = n
>  CONFIG_KBDFRONT = n
>  CONFIG_CONSFRONT = n
>  CONFIG_XENBUS = n
> -CONFIG_LIBXENGNTTAB = n
>  CONFIG_LWIP = n
>  CONFIG_BALLOON = n
>  CONFIG_USE_XEN_CONSOLE = n
> diff --git a/arch/x86/testbuild/all-yes b/arch/x86/testbuild/all-yes
> index eb495a4..6c6096b 100644
> --- a/arch/x86/testbuild/all-yes
> +++ b/arch/x86/testbuild/all-yes
> @@ -16,5 +16,4 @@ CONFIG_XENBUS = y
>  CONFIG_BALLOON = y
>  CONFIG_USE_XEN_CONSOLE = y
>  # The following are special: they need support from outside
> -CONFIG_LIBXENGNTTAB = n
>  CONFIG_LWIP = n
> diff --git a/arch/x86/testbuild/newxen-yes b/arch/x86/testbuild/newxen-yes
> index bf25ace..88094fc 100644
> --- a/arch/x86/testbuild/newxen-yes
> +++ b/arch/x86/testbuild/newxen-yes
> @@ -17,5 +17,4 @@ CONFIG_BALLOON = y
>  CONFIG_USE_XEN_CONSOLE = y
>  XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
>  # The following are special: they need support from outside
> -CONFIG_LIBXENGNTTAB = n
>  CONFIG_LWIP = n
> diff --git a/gntmap.c b/gntmap.c
> index 6fa1dac..3422ab2 100644
> --- a/gntmap.c
> +++ b/gntmap.c
> @@ -3,7 +3,7 @@
>   *
>   * Diego Ongaro <diego.ongaro@citrix.com>, July 2008
>   *
> - * Files of type FTYPE_GNTMAP contain a gntmap, which is an array of
> + * Files of libxengnttab contain a gntmap, which is an array of
>   * (host address, grant handle) pairs. Grant handles come from a hypervisor map
>   * operation and are needed for the corresponding unmap.
>   *
> diff --git a/include/lib.h b/include/lib.h
> index df972ef..283abb8 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -168,8 +168,7 @@ void sanity_check(void);
>  #define FTYPE_TPMFRONT  10
>  #define FTYPE_TPM_TIS   11
>  #define FTYPE_XENBUS    12
> -#define FTYPE_GNTMAP    13
> -#define FTYPE_N         14
> +#define FTYPE_N         13
>  #define FTYPE_SPARE     16
>  
>  typedef int file_read_func(int fd, void *buf, size_t nbytes);
> @@ -205,7 +204,6 @@ struct file {
>      union {
>          int fd; /* Any fd from an upper layer. */
>          void *dev;
> -	struct gntmap gntmap;
>      };
>  };
>  
> diff --git a/lib/sys.c b/lib/sys.c
> index 8fa1fee..9540410 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -505,11 +505,6 @@ int close(int fd)
>  	    res = lwip_close(files[fd].fd);
>              break;
>  #endif
> -#ifdef CONFIG_LIBXENGNTTAB
> -	case FTYPE_GNTMAP:
> -	    minios_gnttab_close_fd(fd);
> -            break;
> -#endif
>  #ifdef CONFIG_NETFRONT
>  	case FTYPE_TAP:
>  	    shutdown_netfront(files[fd].dev);
> -- 
> 2.26.2
> 

-- 
Samuel
Tu as lu les docs. Tu es devenu un informaticien. Que tu le veuilles
ou non. Lire la doc, c'est le Premier et Unique Commandement de
l'informaticien.
-+- TP in: Guide du Linuxien pervers - "L'évangile selon St Thomas"


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 19:58:26 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 19:58:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256044.439163 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NHl-0007qN-PK; Tue, 11 Jan 2022 19:58:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256044.439163; Tue, 11 Jan 2022 19:58:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NHl-0007qG-M1; Tue, 11 Jan 2022 19:58:25 +0000
Received: by outflank-mailman (input) for mailman id 256044;
 Tue, 11 Jan 2022 19:58:24 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7NHk-0007p4-4E
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 19:58:24 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id d51b3e6a-7318-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 20:58:23 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 2982B678;
 Tue, 11 Jan 2022 20:58:23 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id m2eqNvvpl227; Tue, 11 Jan 2022 20:58:22 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id BD163140;
 Tue, 11 Jan 2022 20:58:22 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7NHi-00FFLI-BT;
 Tue, 11 Jan 2022 20:58:22 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: d51b3e6a-7318-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 20:58:22 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 17/18] mini-os: use function vectors instead of switch
 for file operations
Message-ID: <20220111195822.z4n7rjcv65aoswxw@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-18-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111145817.22170-18-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 2982B678
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 15:58:16 +0100, a ecrit:
> +    for ( i = FTYPE_N; i < ARRAY_SIZE(file_ops) && file_ops[i]; i++ );

For such loops, I'd rather see the ';' on its own line, to make it clear
it's an empty loop.

Samuel


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 20:05:52 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 20:05:52 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256051.439179 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NOx-0000yp-Ld; Tue, 11 Jan 2022 20:05:51 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256051.439179; Tue, 11 Jan 2022 20:05:51 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NOx-0000yh-HS; Tue, 11 Jan 2022 20:05:51 +0000
Received: by outflank-mailman (input) for mailman id 256051;
 Tue, 11 Jan 2022 20:05:50 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7NOw-0000yW-8G
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:05:50 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id decb6d33-7319-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 21:05:49 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id A86F1678;
 Tue, 11 Jan 2022 21:05:48 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id dDuQCKH3RpjN; Tue, 11 Jan 2022 21:05:48 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 05521381;
 Tue, 11 Jan 2022 21:05:47 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7NOt-00FFMu-Co;
 Tue, 11 Jan 2022 21:05:47 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: decb6d33-7319-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 21:05:47 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 17/18] mini-os: use function vectors instead of switch
 for file operations
Message-ID: <20220111200547.wb6mwl6zxtf3y54c@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-18-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111145817.22170-18-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: A86F1678
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 15:58:16 +0100, a ecrit:
> @@ -370,8 +413,45 @@ int write(int fd, const void *buf, size_t nbytes)
>      return -1;
>  }
>  
> +off_t lseek_default(int fd, off_t offset, int whence)
> +{
> +    switch ( whence )
> +    {

Is there a reason for making this one a separate function, unlike others
for which you kept the code in the main function?

Apart from that, this looks good to me.

> +    case SEEK_SET:
> +        files[fd].offset = offset;
> +        break;
> +
> +    case SEEK_CUR:
> +        files[fd].offset += offset;
> +        break;
> +
> +    case SEEK_END:
> +    {
> +        struct stat st;
> +        int ret;
> +
> +        ret = fstat(fd, &st);
> +        if ( ret )
> +            return -1;
> +        files[fd].offset = st.st_size + offset;
> +        break;
> +    }
> +
> +    default:
> +        errno = EINVAL;
> +        return -1;
> +    }
> +
> +    return files[fd].offset;
> +}
> +
>  off_t lseek(int fd, off_t offset, int whence)
>  {
> +    struct file_ops *ops = get_file_ops(files[fd].type);
> +
> +    if ( ops->lseek )
> +        return ops->lseek(fd, offset, whence);
> +
>      switch(files[fd].type) {
>  #ifdef CONFIG_BLKFRONT
>         case FTYPE_BLK:
> @@ -393,28 +473,7 @@ off_t lseek(int fd, off_t offset, int whence)
>            return (off_t) -1;
>      }
>  
> -    switch (whence) {
> -       case SEEK_SET:
> -          files[fd].offset = offset;
> -          break;
> -       case SEEK_CUR:
> -          files[fd].offset += offset;
> -          break;
> -       case SEEK_END:
> -          {
> -             struct stat st;
> -             int ret;
> -             ret = fstat(fd, &st);
> -             if (ret)
> -                return -1;
> -             files[fd].offset = st.st_size + offset;
> -             break;
> -          }
> -       default:
> -          errno = EINVAL;
> -          return -1;
> -    }
> -    return files[fd].offset;
> +    return lseek_default(fd, offset, whence);
>  }
>  
>  int fsync(int fd) {


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 20:06:21 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 20:06:21 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256056.439205 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NPR-0001np-8p; Tue, 11 Jan 2022 20:06:21 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256056.439205; Tue, 11 Jan 2022 20:06:21 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NPR-0001nf-5H; Tue, 11 Jan 2022 20:06:21 +0000
Received: by outflank-mailman (input) for mailman id 256056;
 Tue, 11 Jan 2022 20:06:20 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7NPQ-0001Vz-2m
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:06:20 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id eff36a36-7319-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 21:06:18 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id AE365796;
 Tue, 11 Jan 2022 21:06:17 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id PWIs8wVpdH8S; Tue, 11 Jan 2022 21:06:16 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 50F3D746;
 Tue, 11 Jan 2022 21:06:16 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7NPL-00FFND-Rq;
 Tue, 11 Jan 2022 21:06:15 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: eff36a36-7319-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 21:06:15 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 03/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in xs
Message-ID: <20220111200615.b5tpi4faz3cak2ft@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-4-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20220111151215.22955-4-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: AE365796
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 16:12:06 +0100, a ecrit:
> Allocate the needed file type via alloc_file_type().
> 
> Instead of directly accessing the files[] array use get_file_from_fd().
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h   |  3 +--
>  lib/sys.c       | 18 --------------
>  lib/xs.c        | 64 +++++++++++++++++++++++++++++++++++++------------
>  xenbus/xenbus.c |  1 +
>  4 files changed, 51 insertions(+), 35 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 283abb8..05c7de5 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -167,8 +167,7 @@ void sanity_check(void);
>  #define FTYPE_BLK        9
>  #define FTYPE_TPMFRONT  10
>  #define FTYPE_TPM_TIS   11
> -#define FTYPE_XENBUS    12
> -#define FTYPE_N         13
> +#define FTYPE_N         12
>  #define FTYPE_SPARE     16
>  
>  typedef int file_read_func(int fd, void *buf, size_t nbytes);
> diff --git a/lib/sys.c b/lib/sys.c
> index 9540410..d213ae5 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -495,11 +495,6 @@ int close(int fd)
>      switch (files[fd].type) {
>          default:
>              break;
> -#ifdef CONFIG_XENBUS
> -	case FTYPE_XENBUS:
> -            xs_daemon_close((void*)(intptr_t) fd);
> -            break;
> -#endif
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
>  	    res = lwip_close(files[fd].fd);
> @@ -712,7 +707,6 @@ int closedir(DIR *dir)
>  static const char *file_types[] = {
>      [FTYPE_NONE]    = "none",
>      [FTYPE_CONSOLE] = "console",
> -    [FTYPE_XENBUS]  = "xenbus",
>      [FTYPE_SOCKET]  = "socket",
>      [FTYPE_TAP]     = "net",
>      [FTYPE_BLK]     = "blk",
> @@ -892,18 +886,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>                  n++;
>  	    FD_CLR(i, exceptfds);
>  	    break;
> -#ifdef CONFIG_XENBUS
> -	case FTYPE_XENBUS:
> -	    if (FD_ISSET(i, readfds)) {
> -                if (files[i].dev)
> -		    n++;
> -		else
> -		    FD_CLR(i, readfds);
> -	    }
> -	    FD_CLR(i, writefds);
> -	    FD_CLR(i, exceptfds);
> -	    break;
> -#endif
>  	case FTYPE_TAP:
>  	case FTYPE_BLK:
>  	case FTYPE_KBD:
> diff --git a/lib/xs.c b/lib/xs.c
> index 4af0f96..ac830d2 100644
> --- a/lib/xs.c
> +++ b/lib/xs.c
> @@ -18,23 +18,55 @@ static inline int _xs_fileno(struct xs_handle *h) {
>      return (intptr_t) h;
>  }
>  
> +static int xs_close_fd(int fd)
> +{
> +    struct xenbus_event *event, *next;
> +    struct file *file = get_file_from_fd(fd);
> +
> +    for (event = file->dev; event; event = next)
> +    {
> +        next = event->next;
> +        free(event);
> +    }
> +
> +    return 0;
> +}
> +
> +static bool xs_can_read(int fd)
> +{
> +    struct file *file = get_file_from_fd(fd);
> +
> +    return file && file->dev;
> +}
> +
> +static struct file_ops xenbus_ops = {
> +    .name = "xenbus",
> +    .close = xs_close_fd,
> +    .select_rd = xs_can_read,
> +};
> +
>  struct xs_handle *xs_daemon_open()
>  {
> -    int fd = alloc_fd(FTYPE_XENBUS);
> -    files[fd].dev = NULL;
> -    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].dev);
> +    int fd;
> +    struct file *file;
> +    static unsigned int ftype_xenbus;
> +
> +    if ( !ftype_xenbus )
> +        ftype_xenbus = alloc_file_type(&xenbus_ops);
> +
> +    fd = alloc_fd(ftype_xenbus);
> +    file = get_file_from_fd(fd);
> +    if ( !file )
> +        return NULL;
> +
> +    file->dev = NULL;
> +    printk("xs_daemon_open -> %d, %p\n", fd, &file->dev);
>      return (void*)(intptr_t) fd;
>  }
>  
>  void xs_daemon_close(struct xs_handle *h)
>  {
> -    int fd = _xs_fileno(h);
> -    struct xenbus_event *event, *next;
> -    for (event = files[fd].dev; event; event = next)
> -    {
> -        next = event->next;
> -        free(event);
> -    }
> +    close(_xs_fileno(h));
>  }
>  
>  int xs_fileno(struct xs_handle *h)
> @@ -169,18 +201,20 @@ char **xs_directory(struct xs_handle *h, xs_transaction_t t,
>  
>  bool xs_watch(struct xs_handle *h, const char *path, const char *token)
>  {
> -    int fd = _xs_fileno(h);
> +    struct file *file = get_file_from_fd(_xs_fileno(h));
> +
>      printk("xs_watch(%s, %s)\n", path, token);
>      return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token,
> -                   (xenbus_event_queue *)&files[fd].dev));
> +                   (xenbus_event_queue *)&file->dev));
>  }
>  
>  char **xs_read_watch(struct xs_handle *h, unsigned int *num)
>  {
> -    int fd = _xs_fileno(h);
>      struct xenbus_event *event;
> -    event = files[fd].dev;
> -    files[fd].dev = event->next;
> +    struct file *file = get_file_from_fd(_xs_fileno(h));
> +
> +    event = file->dev;
> +    file->dev = event->next;
>      printk("xs_read_watch() -> %s %s\n", event->path, event->token);
>      *num = 2;
>      return (char **) &event->path;
> diff --git a/xenbus/xenbus.c b/xenbus/xenbus.c
> index b687678..785389f 100644
> --- a/xenbus/xenbus.c
> +++ b/xenbus/xenbus.c
> @@ -393,6 +393,7 @@ static int allocate_xenbus_id(void)
>  void init_xenbus(void)
>  {
>      int err;
> +
>      DEBUG("init_xenbus called.\n");
>      create_thread("xenstore", xenbus_thread_func, NULL);
>      DEBUG("buf at %p.\n", xenstore_buf);
> -- 
> 2.26.2
> 

-- 
Samuel
<y> muhahaha...
<y> ya un train qui part de Perrache à 14h57
<y> qui passe à Part-Dieu à 15h10
<y> si je le prends à Perrache, je suis en zone bleue
<y> si je le prends à Part-Dieu, je suis en zone blanche
<y> donc je vais le prendre à Perrache *mais* à Part-Dieu ;-)
 -+- #ens-mim - vive la SNCF -+-


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 20:11:43 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 20:11:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256072.439230 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NUc-0004Gp-7i; Tue, 11 Jan 2022 20:11:42 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256072.439230; Tue, 11 Jan 2022 20:11:42 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NUc-0004Gi-4W; Tue, 11 Jan 2022 20:11:42 +0000
Received: by outflank-mailman (input) for mailman id 256072;
 Tue, 11 Jan 2022 20:11:40 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7NUa-0004GU-K2
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:11:40 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id af7f0431-731a-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 21:11:39 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 0DE81678;
 Tue, 11 Jan 2022 21:11:39 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id USutWDA51RWx; Tue, 11 Jan 2022 21:11:37 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 9345A261;
 Tue, 11 Jan 2022 21:11:37 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7NUW-00FFQS-TL;
 Tue, 11 Jan 2022 21:11:36 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: af7f0431-731a-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 21:11:36 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
Subject: Re: [PATCH v2 03/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in xs
Message-ID: <20220111201136.yqp274wyqju5zshs@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-4-jgross@suse.com>
 <20220111200615.b5tpi4faz3cak2ft@begin>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20220111200615.b5tpi4faz3cak2ft@begin>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 0DE81678
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Samuel Thibault, le mar. 11 janv. 2022 21:06:15 +0100, a ecrit:
> Juergen Gross, le mar. 11 janv. 2022 16:12:06 +0100, a ecrit:
> > Allocate the needed file type via alloc_file_type().
> > 
> > Instead of directly accessing the files[] array use get_file_from_fd().
> > 
> > Signed-off-by: Juergen Gross <jgross@suse.com>
> 
> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> 
> > ---
> >  include/lib.h   |  3 +--
> >  lib/sys.c       | 18 --------------
> >  lib/xs.c        | 64 +++++++++++++++++++++++++++++++++++++------------
> >  xenbus/xenbus.c |  1 +
> >  4 files changed, 51 insertions(+), 35 deletions(-)
> > 
> > diff --git a/include/lib.h b/include/lib.h
> > index 283abb8..05c7de5 100644
> > --- a/include/lib.h
> > +++ b/include/lib.h
> > @@ -167,8 +167,7 @@ void sanity_check(void);
> >  #define FTYPE_BLK        9
> >  #define FTYPE_TPMFRONT  10
> >  #define FTYPE_TPM_TIS   11
> > -#define FTYPE_XENBUS    12
> > -#define FTYPE_N         13
> > +#define FTYPE_N         12
> >  #define FTYPE_SPARE     16
> >  
> >  typedef int file_read_func(int fd, void *buf, size_t nbytes);
> > diff --git a/lib/sys.c b/lib/sys.c
> > index 9540410..d213ae5 100644
> > --- a/lib/sys.c
> > +++ b/lib/sys.c
> > @@ -495,11 +495,6 @@ int close(int fd)
> >      switch (files[fd].type) {
> >          default:
> >              break;
> > -#ifdef CONFIG_XENBUS
> > -	case FTYPE_XENBUS:
> > -            xs_daemon_close((void*)(intptr_t) fd);
> > -            break;
> > -#endif
> >  #ifdef HAVE_LWIP
> >  	case FTYPE_SOCKET:
> >  	    res = lwip_close(files[fd].fd);
> > @@ -712,7 +707,6 @@ int closedir(DIR *dir)
> >  static const char *file_types[] = {
> >      [FTYPE_NONE]    = "none",
> >      [FTYPE_CONSOLE] = "console",
> > -    [FTYPE_XENBUS]  = "xenbus",
> >      [FTYPE_SOCKET]  = "socket",
> >      [FTYPE_TAP]     = "net",
> >      [FTYPE_BLK]     = "blk",
> > @@ -892,18 +886,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
> >                  n++;
> >  	    FD_CLR(i, exceptfds);
> >  	    break;
> > -#ifdef CONFIG_XENBUS
> > -	case FTYPE_XENBUS:
> > -	    if (FD_ISSET(i, readfds)) {
> > -                if (files[i].dev)
> > -		    n++;
> > -		else
> > -		    FD_CLR(i, readfds);
> > -	    }
> > -	    FD_CLR(i, writefds);
> > -	    FD_CLR(i, exceptfds);
> > -	    break;
> > -#endif
> >  	case FTYPE_TAP:
> >  	case FTYPE_BLK:
> >  	case FTYPE_KBD:
> > diff --git a/lib/xs.c b/lib/xs.c
> > index 4af0f96..ac830d2 100644
> > --- a/lib/xs.c
> > +++ b/lib/xs.c
> > @@ -18,23 +18,55 @@ static inline int _xs_fileno(struct xs_handle *h) {
> >      return (intptr_t) h;
> >  }
> >  
> > +static int xs_close_fd(int fd)
> > +{
> > +    struct xenbus_event *event, *next;
> > +    struct file *file = get_file_from_fd(fd);

This...

> > +    for (event = file->dev; event; event = next)
> > +    {
> > +        next = event->next;
> > +        free(event);
> > +    }
> > +
> > +    return 0;
> > +}
> > +
> > +static bool xs_can_read(int fd)
> > +{
> > +    struct file *file = get_file_from_fd(fd);

... and that would be simplified by directly getting the file* from the
parameters.

> > +    return file && file->dev;
> > +}
> > +
> > +static struct file_ops xenbus_ops = {
> > +    .name = "xenbus",
> > +    .close = xs_close_fd,
> > +    .select_rd = xs_can_read,
> > +};
> > +
> >  struct xs_handle *xs_daemon_open()
> >  {
> > -    int fd = alloc_fd(FTYPE_XENBUS);
> > -    files[fd].dev = NULL;
> > -    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].dev);
> > +    int fd;
> > +    struct file *file;
> > +    static unsigned int ftype_xenbus;
> > +
> > +    if ( !ftype_xenbus )
> > +        ftype_xenbus = alloc_file_type(&xenbus_ops);
> > +
> > +    fd = alloc_fd(ftype_xenbus);
> > +    file = get_file_from_fd(fd);
> > +    if ( !file )
> > +        return NULL;
> > +
> > +    file->dev = NULL;
> > +    printk("xs_daemon_open -> %d, %p\n", fd, &file->dev);
> >      return (void*)(intptr_t) fd;
> >  }
> >  
> >  void xs_daemon_close(struct xs_handle *h)
> >  {
> > -    int fd = _xs_fileno(h);
> > -    struct xenbus_event *event, *next;
> > -    for (event = files[fd].dev; event; event = next)
> > -    {
> > -        next = event->next;
> > -        free(event);
> > -    }
> > +    close(_xs_fileno(h));
> >  }
> >  
> >  int xs_fileno(struct xs_handle *h)
> > @@ -169,18 +201,20 @@ char **xs_directory(struct xs_handle *h, xs_transaction_t t,
> >  
> >  bool xs_watch(struct xs_handle *h, const char *path, const char *token)
> >  {
> > -    int fd = _xs_fileno(h);
> > +    struct file *file = get_file_from_fd(_xs_fileno(h));
> > +
> >      printk("xs_watch(%s, %s)\n", path, token);
> >      return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token,
> > -                   (xenbus_event_queue *)&files[fd].dev));
> > +                   (xenbus_event_queue *)&file->dev));
> >  }
> >  
> >  char **xs_read_watch(struct xs_handle *h, unsigned int *num)
> >  {
> > -    int fd = _xs_fileno(h);
> >      struct xenbus_event *event;
> > -    event = files[fd].dev;
> > -    files[fd].dev = event->next;
> > +    struct file *file = get_file_from_fd(_xs_fileno(h));
> > +
> > +    event = file->dev;
> > +    file->dev = event->next;
> >      printk("xs_read_watch() -> %s %s\n", event->path, event->token);
> >      *num = 2;
> >      return (char **) &event->path;
> > diff --git a/xenbus/xenbus.c b/xenbus/xenbus.c
> > index b687678..785389f 100644
> > --- a/xenbus/xenbus.c
> > +++ b/xenbus/xenbus.c
> > @@ -393,6 +393,7 @@ static int allocate_xenbus_id(void)
> >  void init_xenbus(void)
> >  {
> >      int err;
> > +
> >      DEBUG("init_xenbus called.\n");
> >      create_thread("xenstore", xenbus_thread_func, NULL);
> >      DEBUG("buf at %p.\n", xenstore_buf);
> > -- 
> > 2.26.2
> > 
> 
> -- 
> Samuel
> <y> muhahaha...
> <y> ya un train qui part de Perrache à 14h57
> <y> qui passe à Part-Dieu à 15h10
> <y> si je le prends à Perrache, je suis en zone bleue
> <y> si je le prends à Part-Dieu, je suis en zone blanche
> <y> donc je vais le prendre à Perrache *mais* à Part-Dieu ;-)
>  -+- #ens-mim - vive la SNCF -+-

-- 
Samuel
<c> hiri, le cri ici, c des marrants
<c> j'ai un rep ".uglyhackdirectorywithoutacls" ds mon home
 -+- #ens-mim en stage -+-


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 20:13:11 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 20:13:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256080.439256 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NW2-0005YI-VF; Tue, 11 Jan 2022 20:13:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256080.439256; Tue, 11 Jan 2022 20:13:10 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NW2-0005YB-Rs; Tue, 11 Jan 2022 20:13:10 +0000
Received: by outflank-mailman (input) for mailman id 256080;
 Tue, 11 Jan 2022 20:13:10 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7NW2-0005SV-0C
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:13:10 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e4d4e384-731a-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 21:13:09 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 80329678;
 Tue, 11 Jan 2022 21:13:08 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id B6WWKwD8_xbJ; Tue, 11 Jan 2022 21:13:07 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 53872261;
 Tue, 11 Jan 2022 21:13:07 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7NVy-00FFRE-I3;
 Tue, 11 Jan 2022 21:13:06 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e4d4e384-731a-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 21:13:06 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 04/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in tpm_tis
Message-ID: <20220111201306.you23ajz25etmmb7@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-5-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111151215.22955-5-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 80329678
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 16:12:07 +0100, a ecrit:
> Allocate a file type dynamically via alloc_file_type().
> 
> Instead of directly accessing the files[] array use get_file_from_fd().
> 
> Make some now local functions static and modify their prototypes to
> match the file_ops requirements.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

modulo the int fd / file * thing,

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h     |   3 +-
>  include/tpm_tis.h |   6 ---
>  lib/sys.c         |  23 ---------
>  tpm_tis.c         | 120 ++++++++++++++++++++++++++++++----------------
>  4 files changed, 80 insertions(+), 72 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 05c7de5..d94d142 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -166,8 +166,7 @@ void sanity_check(void);
>  #define FTYPE_TAP        8
>  #define FTYPE_BLK        9
>  #define FTYPE_TPMFRONT  10
> -#define FTYPE_TPM_TIS   11
> -#define FTYPE_N         12
> +#define FTYPE_N         11
>  #define FTYPE_SPARE     16
>  
>  typedef int file_read_func(int fd, void *buf, size_t nbytes);
> diff --git a/include/tpm_tis.h b/include/tpm_tis.h
> index 86e83f1..2af974d 100644
> --- a/include/tpm_tis.h
> +++ b/include/tpm_tis.h
> @@ -37,14 +37,11 @@ struct tpm_chip;
>  
>  struct tpm_chip* init_tpm_tis(unsigned long baseaddr, int localities, unsigned int irq);
>  struct tpm_chip* init_tpm2_tis(unsigned long baseaddr, int localities, unsigned int irq);
> -void shutdown_tpm_tis(struct tpm_chip* tpm);
>  
>  int tpm_tis_request_locality(struct tpm_chip* tpm, int locality);
>  int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** resp, size_t* resplen);
>  
>  #ifdef HAVE_LIBC
> -#include <sys/stat.h>
> -#include <fcntl.h>
>  /* POSIX IO functions:
>   * use tpm_tis_open() to get a file descriptor to the tpm device
>   * use write() on the fd to send a command to the backend. You must
> @@ -53,9 +50,6 @@ int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** res
>   * fstat() to get the size of the response and lseek() to seek on it.
>   */
>  int tpm_tis_open(struct tpm_chip* tpm);
> -int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count);
> -int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count);
> -int tpm_tis_posix_fstat(int fd, struct stat* buf);
>  #endif
>  
>  #endif
> diff --git a/lib/sys.c b/lib/sys.c
> index d213ae5..4060b42 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -29,7 +29,6 @@
>  #include <blkfront.h>
>  #include <fbfront.h>
>  #include <tpmfront.h>
> -#include <tpm_tis.h>
>  #include <xenbus.h>
>  #include <xenstore.h>
>  #include <poll.h>
> @@ -349,11 +348,6 @@ int read(int fd, void *buf, size_t nbytes)
>          case FTYPE_TPMFRONT: {
>  	    return tpmfront_posix_read(fd, buf, nbytes);
>          }
> -#endif
> -#ifdef CONFIG_TPM_TIS
> -        case FTYPE_TPM_TIS: {
> -	    return tpm_tis_posix_read(fd, buf, nbytes);
> -        }
>  #endif
>  	default:
>  	    break;
> @@ -399,10 +393,6 @@ int write(int fd, const void *buf, size_t nbytes)
>  #ifdef CONFIG_TPMFRONT
>  	case FTYPE_TPMFRONT:
>  	    return tpmfront_posix_write(fd, buf, nbytes);
> -#endif
> -#ifdef CONFIG_TPM_TIS
> -	case FTYPE_TPM_TIS:
> -	    return tpm_tis_posix_write(fd, buf, nbytes);
>  #endif
>  	default:
>  	    break;
> @@ -459,10 +449,6 @@ off_t lseek(int fd, off_t offset, int whence)
>  #ifdef CONFIG_TPMFRONT
>         case FTYPE_TPMFRONT:
>            break;
> -#endif
> -#ifdef CONFIG_TPM_TIS
> -       case FTYPE_TPM_TIS:
> -          break;
>  #endif
>         case FTYPE_FILE:
>            break;
> @@ -515,11 +501,6 @@ int close(int fd)
>              shutdown_tpmfront(files[fd].dev);
>              break;
>  #endif
> -#ifdef CONFIG_TPM_TIS
> -	case FTYPE_TPM_TIS:
> -            shutdown_tpm_tis(files[fd].dev);
> -            break;
> -#endif
>  #ifdef CONFIG_KBDFRONT
>  	case FTYPE_KBD:
>              shutdown_kbdfront(files[fd].dev);
> @@ -599,10 +580,6 @@ int fstat(int fd, struct stat *buf)
>  #ifdef CONFIG_TPMFRONT
>  	case FTYPE_TPMFRONT:
>  	   return tpmfront_posix_fstat(fd, buf);
> -#endif
> -#ifdef CONFIG_TPM_TIS
> -	case FTYPE_TPM_TIS:
> -	   return tpm_tis_posix_fstat(fd, buf);
>  #endif
>  	default:
>  	    break;
> diff --git a/tpm_tis.c b/tpm_tis.c
> index 477f555..abea7a1 100644
> --- a/tpm_tis.c
> +++ b/tpm_tis.c
> @@ -792,6 +792,9 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
>     int status, burstcnt = 0;
>     int count = 0;
>     uint32_t ordinal;
> +#ifdef HAVE_LIBC
> +   struct file *file = get_file_from_fd(tpm->fd);
> +#endif
>  
>     if(tpm_tis_request_locality(tpm, tpm->locality) < 0) {
>        return -EBUSY;
> @@ -844,9 +847,10 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
>        }
>     }
>  #ifdef HAVE_LIBC
> -   if(tpm->fd >= 0) {
> -      files[tpm->fd].read = false;
> -      files[tpm->fd].offset = 0;
> +   if ( file )
> +   {
> +      file->read = false;
> +      file->offset = 0;
>     }
>  #endif
>     return len;
> @@ -1093,6 +1097,23 @@ ssize_t tpm_getcap(struct tpm_chip *chip, uint32_t subcap_id, cap_t *cap,
>          return rc;
>  }
>  
> +static void shutdown_tpm_tis(struct tpm_chip* tpm){
> +   int i;
> +
> +   printk("Shutting down tpm_tis device\n");
> +
> +   iowrite32(TPM_INT_ENABLE(tpm, tpm->locality), ~TPM_GLOBAL_INT_ENABLE);
> +
> +   /*Unmap all of the mmio pages */
> +   for(i = 0; i < 5; ++i) {
> +      if(tpm->pages[i] != NULL) {
> +	 iounmap(tpm->pages[i], PAGE_SIZE);
> +	 tpm->pages[i] = NULL;
> +      }
> +   }
> +   free(tpm);
> +   return;
> +}
>  
>  struct tpm_chip* init_tpm_tis(unsigned long baseaddr, int localities, unsigned int irq)
>  {
> @@ -1242,25 +1263,6 @@ abort_egress:
>     return NULL;
>  }
>  
> -void shutdown_tpm_tis(struct tpm_chip* tpm){
> -   int i;
> -
> -   printk("Shutting down tpm_tis device\n");
> -
> -   iowrite32(TPM_INT_ENABLE(tpm, tpm->locality), ~TPM_GLOBAL_INT_ENABLE);
> -
> -   /*Unmap all of the mmio pages */
> -   for(i = 0; i < 5; ++i) {
> -      if(tpm->pages[i] != NULL) {
> -	 iounmap(tpm->pages[i], PAGE_SIZE);
> -	 tpm->pages[i] = NULL;
> -      }
> -   }
> -   free(tpm);
> -   return;
> -}
> -
> -
>  int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** resp, size_t* resplen)
>  {
>     if(tpm->locality < 0) {
> @@ -1279,23 +1281,24 @@ int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** res
>  }
>  
>  #ifdef HAVE_LIBC
> -int tpm_tis_open(struct tpm_chip* tpm)
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +
> +static int tpm_tis_close(int fd)
>  {
> -   /* Silently prevent multiple opens */
> -   if(tpm->fd != -1) {
> -      return tpm->fd;
> -   }
> +    struct file *file = get_file_from_fd(fd);
>  
> -   tpm->fd = alloc_fd(FTYPE_TPM_TIS);
> -   printk("tpm_tis_open() -> %d\n", tpm->fd);
> -   files[tpm->fd].dev = tpm;
> -   return tpm->fd;
> +    shutdown_tpm_tis(file->dev);
> +
> +    return 0;
>  }
>  
> -int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count)
> +static int tpm_tis_posix_write(int fd, const void *buf, size_t count)
>  {
>     struct tpm_chip* tpm;
> -   tpm = files[fd].dev;
> +   struct file *file = get_file_from_fd(fd);
> +
> +   tpm = file->dev;
>  
>     if(tpm->locality < 0) {
>        printk("tpm_tis_posix_write() failed! locality not set!\n");
> @@ -1319,11 +1322,13 @@ int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count)
>     return count;
>  }
>  
> -int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
> +static int tpm_tis_posix_read(int fd, void *buf, size_t count)
>  {
>     int rc;
>     struct tpm_chip* tpm;
> -   tpm = files[fd].dev;
> +   struct file *file = get_file_from_fd(fd);
> +
> +   tpm = file->dev;
>  
>     if(count == 0) {
>        return 0;
> @@ -1337,20 +1342,24 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
>  
>  
>     /* Handle EOF case */
> -   if(files[fd].offset >= tpm->data_len) {
> +   if ( file->offset >= tpm->data_len )
> +   {
>        rc = 0;
>     } else {
> -      rc = min(tpm->data_len - files[fd].offset, count);
> -      memcpy(buf, tpm->data_buffer + files[fd].offset, rc);
> +      rc = min(tpm->data_len - file->offset, count);
> +      memcpy(buf, tpm->data_buffer + file->offset, rc);
>     }
> -   files[fd].offset += rc;
> +   file->offset += rc;
>     /* Reset the data pending flag */
>     return rc;
>  }
> -int tpm_tis_posix_fstat(int fd, struct stat* buf)
> +
> +static int tpm_tis_posix_fstat(int fd, struct stat *buf)
>  {
>     struct tpm_chip* tpm;
> -   tpm = files[fd].dev;
> +   struct file *file = get_file_from_fd(fd);
> +
> +   tpm = file->dev;
>  
>     buf->st_mode = O_RDWR;
>     buf->st_uid = 0;
> @@ -1360,6 +1369,35 @@ int tpm_tis_posix_fstat(int fd, struct stat* buf)
>     return 0;
>  }
>  
> +static struct file_ops tpm_tis_ops = {
> +    .name = "tpm_tis",
> +    .read = tpm_tis_posix_read,
> +    .write = tpm_tis_posix_write,
> +    .lseek = lseek_default,
> +    .close = tpm_tis_close,
> +    .fstat = tpm_tis_posix_fstat,
> +};
> +
> +int tpm_tis_open(struct tpm_chip* tpm)
> +{
> +   struct file *file;
> +   static unsigned int ftype_tis;
> +
> +   /* Silently prevent multiple opens */
> +   if(tpm->fd != -1) {
> +      return tpm->fd;
> +   }
> +
> +   if ( !ftype_tis )
> +       ftype_tis = alloc_file_type(&tpm_tis_ops);
> +
> +   tpm->fd = alloc_fd(ftype_tis);
> +   printk("tpm_tis_open() -> %d\n", tpm->fd);
> +   file = get_file_from_fd(tpm->fd);
> +   file->dev = tpm;
> +   return tpm->fd;
> +}
> +
>  /* TPM 2.0 */
>  
>  /*TPM2.0 Selftest*/
> -- 
> 2.26.2
> 

-- 
Samuel
Now, it we had this sort of thing:
  yield -a     for yield to all traffic
  yield -t     for yield to trucks
  yield -f     for yield to people walking (yield foot)
  yield -d t*  for yield on days starting with t
...you'd have a lot of dead people at intersections, and traffic jams you
wouldn't believe...
(Discussion in comp.os.linux.misc on the intuitiveness of commands.)


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 20:15:39 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 20:15:39 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256092.439282 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NYP-0006rw-Ok; Tue, 11 Jan 2022 20:15:37 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256092.439282; Tue, 11 Jan 2022 20:15:37 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NYP-0006rp-Kx; Tue, 11 Jan 2022 20:15:37 +0000
Received: by outflank-mailman (input) for mailman id 256092;
 Tue, 11 Jan 2022 20:15:35 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7NYN-0006rb-CU
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:15:35 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 3aafe26c-731b-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 21:15:33 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 850A9261;
 Tue, 11 Jan 2022 21:15:32 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id xM-gHFQcF9N5; Tue, 11 Jan 2022 21:15:31 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 5B9BF140;
 Tue, 11 Jan 2022 21:15:31 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7NYI-00FFRz-Dt;
 Tue, 11 Jan 2022 21:15:30 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 3aafe26c-731b-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 21:15:30 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 05/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in tpmfront
Message-ID: <20220111201530.7aa5m6s43tgntjbk@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-6-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111151215.22955-6-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 850A9261
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 16:12:08 +0100, a ecrit:
> Allocate a file type dynamically via alloc_file_type().
> 
> Instead of directly accessing the files[] array use get_file_from_fd().
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>


modulo the int fd / file * thing,

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>


> ---
>  include/lib.h      |   3 +-
>  include/tpmfront.h |   5 ---
>  lib/sys.c          |  23 -----------
>  tpmfront.c         | 100 ++++++++++++++++++++++++++++++++-------------
>  4 files changed, 72 insertions(+), 59 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index d94d142..f6478de 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -165,8 +165,7 @@ void sanity_check(void);
>  #define FTYPE_KBD        7
>  #define FTYPE_TAP        8
>  #define FTYPE_BLK        9
> -#define FTYPE_TPMFRONT  10
> -#define FTYPE_N         11
> +#define FTYPE_N         10
>  #define FTYPE_SPARE     16
>  
>  typedef int file_read_func(int fd, void *buf, size_t nbytes);
> diff --git a/include/tpmfront.h b/include/tpmfront.h
> index b7da50e..a527371 100644
> --- a/include/tpmfront.h
> +++ b/include/tpmfront.h
> @@ -81,7 +81,6 @@ int tpmfront_cmd(struct tpmfront_dev* dev, uint8_t* req, size_t reqlen, uint8_t*
>  int tpmfront_set_locality(struct tpmfront_dev* dev, int locality);
>  
>  #ifdef HAVE_LIBC
> -#include <sys/stat.h>
>  /* POSIX IO functions:
>   * use tpmfront_open() to get a file descriptor to the tpm device
>   * use write() on the fd to send a command to the backend. You must
> @@ -90,10 +89,6 @@ int tpmfront_set_locality(struct tpmfront_dev* dev, int locality);
>   * fstat() to get the size of the response and lseek() to seek on it.
>   */
>  int tpmfront_open(struct tpmfront_dev* dev);
> -int tpmfront_posix_read(int fd, uint8_t* buf, size_t count);
> -int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count);
> -int tpmfront_posix_fstat(int fd, struct stat* buf);
>  #endif
>  
> -
>  #endif
> diff --git a/lib/sys.c b/lib/sys.c
> index 4060b42..ff6be52 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -28,7 +28,6 @@
>  #include <netfront.h>
>  #include <blkfront.h>
>  #include <fbfront.h>
> -#include <tpmfront.h>
>  #include <xenbus.h>
>  #include <xenstore.h>
>  #include <poll.h>
> @@ -343,11 +342,6 @@ int read(int fd, void *buf, size_t nbytes)
>          case FTYPE_BLK: {
>  	    return blkfront_posix_read(fd, buf, nbytes);
>          }
> -#endif
> -#ifdef CONFIG_TPMFRONT
> -        case FTYPE_TPMFRONT: {
> -	    return tpmfront_posix_read(fd, buf, nbytes);
> -        }
>  #endif
>  	default:
>  	    break;
> @@ -389,10 +383,6 @@ int write(int fd, const void *buf, size_t nbytes)
>  #ifdef CONFIG_BLKFRONT
>  	case FTYPE_BLK:
>  	    return blkfront_posix_write(fd, buf, nbytes);
> -#endif
> -#ifdef CONFIG_TPMFRONT
> -	case FTYPE_TPMFRONT:
> -	    return tpmfront_posix_write(fd, buf, nbytes);
>  #endif
>  	default:
>  	    break;
> @@ -445,10 +435,6 @@ off_t lseek(int fd, off_t offset, int whence)
>  #ifdef CONFIG_BLKFRONT
>         case FTYPE_BLK:
>            break;
> -#endif
> -#ifdef CONFIG_TPMFRONT
> -       case FTYPE_TPMFRONT:
> -          break;
>  #endif
>         case FTYPE_FILE:
>            break;
> @@ -496,11 +482,6 @@ int close(int fd)
>              shutdown_blkfront(files[fd].dev);
>              break;
>  #endif
> -#ifdef CONFIG_TPMFRONT
> -	case FTYPE_TPMFRONT:
> -            shutdown_tpmfront(files[fd].dev);
> -            break;
> -#endif
>  #ifdef CONFIG_KBDFRONT
>  	case FTYPE_KBD:
>              shutdown_kbdfront(files[fd].dev);
> @@ -576,10 +557,6 @@ int fstat(int fd, struct stat *buf)
>  #ifdef CONFIG_BLKFRONT
>  	case FTYPE_BLK:
>  	   return blkfront_posix_fstat(fd, buf);
> -#endif
> -#ifdef CONFIG_TPMFRONT
> -	case FTYPE_TPMFRONT:
> -	   return tpmfront_posix_fstat(fd, buf);
>  #endif
>  	default:
>  	    break;
> diff --git a/tpmfront.c b/tpmfront.c
> index 0a2fefc..a19a052 100644
> --- a/tpmfront.c
> +++ b/tpmfront.c
> @@ -49,6 +49,10 @@
>  void tpmfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) {
>     struct tpmfront_dev* dev = (struct tpmfront_dev*) data;
>     tpmif_shared_page_t *shr = dev->page;
> +#ifdef HAVE_LIBC
> +    struct file *file = get_file_from_fd(dev->fd);
> +#endif
> +
>     /*If we get a response when we didnt make a request, just ignore it */
>     if(!dev->waiting) {
>        return;
> @@ -65,8 +69,9 @@ void tpmfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) {
>  
>     dev->waiting = 0;
>  #ifdef HAVE_LIBC
> -   if(dev->fd >= 0) {
> -      files[dev->fd].read = true;
> +   if ( file )
> +   {
> +      file->read = true;
>     }
>  #endif
>     wake_up(&dev->waitq);
> @@ -405,6 +410,10 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
>  #ifdef TPMFRONT_PRINT_DEBUG
>     int i;
>  #endif
> +#ifdef HAVE_LIBC
> +    struct file *file = dev ? get_file_from_fd(dev->fd) : NULL;
> +#endif
> +
>     /* Error Checking */
>     if(dev == NULL || dev->state != XenbusStateConnected) {
>        TPMFRONT_ERR("Tried to send message through disconnected frontend\n");
> @@ -437,9 +446,10 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
>     dev->waiting = 1;
>     dev->resplen = 0;
>  #ifdef HAVE_LIBC
> -   if(dev->fd >= 0) {
> -      files[dev->fd].read = false;
> -      files[dev->fd].offset = 0;
> +   if ( file )
> +   {
> +      file->read = false;
> +      file->offset = 0;
>        dev->respgot = false;
>     }
>  #endif
> @@ -529,25 +539,14 @@ int tpmfront_set_locality(struct tpmfront_dev* dev, int locality)
>  
>  #ifdef HAVE_LIBC
>  #include <errno.h>
> -int tpmfront_open(struct tpmfront_dev* dev)
> -{
> -   /* Silently prevent multiple opens */
> -   if(dev->fd != -1) {
> -      return dev->fd;
> -   }
>  
> -   dev->fd = alloc_fd(FTYPE_TPMFRONT);
> -   printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
> -   files[dev->fd].dev = dev;
> -   dev->respgot = false;
> -   return dev->fd;
> -}
> -
> -int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count)
> +static int tpmfront_posix_write(int fd, const void *buf, size_t count)
>  {
>     int rc;
>     struct tpmfront_dev* dev;
> -   dev = files[fd].dev;
> +   struct file *file = get_file_from_fd(fd);
> +
> +   dev = file->dev;
>  
>     if(count == 0) {
>        return 0;
> @@ -566,14 +565,15 @@ int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count)
>     return count;
>  }
>  
> -int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
> +static int tpmfront_posix_read(int fd, void *buf, size_t count)
>  {
>     int rc;
>     uint8_t* dummybuf;
>     size_t dummysz;
>     struct tpmfront_dev* dev;
> +   struct file *file = get_file_from_fd(fd);
>  
> -   dev = files[fd].dev;
> +   dev = file->dev;
>  
>     if(count == 0) {
>        return 0;
> @@ -588,29 +588,33 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
>     }
>  
>     /* handle EOF case */
> -   if(files[dev->fd].offset >= dev->resplen) {
> +   if ( file->offset >= dev->resplen )
> +   {
>        return 0;
>     }
>  
>     /* Compute the number of bytes and do the copy operation */
> -   if((rc = min(count, dev->resplen - files[dev->fd].offset)) != 0) {
> -      memcpy(buf, dev->respbuf + files[dev->fd].offset, rc);
> -      files[dev->fd].offset += rc;
> +   if ( (rc = min(count, dev->resplen - file->offset)) != 0 )
> +   {
> +      memcpy(buf, dev->respbuf + file->offset, rc);
> +      file->offset += rc;
>     }
>  
>     return rc;
>  }
>  
> -int tpmfront_posix_fstat(int fd, struct stat* buf)
> +static int tpmfront_posix_fstat(int fd, struct stat *buf)
>  {
>     uint8_t* dummybuf;
>     size_t dummysz;
>     int rc;
> -   struct tpmfront_dev* dev = files[fd].dev;
> +   struct file *file = get_file_from_fd(fd);
> +   struct tpmfront_dev* dev = file->dev;
>  
>     /* If we have a response waiting, then read it now from the backend
>      * so we can get its length*/
> -   if(dev->waiting || (files[dev->fd].read && !dev->respgot)) {
> +   if ( dev->waiting || (file->read && !dev->respgot) )
> +   {
>        if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
>  	 errno = EIO;
>  	 return -1;
> @@ -626,5 +630,43 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
>     return 0;
>  }
>  
> +static int tpmfront_close_fd(int fd)
> +{
> +    struct file *file = get_file_from_fd(fd);
> +
> +    shutdown_tpmfront(file->dev);
> +
> +    return 0;
> +}
> +
> +static struct file_ops tpmfront_ops = {
> +    .name = "tpmfront",
> +    .read = tpmfront_posix_read,
> +    .write = tpmfront_posix_write,
> +    .lseek = lseek_default,
> +    .close = tpmfront_close_fd,
> +    .fstat = tpmfront_posix_fstat,
> +};
> +
> +int tpmfront_open(struct tpmfront_dev* dev)
> +{
> +   struct file *file;
> +   static unsigned int ftype_tpmfront;
> +
> +   /* Silently prevent multiple opens */
> +   if(dev->fd != -1) {
> +      return dev->fd;
> +   }
> +
> +   if ( !ftype_tpmfront )
> +       ftype_tpmfront = alloc_file_type(&tpmfront_ops);
> +
> +   dev->fd = alloc_fd(ftype_tpmfront);
> +   printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
> +   file = get_file_from_fd(dev->fd);
> +   file->dev = dev;
> +   dev->respgot = false;
> +   return dev->fd;
> +}
>  
>  #endif
> -- 
> 2.26.2
> 

-- 
Samuel
"...very few phenomena can pull someone out of Deep Hack Mode, with two
noted exceptions: being struck by lightning, or worse, your *computer*
being struck by lightning."
(By Matt Welsh)


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 20:21:02 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 20:21:02 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256098.439302 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ndc-0008SH-Ra; Tue, 11 Jan 2022 20:21:00 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256098.439302; Tue, 11 Jan 2022 20:21:00 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ndc-0008Rb-Nh; Tue, 11 Jan 2022 20:21:00 +0000
Received: by outflank-mailman (input) for mailman id 256098;
 Tue, 11 Jan 2022 20:21:00 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7Ndb-0008P4-Qy
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:20:59 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id fc222808-731b-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 21:20:57 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id C830E678;
 Tue, 11 Jan 2022 21:20:56 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id MxJ_vLkRyhCo; Tue, 11 Jan 2022 21:20:55 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 1F285140;
 Tue, 11 Jan 2022 21:20:55 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7NdV-00FFTM-TO;
 Tue, 11 Jan 2022 21:20:53 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fc222808-731b-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 21:20:53 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 06/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in blkfront
Message-ID: <20220111202053.ii2sahyqgictpfqd@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-7-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111151215.22955-7-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: C830E678
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 16:12:09 +0100, a ecrit:
> Allocate the file type dynamically via alloc_file_type().
> 
> Instead of directly accessing the files[] array use get_file_from_fd().
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

modulo the int fd / file * thing,

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  blkfront.c         | 92 ++++++++++++++++++++++++++++++++++------------
>  include/blkfront.h |  5 ---
>  include/lib.h      |  3 +-
>  lib/sys.c          | 24 ------------
>  4 files changed, 69 insertions(+), 55 deletions(-)
> 
> diff --git a/blkfront.c b/blkfront.c
> index e3f42be..b7ea1d7 100644
> --- a/blkfront.c
> +++ b/blkfront.c
> @@ -59,10 +59,10 @@ void blkfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
>  {
>  #ifdef HAVE_LIBC
>      struct blkfront_dev *dev = data;
> -    int fd = dev->fd;
> +    struct file *file = get_file_from_fd(dev->fd);
>  
> -    if (fd != -1)
> -        files[fd].read = true;
> +    if ( file )
> +        file->read = true;
>  #endif
>      wake_up(&blkfront_queue);
>  }
> @@ -483,9 +483,13 @@ int blkfront_aio_poll(struct blkfront_dev *dev)
>  
>  moretodo:
>  #ifdef HAVE_LIBC
> -    if (dev->fd != -1) {
> -        files[dev->fd].read = false;
> -        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
> +    {
> +        struct file *file = get_file_from_fd(dev->fd);
> +
> +        if ( file ) {
> +            file->read = false;
> +            mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
> +        }
>      }
>  #endif
>  
> @@ -554,22 +558,11 @@ moretodo:
>  }
>  
>  #ifdef HAVE_LIBC
> -int blkfront_open(struct blkfront_dev *dev)
> -{
> -    /* Silently prevent multiple opens */
> -    if(dev->fd != -1) {
> -       return dev->fd;
> -    }
> -    dev->fd = alloc_fd(FTYPE_BLK);
> -    printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
> -    files[dev->fd].dev = dev;
> -    return dev->fd;
> -}
> -
> -int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
> +static int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
>  {
> -   struct blkfront_dev* dev = files[fd].dev;
> -   off_t offset = files[fd].offset;
> +   struct file *file = get_file_from_fd(fd);
> +   struct blkfront_dev* dev = file->dev;
> +   off_t offset = file->offset;
>     struct blkfront_aiocb aiocb;
>     unsigned long long disksize = dev->info.sectors * dev->info.sector_size;
>     unsigned int blocksize = dev->info.sector_size;
> @@ -711,14 +704,25 @@ int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
>     }
>  
>     free(copybuf);
> -   files[fd].offset += rc;
> +   file->offset += rc;
>     return rc;
>  
>  }
>  
> -int blkfront_posix_fstat(int fd, struct stat* buf)
> +static int blkfront_posix_read(int fd, void *buf, size_t nbytes)
> +{
> +    return blkfront_posix_rwop(fd, buf, nbytes, 0);
> +}
> +
> +static int blkfront_posix_write(int fd, const void *buf, size_t nbytes)
>  {
> -   struct blkfront_dev* dev = files[fd].dev;
> +    return blkfront_posix_rwop(fd, (void *)buf, nbytes, 1);
> +}
> +
> +static int blkfront_posix_fstat(int fd, struct stat *buf)
> +{
> +   struct file *file = get_file_from_fd(fd);
> +   struct blkfront_dev* dev = file->dev;
>  
>     buf->st_mode = dev->info.mode;
>     buf->st_uid = 0;
> @@ -728,4 +732,44 @@ int blkfront_posix_fstat(int fd, struct stat* buf)
>  
>     return 0;
>  }
> +
> +static int blkfront_close_fd(int fd)
> +{
> +    struct file *file = get_file_from_fd(fd);
> +
> +    shutdown_blkfront(file->dev);
> +
> +    return 0;
> +}
> +
> +static struct file_ops blk_ops = {
> +    .name = "blk",
> +    .read = blkfront_posix_read,
> +    .write = blkfront_posix_write,
> +    .lseek = lseek_default,
> +    .close = blkfront_close_fd,
> +    .fstat = blkfront_posix_fstat,
> +    .select_rd = select_read_flag,
> +};
> +
> +int blkfront_open(struct blkfront_dev *dev)
> +{
> +    struct file *file;
> +    static unsigned int ftype_blk;
> +
> +    /* Silently prevent multiple opens */
> +    if(dev->fd != -1) {
> +       return dev->fd;
> +    }
> +
> +    if ( !ftype_blk )
> +        ftype_blk = alloc_file_type(&blk_ops);
> +
> +    dev->fd = alloc_fd(ftype_blk);
> +    printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
> +    file = get_file_from_fd(dev->fd);
> +    file->dev = dev;
> +
> +    return dev->fd;
> +}
>  #endif
> diff --git a/include/blkfront.h b/include/blkfront.h
> index 3528af9..7f84a0a 100644
> --- a/include/blkfront.h
> +++ b/include/blkfront.h
> @@ -28,17 +28,12 @@ struct blkfront_info
>  };
>  struct blkfront_dev *init_blkfront(char *nodename, struct blkfront_info *info);
>  #ifdef HAVE_LIBC
> -#include <sys/stat.h>
>  /* POSIX IO functions:
>   * use blkfront_open() to get a file descriptor to the block device
>   * Don't use the other blkfront posix functions here directly, instead use
>   * read(), write(), lseek() and fstat() on the file descriptor
>   */
>  int blkfront_open(struct blkfront_dev *dev);
> -int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write);
> -#define blkfront_posix_write(fd, buf, count) blkfront_posix_rwop(fd, (uint8_t*)buf, count, 1)
> -#define blkfront_posix_read(fd, buf, count) blkfront_posix_rwop(fd, (uint8_t*)buf, count, 0)
> -int blkfront_posix_fstat(int fd, struct stat* buf);
>  #endif
>  void blkfront_aio(struct blkfront_aiocb *aiocbp, int write);
>  #define blkfront_aio_read(aiocbp) blkfront_aio(aiocbp, 0)
> diff --git a/include/lib.h b/include/lib.h
> index f6478de..05f5083 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -164,8 +164,7 @@ void sanity_check(void);
>  #define FTYPE_FB         6
>  #define FTYPE_KBD        7
>  #define FTYPE_TAP        8
> -#define FTYPE_BLK        9
> -#define FTYPE_N         10
> +#define FTYPE_N          9
>  #define FTYPE_SPARE     16
>  
>  typedef int file_read_func(int fd, void *buf, size_t nbytes);
> diff --git a/lib/sys.c b/lib/sys.c
> index ff6be52..f84fedd 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -337,11 +337,6 @@ int read(int fd, void *buf, size_t nbytes)
>  	    }
>  	    return ret * sizeof(union xenfb_in_event);
>          }
> -#endif
> -#ifdef CONFIG_BLKFRONT
> -        case FTYPE_BLK: {
> -	    return blkfront_posix_read(fd, buf, nbytes);
> -        }
>  #endif
>  	default:
>  	    break;
> @@ -379,10 +374,6 @@ int write(int fd, const void *buf, size_t nbytes)
>  	case FTYPE_TAP:
>  	    netfront_xmit(files[fd].dev, (void*) buf, nbytes);
>  	    return nbytes;
> -#endif
> -#ifdef CONFIG_BLKFRONT
> -	case FTYPE_BLK:
> -	    return blkfront_posix_write(fd, buf, nbytes);
>  #endif
>  	default:
>  	    break;
> @@ -432,10 +423,6 @@ off_t lseek(int fd, off_t offset, int whence)
>          return ops->lseek(fd, offset, whence);
>  
>      switch(files[fd].type) {
> -#ifdef CONFIG_BLKFRONT
> -       case FTYPE_BLK:
> -          break;
> -#endif
>         case FTYPE_FILE:
>            break;
>         default:
> @@ -477,11 +464,6 @@ int close(int fd)
>  	    shutdown_netfront(files[fd].dev);
>              break;
>  #endif
> -#ifdef CONFIG_BLKFRONT
> -	case FTYPE_BLK:
> -            shutdown_blkfront(files[fd].dev);
> -            break;
> -#endif
>  #ifdef CONFIG_KBDFRONT
>  	case FTYPE_KBD:
>              shutdown_kbdfront(files[fd].dev);
> @@ -554,10 +536,6 @@ int fstat(int fd, struct stat *buf)
>  	    buf->st_ctime = time(NULL);
>  	    return 0;
>  	}
> -#ifdef CONFIG_BLKFRONT
> -	case FTYPE_BLK:
> -	   return blkfront_posix_fstat(fd, buf);
> -#endif
>  	default:
>  	    break;
>      }
> @@ -663,7 +641,6 @@ static const char *file_types[] = {
>      [FTYPE_CONSOLE] = "console",
>      [FTYPE_SOCKET]  = "socket",
>      [FTYPE_TAP]     = "net",
> -    [FTYPE_BLK]     = "blk",
>      [FTYPE_KBD]     = "kbd",
>      [FTYPE_FB]      = "fb",
>  };
> @@ -841,7 +818,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  	    FD_CLR(i, exceptfds);
>  	    break;
>  	case FTYPE_TAP:
> -	case FTYPE_BLK:
>  	case FTYPE_KBD:
>  	case FTYPE_FB:
>  	    if (FD_ISSET(i, readfds)) {
> -- 
> 2.26.2
> 

-- 
Samuel
gawk; talk; nice; date; wine; grep; touch; unzip; strip;  \
touch; gasp; finger; gasp; lyx; gasp; latex; mount; fsck; \
more; yes; gasp; umount; make clean; make mrproper; sleep


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 20:22:18 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 20:22:18 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256105.439324 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Nes-0001BB-7i; Tue, 11 Jan 2022 20:22:18 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256105.439324; Tue, 11 Jan 2022 20:22:18 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Nes-0001B4-4K; Tue, 11 Jan 2022 20:22:18 +0000
Received: by outflank-mailman (input) for mailman id 256105;
 Tue, 11 Jan 2022 20:22:16 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7Neq-00017B-Bz
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:22:16 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 2a8678a0-731c-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 21:22:15 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id EE19440E;
 Tue, 11 Jan 2022 21:22:14 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id TAT_ODCsa4fw; Tue, 11 Jan 2022 21:22:14 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 8AEF5261;
 Tue, 11 Jan 2022 21:22:13 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7Nem-00FFTk-Ru;
 Tue, 11 Jan 2022 21:22:12 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 2a8678a0-731c-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 21:22:12 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 07/12] mini-os: use get_file_from_fd() in netfront
Message-ID: <20220111202212.k5lvnnneihoqagnl@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-8-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111151215.22955-8-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: EE19440E
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 16:12:10 +0100, a ecrit:
> Instead of directly accessing the files[] array use get_file_from_fd().
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

modulo the int fd / file * thing,

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h |  3 +--
>  lib/sys.c     | 23 ------------------
>  netfront.c    | 64 ++++++++++++++++++++++++++++++++++++++++++++-------
>  3 files changed, 57 insertions(+), 33 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 05f5083..aa8036e 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -163,8 +163,7 @@ void sanity_check(void);
>  #define FTYPE_SAVEFILE   5
>  #define FTYPE_FB         6
>  #define FTYPE_KBD        7
> -#define FTYPE_TAP        8
> -#define FTYPE_N          9
> +#define FTYPE_N          8
>  #define FTYPE_SPARE     16
>  
>  typedef int file_read_func(int fd, void *buf, size_t nbytes);
> diff --git a/lib/sys.c b/lib/sys.c
> index f84fedd..7f2e11f 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -303,17 +303,6 @@ int read(int fd, void *buf, size_t nbytes)
>  	case FTYPE_SOCKET:
>  	    return lwip_read(files[fd].fd, buf, nbytes);
>  #endif
> -#ifdef CONFIG_NETFRONT
> -	case FTYPE_TAP: {
> -	    ssize_t ret;
> -	    ret = netfront_receive(files[fd].dev, buf, nbytes);
> -	    if (ret <= 0) {
> -		errno = EAGAIN;
> -		return -1;
> -	    }
> -	    return ret;
> -	}
> -#endif
>  #ifdef CONFIG_KBDFRONT
>          case FTYPE_KBD: {
>              int ret, n;
> @@ -369,11 +358,6 @@ int write(int fd, const void *buf, size_t nbytes)
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
>  	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
> -#endif
> -#ifdef CONFIG_NETFRONT
> -	case FTYPE_TAP:
> -	    netfront_xmit(files[fd].dev, (void*) buf, nbytes);
> -	    return nbytes;
>  #endif
>  	default:
>  	    break;
> @@ -459,11 +443,6 @@ int close(int fd)
>  	    res = lwip_close(files[fd].fd);
>              break;
>  #endif
> -#ifdef CONFIG_NETFRONT
> -	case FTYPE_TAP:
> -	    shutdown_netfront(files[fd].dev);
> -            break;
> -#endif
>  #ifdef CONFIG_KBDFRONT
>  	case FTYPE_KBD:
>              shutdown_kbdfront(files[fd].dev);
> @@ -640,7 +619,6 @@ static const char *file_types[] = {
>      [FTYPE_NONE]    = "none",
>      [FTYPE_CONSOLE] = "console",
>      [FTYPE_SOCKET]  = "socket",
> -    [FTYPE_TAP]     = "net",
>      [FTYPE_KBD]     = "kbd",
>      [FTYPE_FB]      = "fb",
>  };
> @@ -817,7 +795,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>                  n++;
>  	    FD_CLR(i, exceptfds);
>  	    break;
> -	case FTYPE_TAP:
>  	case FTYPE_KBD:
>  	case FTYPE_FB:
>  	    if (FD_ISSET(i, readfds)) {
> diff --git a/netfront.c b/netfront.c
> index 7696451..f86c6a2 100644
> --- a/netfront.c
> +++ b/netfront.c
> @@ -248,14 +248,14 @@ void netfront_select_handler(evtchn_port_t port, struct pt_regs *regs, void *dat
>  {
>      int flags;
>      struct netfront_dev *dev = data;
> -    int fd = dev->fd;
> +    struct file *file = get_file_from_fd(dev->fd);
>  
>      local_irq_save(flags);
>      network_tx_buf_gc(dev);
>      local_irq_restore(flags);
>  
> -    if (fd != -1)
> -        files[fd].read = true;
> +    if ( file )
> +        file->read = true;
>      wake_up(&netfront_queue);
>  }
>  #endif
> @@ -565,8 +565,54 @@ error:
>  }
>  
>  #ifdef HAVE_LIBC
> +static int netfront_read(int fd, void *buf, size_t nbytes)
> +{
> +    ssize_t ret;
> +    struct file *file = get_file_from_fd(fd);
> +
> +    ret = netfront_receive(file->dev, buf, nbytes);
> +    if ( ret <= 0 )
> +    {
> +        errno = EAGAIN;
> +        return -1;
> +    }
> +
> +    return ret;
> +}
> +
> +static int netfront_write(int fd, const void *buf, size_t nbytes)
> +{
> +    struct file *file = get_file_from_fd(fd);
> +
> +    netfront_xmit(file->dev, (void *)buf, nbytes);
> +
> +    return nbytes;
> +}
> +
> +static int netfront_close_fd(int fd)
> +{
> +    struct file *file = get_file_from_fd(fd);
> +
> +    shutdown_netfront(file->dev);
> +
> +    return 0;
> +}
> +
> +static struct file_ops netfront_ops = {
> +    .name = "net",
> +    .read = netfront_read,
> +    .write = netfront_write,
> +    .close = netfront_close_fd,
> +    .select_rd = select_read_flag,
> +};
> +
>  int netfront_tap_open(char *nodename) {
>      struct netfront_dev *dev;
> +    struct file *file;
> +    static unsigned int ftype_netfront;
> +
> +    if ( !ftype_netfront )
> +        ftype_netfront = alloc_file_type(&netfront_ops);
>  
>      dev = init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL);
>      if (!dev) {
> @@ -574,9 +620,10 @@ int netfront_tap_open(char *nodename) {
>  	errno = EIO;
>  	return -1;
>      }
> -    dev->fd = alloc_fd(FTYPE_TAP);
> +    dev->fd = alloc_fd(ftype_netfront);
>      printk("tap_open(%s) -> %d\n", nodename, dev->fd);
> -    files[dev->fd].dev = dev;
> +    file = get_file_from_fd(dev->fd);
> +    file->dev = dev;
>      return dev->fd;
>  }
>  #endif
> @@ -772,7 +819,8 @@ void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len)
>  ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t len)
>  {
>      unsigned long flags;
> -    int fd = dev->fd;
> +    struct file *file = get_file_from_fd(dev->fd);
> +
>      ASSERT(current == main_thread);
>  
>      dev->rlen = 0;
> @@ -781,9 +829,9 @@ ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t l
>  
>      local_irq_save(flags);
>      network_rx(dev);
> -    if (!dev->rlen && fd != -1)
> +    if ( !dev->rlen && file )
>          /* No data for us, make select stop returning */
> -        files[fd].read = false;
> +        file->read = false;
>      /* Before re-enabling the interrupts, in case a packet just arrived in the
>       * meanwhile. */
>      local_irq_restore(flags);
> -- 
> 2.26.2
> 

-- 
Samuel
/*
 * [...] Note that 120 sec is defined in the protocol as the maximum
 * possible RTT.  I guess we'll have to use something other than TCP
 * to talk to the University of Mars.
 * PAWS allows us longer timeouts and large windows, so once implemented
 * ftp to mars will work nicely.
 */
(from /usr/src/linux/net/inet/tcp.c, concerning RTT [retransmission timeout])


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 20:26:13 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 20:26:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256114.439344 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Nie-0001ym-4H; Tue, 11 Jan 2022 20:26:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256114.439344; Tue, 11 Jan 2022 20:26:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Nid-0001y5-Uw; Tue, 11 Jan 2022 20:26:11 +0000
Received: by outflank-mailman (input) for mailman id 256114;
 Tue, 11 Jan 2022 20:26:10 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7Nic-0001w4-F9
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:26:10 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id b5a73d8b-731c-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 21:26:08 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id EE6FD40E;
 Tue, 11 Jan 2022 21:26:07 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id OYgKDOkHK2uc; Tue, 11 Jan 2022 21:26:07 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 2E234261;
 Tue, 11 Jan 2022 21:26:07 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7NiX-00FFaW-VT;
 Tue, 11 Jan 2022 21:26:05 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: b5a73d8b-731c-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 21:26:05 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 08/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in fbfront
Message-ID: <20220111202605.sihxjumqcxbfthxf@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-9-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111151215.22955-9-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: EE6FD40E
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 16:12:11 +0100, a ecrit:
> +static struct file_ops fb_ops = {
> +    .name = ".fb",

Why a dot?


Apart from that, and modulo the int fd / file * thing,

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>



From minios-devel-bounces@lists.xenproject.org Tue Jan 11 20:35:09 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 20:35:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256125.439375 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NrH-0004Lt-9L; Tue, 11 Jan 2022 20:35:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256125.439375; Tue, 11 Jan 2022 20:35:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NrH-0004Lp-6Q; Tue, 11 Jan 2022 20:35:07 +0000
Received: by outflank-mailman (input) for mailman id 256125;
 Tue, 11 Jan 2022 20:35:05 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7NrF-000462-IW
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:35:05 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id f4736e51-731d-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 21:35:03 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id E335537A;
 Tue, 11 Jan 2022 21:35:02 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id xbF25ZqM8-4f; Tue, 11 Jan 2022 21:35:02 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 6B9D8140;
 Tue, 11 Jan 2022 21:35:02 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7NrB-00FFgN-8g;
 Tue, 11 Jan 2022 21:35:01 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: f4736e51-731d-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 21:35:01 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 09/12] mini-os: use file_ops and get_file_from_fd()
 for console
Message-ID: <20220111203501.tywfn4czhwavhgrf@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-10-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111151215.22955-10-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: E335537A
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 16:12:12 +0100, a ecrit:
> +static int consfront_fstat(int fd, struct stat *buf)
> +{
> +    struct file *file = get_file_from_fd(fd);
> +
> +    buf->st_mode = S_IRUSR | S_IWUSR;
> +    buf->st_mode |= (file->type == FTYPE_CONSOLE) ? S_IFCHR : S_IFREG;
> +    buf->st_atime = buf->st_mtime = buf->st_ctime = time(NULL);
> +
> +    return 0;
> +}

This seems to be missing filling st_uid, st_gid, etc.?

Samuel


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 20:38:18 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 20:38:18 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256129.439379 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NuM-0004ov-I1; Tue, 11 Jan 2022 20:38:18 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256129.439379; Tue, 11 Jan 2022 20:38:18 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NuM-0004oo-F9; Tue, 11 Jan 2022 20:38:18 +0000
Received: by outflank-mailman (input) for mailman id 256129;
 Tue, 11 Jan 2022 20:38:17 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7NuL-0004od-3X
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:38:17 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 67280df6-731e-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 21:38:16 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 8FC55678;
 Tue, 11 Jan 2022 21:38:15 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id zVLRcc43YJzm; Tue, 11 Jan 2022 21:38:15 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id F382D174;
 Tue, 11 Jan 2022 21:38:14 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7NuH-00FFio-QR;
 Tue, 11 Jan 2022 21:38:13 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 67280df6-731e-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 21:38:13 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 10/12] mini-os: add struct file_ops for file type
 socket
Message-ID: <20220111203813.rnx6fuihlq7soxex@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-11-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111151215.22955-11-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 8FC55678
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 16:12:13 +0100, a ecrit:
> +static int socket_fstat(int fd, struct stat *buf)
> +{
> +    buf->st_mode = S_IFSOCK | S_IRUSR | S_IWUSR;
> +    buf->st_atime = buf->st_mtime = buf->st_ctime = time(NULL);
> +
> +    return 0;
> +}

Similarly, this seems to be missing setting st_uid, st_gid, st_size?

Samuel


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 20:42:14 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 20:42:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256134.439395 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ny8-0006Gc-4E; Tue, 11 Jan 2022 20:42:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256134.439395; Tue, 11 Jan 2022 20:42:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ny8-0006GV-0y; Tue, 11 Jan 2022 20:42:12 +0000
Received: by outflank-mailman (input) for mailman id 256134;
 Tue, 11 Jan 2022 20:42:10 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7Ny6-0006GK-Kl
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:42:10 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id f231f8ec-731e-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 21:42:09 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 7BFDC678;
 Tue, 11 Jan 2022 21:42:08 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id J3PqWnO4Gxlu; Tue, 11 Jan 2022 21:42:07 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 558D4174;
 Tue, 11 Jan 2022 21:42:07 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7Ny2-00FFmd-7I;
 Tue, 11 Jan 2022 21:42:06 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: f231f8ec-731e-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 21:42:06 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
Subject: Re: [PATCH v2 17/18] mini-os: use function vectors instead of switch
 for file operations
Message-ID: <20220111204206.4cueltjygd2ydnga@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-18-jgross@suse.com>
 <20220111200547.wb6mwl6zxtf3y54c@begin>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111200547.wb6mwl6zxtf3y54c@begin>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 7BFDC678
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Samuel Thibault, le mar. 11 janv. 2022 21:05:47 +0100, a ecrit:
> Juergen Gross, le mar. 11 janv. 2022 15:58:16 +0100, a ecrit:
> > @@ -370,8 +413,45 @@ int write(int fd, const void *buf, size_t nbytes)
> >      return -1;
> >  }
> >  
> > +off_t lseek_default(int fd, off_t offset, int whence)
> > +{
> > +    switch ( whence )
> > +    {
> 
> Is there a reason for making this one a separate function, unlike others
> for which you kept the code in the main function?

Ah, I guess that it's because in the end, it's the only function that
has a default implementation left?  And thus the rule is that unless the
method is set, the default implementation is ENOSYS?  I agree with that,
then.

Samuel


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 20:42:34 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 20:42:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256137.439410 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NyU-0006pD-FW; Tue, 11 Jan 2022 20:42:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256137.439410; Tue, 11 Jan 2022 20:42:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7NyU-0006p4-CJ; Tue, 11 Jan 2022 20:42:34 +0000
Received: by outflank-mailman (input) for mailman id 256137;
 Tue, 11 Jan 2022 20:42:33 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7NyT-0006GK-22
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:42:33 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ffded402-731e-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 21:42:32 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id DC4EE678;
 Tue, 11 Jan 2022 21:42:31 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id VPcginCM2lUV; Tue, 11 Jan 2022 21:42:31 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 2B053174;
 Tue, 11 Jan 2022 21:42:31 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7NyQ-00FFmz-Nn;
 Tue, 11 Jan 2022 21:42:30 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ffded402-731e-11ec-9ce5-af14b9085ebd
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 21:42:30 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 11/12] mini-os: add struct file_ops for FTYPE_FILE
Message-ID: <20220111204230.xd4rj7fkmidooiik@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-12-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111151215.22955-12-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: DC4EE678
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 16:12:14 +0100, a ecrit:
> FTYPE_FILE is the last relevant file type without a struct file_ops.
> Add it.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  lib/sys.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/lib/sys.c b/lib/sys.c
> index 12deaed..0f42e97 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -99,6 +99,11 @@ static struct file_ops file_ops_none = {
>      .name = "none",
>  };
>  
> +static struct file_ops file_file_ops = {
> +    .name = "file",
> +    .lseek = lseek_default,
> +};
> +
>  #ifdef HAVE_LWIP
>  static int socket_read(int fd, void *buf, size_t nbytes)
>  {
> @@ -160,6 +165,7 @@ static struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
>  #ifdef CONFIG_CONSFRONT
>      [FTYPE_CONSOLE] = &console_ops,
>  #endif
> +    [FTYPE_FILE] = &file_file_ops,
>  #ifdef HAVE_LWIP
>      [FTYPE_SOCKET] = &socket_ops,
>  #endif
> @@ -397,16 +403,9 @@ off_t lseek(int fd, off_t offset, int whence)
>      if ( ops->lseek )
>          return ops->lseek(fd, offset, whence);
>  
> -    switch(files[fd].type) {
> -       case FTYPE_FILE:
> -          break;
> -       default:
> -          /* Not implemented for this filetype */
> -          errno = ESPIPE;
> -          return (off_t) -1;
> -    }
> -
> -    return lseek_default(fd, offset, whence);
> +    /* Not implemented for this filetype */
> +    errno = ESPIPE;
> +    return (off_t) -1;
>  }
>  
>  int fsync(int fd) {
> -- 
> 2.26.2
> 

-- 
Samuel
"...[Linux's] capacity to talk via any medium except smoke signals."
(By Dr. Greg Wettstein, Roger Maris Cancer Center)


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 20:42:52 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 20:42:52 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256141.439436 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Nym-0007eN-3e; Tue, 11 Jan 2022 20:42:52 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256141.439436; Tue, 11 Jan 2022 20:42:52 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Nyl-0007eG-W8; Tue, 11 Jan 2022 20:42:51 +0000
Received: by outflank-mailman (input) for mailman id 256141;
 Tue, 11 Jan 2022 20:42:51 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZoZL=R3=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7Nyk-0007Ce-Vg
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:42:50 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 09fbecd2-731f-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 21:42:49 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id DE358678;
 Tue, 11 Jan 2022 21:42:48 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id O9ROnKIghYpM; Tue, 11 Jan 2022 21:42:48 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 81A25140;
 Tue, 11 Jan 2022 21:42:47 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7Nyh-00FFnE-3z;
 Tue, 11 Jan 2022 21:42:47 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 09fbecd2-731f-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 21:42:47 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 12/12] mini-os: make files array private to sys.c
Message-ID: <20220111204247.iqfobcpsnnqnx2el@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-13-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111151215.22955-13-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: DE358678
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 16:12:15 +0100, a ecrit:
> There is no user of the files[] array outside of lib/sys.c left, so
> it can be made static.

Yay!

> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/lib.h | 2 --
>  lib/sys.c     | 2 +-
>  2 files changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index c171fe8..80e804b 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -199,8 +199,6 @@ struct file {
>      };
>  };
>  
> -extern struct file files[];
> -
>  struct file *get_file_from_fd(int fd);
>  int alloc_fd(unsigned int type);
>  void close_all_files(void);
> diff --git a/lib/sys.c b/lib/sys.c
> index 0f42e97..c0cad87 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -89,7 +89,7 @@ extern void minios_evtchn_close_fd(int fd);
>  extern void minios_gnttab_close_fd(int fd);
>  
>  pthread_mutex_t fd_lock = PTHREAD_MUTEX_INITIALIZER;
> -struct file files[NOFILE] = {
> +static struct file files[NOFILE] = {
>      { .type = FTYPE_CONSOLE }, /* stdin */
>      { .type = FTYPE_CONSOLE }, /* stdout */
>      { .type = FTYPE_CONSOLE }, /* stderr */
> -- 
> 2.26.2
> 

-- 
Samuel
#include <culture.h>


From minios-devel-bounces@lists.xenproject.org Tue Jan 11 20:58:41 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jan 2022 20:58:41 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256158.439450 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7OE4-0001P4-Lw; Tue, 11 Jan 2022 20:58:40 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256158.439450; Tue, 11 Jan 2022 20:58:40 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7OE4-0001Ox-J9; Tue, 11 Jan 2022 20:58:40 +0000
Received: by outflank-mailman (input) for mailman id 256158;
 Tue, 11 Jan 2022 20:58:39 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=WMrX=R3=gmail.com=jandryuk@srs-se1.protection.inumbo.net>)
 id 1n7OE3-0001Om-Js
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:58:39 +0000
Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com
 [2a00:1450:4864:20::12b])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 3fe6eeb7-7321-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 21:58:38 +0100 (CET)
Received: by mail-lf1-x12b.google.com with SMTP id o12so1087309lfk.1;
 Tue, 11 Jan 2022 12:58:38 -0800 (PST)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 3fe6eeb7-7321-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20210112;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to
         :cc;
        bh=T1v+9Ueeg7OUQ3kdGw68OPT8Wm7+J1hRdoFF6SyrlxQ=;
        b=dO552taYRC5MqeaXNw/2wooBC+b8eO3MpdHdMrzRRyHd/yRb60MgaWsX7b6jrYkmBv
         eE47KfBKv2Gw9UWVJRn1GGxVVdgVM9+3wuTE8QwiaE/yXQoDE4+bSRY+AdicMea+8UYm
         LU822VxSMB6ViC3KyW8N/Yc/fzGn2o4JrFNAOxXc8bi8NEn9va+zYBqARo+uAEbr4hgS
         Tqbp5VKPsL6wUAQCiUAWZzrVnIjl0QaF1nOdnCUffWveoSp63IEOjl+i/5T9hbTiT4fQ
         lKKBlk+uW7qoKeFu2dQ7uY36xkPKu4yeNd+BNNFv/NMoo6A/3hsp0UvxdnOrXANnJKWD
         cQpQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20210112;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to:cc;
        bh=T1v+9Ueeg7OUQ3kdGw68OPT8Wm7+J1hRdoFF6SyrlxQ=;
        b=tPoq4VTiTBbWE4i8TcR6e4i+6yTRSLXiJfxP+wNiWorPVn1E5Xt4IN+d+c4IBNdOdc
         bUnZLYA2vTZtTZ1ku4EZs+jfWCuEF7757tRngV4CTXZUE70XtV3SOsCWt/TZoL9T+ooW
         YtLMUDiD7So+Fl7QKz8AFbqS2oGi7itVjo6tQnJ5NXmzvS8DQLGpzlzLBzUzID0KPH3/
         RUamKuOnfxBR7I20IIoWEWYbfn35E5v496dwUOqbcTm3S+5mHhsrp0d7uHMWu+luAHCi
         7FWCI8S13/En/Pc9v28MrGepWf5a/1cnpl6mAw6rtc3F1S3jWwYMKZL2zYlN8LvAqX0X
         iEmw==
X-Gm-Message-State: AOAM533La/A62WwIOuz34CvNgg9DyGPdYpSd7JN/laMDlATfkg15/Gs0
	UiVrEiNlvN4rLdn5OKuGt92FEBdhGX5c5iJunuY=
X-Google-Smtp-Source: ABdhPJwsZgYQK/QDNS7/XYyoGOTw2hRcfA8tQikuefdLMc9jR5U9Sozdg6EdupTPlksDCEb9VgmPXIACxsw4hRU299Y=
X-Received: by 2002:a05:651c:1241:: with SMTP id h1mr2097250ljh.459.1641934718135;
 Tue, 11 Jan 2022 12:58:38 -0800 (PST)
MIME-Version: 1.0
References: <20220111151215.22955-1-jgross@suse.com> <20220111151215.22955-5-jgross@suse.com>
 <95614df8-c22d-3e1e-b976-84bbed1b30be@srcf.net>
In-Reply-To: <95614df8-c22d-3e1e-b976-84bbed1b30be@srcf.net>
From: Jason Andryuk <jandryuk@gmail.com>
Date: Tue, 11 Jan 2022 15:58:26 -0500
Message-ID: <CAKf6xps03Dn8kaAPeAgctU9Dze17qX-uLVx05+yX038weqwtJQ@mail.gmail.com>
Subject: Re: [PATCH v2 04/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in tpm_tis
To: Andrew Cooper <amc96@srcf.net>
Cc: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org, 
	xen-devel <xen-devel@lists.xenproject.org>, 
	Samuel Thibault <samuel.thibault@ens-lyon.org>, Wei Liu <wl@xen.org>, 
	Daniel Smith <dpsmith@apertussolutions.com>
Content-Type: text/plain; charset="UTF-8"

On Tue, Jan 11, 2022 at 3:29 PM Andrew Cooper <amc96@srcf.net> wrote:
>
> On 11/01/2022 15:12, Juergen Gross wrote:
> > diff --git a/tpm_tis.c b/tpm_tis.c
> > index 477f555..abea7a1 100644
> > --- a/tpm_tis.c
> > +++ b/tpm_tis.c
> > @@ -1093,6 +1097,23 @@ ssize_t tpm_getcap(struct tpm_chip *chip, uint32_t subcap_id, cap_t *cap,
> >          return rc;
> >  }
> >
> > +static void shutdown_tpm_tis(struct tpm_chip* tpm){
>
> Style, as you're moving it.  Also in the function.
>
> > @@ -1360,6 +1369,35 @@ int tpm_tis_posix_fstat(int fd, struct stat* buf)
> >     return 0;
> >  }
> >
> > +static struct file_ops tpm_tis_ops = {
> > +    .name = "tpm_tis",
> > +    .read = tpm_tis_posix_read,
> > +    .write = tpm_tis_posix_write,
> > +    .lseek = lseek_default,
> > +    .close = tpm_tis_close,
> > +    .fstat = tpm_tis_posix_fstat,
> > +};
> > +
> > +int tpm_tis_open(struct tpm_chip* tpm)
>
> Style.
>
> > +{
> > +   struct file *file;
> > +   static unsigned int ftype_tis;
> > +
> > +   /* Silently prevent multiple opens */
> > +   if(tpm->fd != -1) {
> > +      return tpm->fd;
> > +   }
>
> Another WTF moment.  We silently swallow multiple open()s, but don't
> refcout close()s ?
>
> This cannot be correct, or sensible, behaviour.
>
> Jason/Daniel - thoughts?

Looks like vtpmmgr only opens a single global fd, so it has not been a
problem in practice.

You need some sort of synchronization to let multiple entities access
the TPM.  So limiting to only a single entity/single FD is a
reasonable restriction.

Regards,
Jason


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 07:34:46 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 07:34:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256253.439623 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Y9b-0002R3-LB; Wed, 12 Jan 2022 07:34:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256253.439623; Wed, 12 Jan 2022 07:34:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Y9b-0002Qw-Hw; Wed, 12 Jan 2022 07:34:43 +0000
Received: by outflank-mailman (input) for mailman id 256253;
 Wed, 12 Jan 2022 07:34:41 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Y9Z-0002Ql-H8
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 07:34:41 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 19ac725a-737a-11ec-81c1-a30af7de8005;
 Wed, 12 Jan 2022 08:34:39 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 583281F3BB;
 Wed, 12 Jan 2022 07:34:39 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 28B3713B32;
 Wed, 12 Jan 2022 07:34:39 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id tc1lCI+E3mEeDwAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 07:34:39 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 19ac725a-737a-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641972879; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=WpAam2Xb/p4rOHtj0x911ZgbJaMNbmmnG47Q7yxMM7Q=;
	b=g9ut3n6sDqSDmG71Q+UW30bgHb+JAclEiezNTjJSd/x1lNbsV0gdNhpLUNf9mUcB0EFPk4
	kgO5r1eu3wAKmkGlFa6z4CV5pRJ1XWpYg6RQ/vNPXoMQucIbWcTnzeiZmE9UvBWdD5/8gc
	fFHNQuTv9z0yHkdRojG3EIcgO3j8J18=
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-18-jgross@suse.com>
 <a2d4c905-c477-8553-85a7-90168d914b6e@srcf.net>
From: Juergen Gross <jgross@suse.com>
Subject: Re: [PATCH v2 17/18] mini-os: use function vectors instead of switch
 for file operations
Message-ID: <08672989-53be-1551-f001-0d2c0435b586@suse.com>
Date: Wed, 12 Jan 2022 08:34:38 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <a2d4c905-c477-8553-85a7-90168d914b6e@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="1yRxLjG8LI6TWxRXbZOs6dgGzDbd4tlbj"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--1yRxLjG8LI6TWxRXbZOs6dgGzDbd4tlbj
Content-Type: multipart/mixed; boundary="PLE3ZJvZpi5M3UTKkAGKQjQ8OKjGp7roo";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <08672989-53be-1551-f001-0d2c0435b586@suse.com>
Subject: Re: [PATCH v2 17/18] mini-os: use function vectors instead of switch
 for file operations
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-18-jgross@suse.com>
 <a2d4c905-c477-8553-85a7-90168d914b6e@srcf.net>
In-Reply-To: <a2d4c905-c477-8553-85a7-90168d914b6e@srcf.net>

--PLE3ZJvZpi5M3UTKkAGKQjQ8OKjGp7roo
Content-Type: multipart/mixed;
 boundary="------------24BCAA1F1F5DE129C8C99AE9"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------24BCAA1F1F5DE129C8C99AE9
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 11.01.22 19:08, Andrew Cooper wrote:
> On 11/01/2022 14:58, Juergen Gross wrote:
>> Introduce file type specific function vectors for all the needed file
>> operations which are file type specific in order to prepare replacing
>> the large switch statements in each generic file function.
>>
>> Add a function to allocate a new file type dynamically in order to
>> prepare removing direct dependencies to external components in the
>> future. For this reason switch the file type from an enum to an
>> unsigned int. Prepare removal of some statically defines file types
>> by putting them at the end of the defined list.
>>
>> Change the debug output for the file type from a single character to
>> a string in order to support a future removal of the file_types[]
>> array.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>=20
> A few misc observations.
>=20
>> diff --git a/include/lib.h b/include/lib.h
>> index 7a0546b..b40e213 100644
>> --- a/include/lib.h
>> +++ b/include/lib.h
>> @@ -154,25 +155,51 @@ do {                                            =
               \
>>   void sanity_check(void);
>>  =20
>>   #ifdef HAVE_LIBC
>> -enum fd_type {
>> -    FTYPE_NONE =3D 0,
>> -    FTYPE_CONSOLE,
>> -    FTYPE_FILE,
>> -    FTYPE_XENBUS,
>> -    FTYPE_XC,
>> -    FTYPE_EVTCHN,
>> -    FTYPE_GNTMAP,
>> -    FTYPE_SOCKET,
>> -    FTYPE_TAP,
>> -    FTYPE_BLK,
>> -    FTYPE_KBD,
>> -    FTYPE_FB,
>> -    FTYPE_MEM,
>> -    FTYPE_SAVEFILE,
>> -    FTYPE_TPMFRONT,
>> -    FTYPE_TPM_TIS,
>> +#define FTYPE_NONE       0
>> +#define FTYPE_CONSOLE    1
>> +#define FTYPE_FILE       2
>> +#define FTYPE_SOCKET     3
>> +#define FTYPE_MEM        4
>> +#define FTYPE_SAVEFILE   5
>> +#define FTYPE_FB         6
>> +#define FTYPE_KBD        7
>> +#define FTYPE_TAP        8
>> +#define FTYPE_BLK        9
>> +#define FTYPE_TPMFRONT  10
>> +#define FTYPE_TPM_TIS   11
>> +#define FTYPE_XENBUS    12
>> +#define FTYPE_GNTMAP    13
>> +#define FTYPE_EVTCHN    14
>> +#define FTYPE_XC        15
>> +#define FTYPE_N         16
>> +#define FTYPE_SPARE     16
>> +
>> +typedef int file_read_func(int fd, void *buf, size_t nbytes);
>> +typedef int file_write_func(int fd, const void *buf, size_t nbytes);
>> +typedef off_t file_lseek_func(int fd, off_t offset, int whence);
>> +typedef int file_close_func(int fd);
>> +typedef int file_fstat_func(int fd, struct stat *buf);
>> +typedef int file_fcntl_func(int fd, int cmd, va_list args);
>> +typedef bool file_select_func(int fd);
>=20
> Are these typedef's useful?=C2=A0 I don't see them used anywhere other =
than
> the file_ops structure.

I can drop them.

>=20
>> +
>> +struct file_ops {
>> +    const char *name;
>> +    file_read_func *read;
>> +    file_write_func *write;
>> +    file_lseek_func *lseek;
>> +    file_close_func *close;
>> +    file_fstat_func *fstat;
>> +    file_fcntl_func *fcntl;
>> +    file_select_func *select_rd;
>> +    file_select_func *select_wr;
>>   };
>>  =20
>> +unsigned int alloc_file_type(struct file_ops *ops);
>=20
> const.

Yes.

>=20
>> +
>> +off_t lseek_default(int fd, off_t offset, int whence);
>> +bool select_yes(int fd);
>> +bool select_read_flag(int fd);
>> +
>>   LIST_HEAD(evtchn_port_list, evtchn_port_info);
>>  =20
>>   struct evtchn_port_info {
>> @@ -183,7 +210,7 @@ struct evtchn_port_info {
>>   };
>>  =20
>>   struct file {
>> -    enum fd_type type;
>> +    unsigned int type;
>>       bool read;	/* maybe available for read */
>>       off_t offset;
>>       union {
>> @@ -199,7 +226,7 @@ struct file {
>>   extern struct file files[];
>>  =20
>>   struct file *get_file_from_fd(int fd);
>> -int alloc_fd(enum fd_type type);
>> +int alloc_fd(unsigned int type);
>>   void close_all_files(void);
>>   extern struct thread *main_thread;
>>   void sparse(unsigned long data, size_t size);
>> diff --git a/lib/sys.c b/lib/sys.c
>> index 323a7cd..c327247 100644
>> --- a/lib/sys.c
>> +++ b/lib/sys.c
>> @@ -98,6 +98,39 @@ struct file files[NOFILE] =3D {
>>       { .type =3D FTYPE_CONSOLE }, /* stderr */
>>   };
>>  =20
>> +static struct file_ops file_ops_none =3D {
>> +    .name =3D "none",
>> +};
>> +
>> +static struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] =3D {
>> +    [FTYPE_NONE] =3D &file_ops_none,
>> +};
>=20
> Both want to be const, because all file_ops ought to live in rodata.

file_ops[] can't be const, it will just point to const data.

>=20
>> +
>> +unsigned int alloc_file_type(struct file_ops *ops)
>> +{
>> +    unsigned int i;
>> +
>> +    pthread_mutex_lock(&fd_lock);
>> +
>> +    for ( i =3D FTYPE_N; i < ARRAY_SIZE(file_ops) && file_ops[i]; i++=
 );
>=20
> No need for a for loop.=C2=A0 Given the mutex, you can safely do someth=
ing
> like this:
>=20
> static unsigned int i =3D FTYPE_N;
>=20
> BUG_ON(i =3D=3D ARRAY_SIZE(file_ops));
> file_ops[i++] =3D ops;

Will change it that way.

>=20
> Alternatively, if you do want to keep the loop, we might want to confir=
m
> that the same ops structure doesn't get registered twice.
>=20
>> +    BUG_ON(i =3D=3D ARRAY_SIZE(file_ops));
>> +    file_ops[i] =3D ops;
>> +
>> +    pthread_mutex_unlock(&fd_lock);
>> +
>> +    printk("New file type \"%s\"(%u) allocated\n", ops->name, i);
>> +
>> +    return i;
>> +}
>> +
>> +static struct file_ops *get_file_ops(unsigned int type)
>> +{
>> +    if ( type >=3D ARRAY_SIZE(file_ops) || !file_ops[type] )
>> +        return &file_ops_none;
>> +
>> +    return file_ops[type];
>> +}
>> +
>>   struct file *get_file_from_fd(int fd)
>>   {
>>       if ( fd < 0 || fd >=3D NOFILE )
>> @@ -108,7 +141,7 @@ struct file *get_file_from_fd(int fd)
>>  =20
>>   DECLARE_WAIT_QUEUE_HEAD(event_queue);
>>  =20
>> -int alloc_fd(enum fd_type type)
>> +int alloc_fd(unsigned int type)
>>   {
>>       int i;
>>       pthread_mutex_lock(&fd_lock);
>> @@ -249,6 +282,11 @@ int isatty(int fd)
>>  =20
>>   int read(int fd, void *buf, size_t nbytes)
>>   {
>> +    struct file_ops *ops =3D get_file_ops(files[fd].type);
>> +
>> +    if ( ops->read )
>> +        return ops->read(fd, buf, nbytes);
>> +
>>       switch (files[fd].type) {
>>           case FTYPE_SAVEFILE:
>>   	case FTYPE_CONSOLE: {
>> @@ -328,6 +366,11 @@ int read(int fd, void *buf, size_t nbytes)
>>  =20
>>   int write(int fd, const void *buf, size_t nbytes)
>>   {
>> +    struct file_ops *ops =3D get_file_ops(files[fd].type);
>> +
>> +    if ( ops->write )
>> +        return ops->write(fd, buf, nbytes);
>> +
>>       switch (files[fd].type) {
>>           case FTYPE_SAVEFILE: {
>>                   int ret =3D 0, tot =3D nbytes;
>> @@ -370,8 +413,45 @@ int write(int fd, const void *buf, size_t nbytes)=

>>       return -1;
>>   }
>>  =20
>> +off_t lseek_default(int fd, off_t offset, int whence)
>> +{
>> +    switch ( whence )
>> +    {
>> +    case SEEK_SET:
>> +        files[fd].offset =3D offset;
>> +        break;
>> +
>> +    case SEEK_CUR:
>> +        files[fd].offset +=3D offset;
>> +        break;
>> +
>> +    case SEEK_END:
>> +    {
>> +        struct stat st;
>> +        int ret;
>> +
>> +        ret =3D fstat(fd, &st);
>> +        if ( ret )
>> +            return -1;
>> +        files[fd].offset =3D st.st_size + offset;
>> +        break;
>> +    }
>> +
>> +    default:
>> +        errno =3D EINVAL;
>> +        return -1;
>> +    }
>> +
>> +    return files[fd].offset;
>> +}
>> +
>>   off_t lseek(int fd, off_t offset, int whence)
>>   {
>> +    struct file_ops *ops =3D get_file_ops(files[fd].type);
>> +
>> +    if ( ops->lseek )
>> +        return ops->lseek(fd, offset, whence);
>> +
>>       switch(files[fd].type) {
>>   #ifdef CONFIG_BLKFRONT
>>          case FTYPE_BLK:
>> @@ -393,28 +473,7 @@ off_t lseek(int fd, off_t offset, int whence)
>>             return (off_t) -1;
>>       }
>>  =20
>> -    switch (whence) {
>> -       case SEEK_SET:
>> -          files[fd].offset =3D offset;
>> -          break;
>> -       case SEEK_CUR:
>> -          files[fd].offset +=3D offset;
>> -          break;
>> -       case SEEK_END:
>> -          {
>> -             struct stat st;
>> -             int ret;
>> -             ret =3D fstat(fd, &st);
>> -             if (ret)
>> -                return -1;
>> -             files[fd].offset =3D st.st_size + offset;
>> -             break;
>> -          }
>> -       default:
>> -          errno =3D EINVAL;
>> -          return -1;
>> -    }
>> -    return files[fd].offset;
>> +    return lseek_default(fd, offset, whence);
>>   }
>>  =20
>>   int fsync(int fd) {
>> @@ -425,8 +484,15 @@ int fsync(int fd) {
>>   int close(int fd)
>>   {
>>       int res =3D 0;
>> +    struct file_ops *ops =3D get_file_ops(files[fd].type);
>>  =20
>>       printk("close(%d)\n", fd);
>> +    if ( ops->close )
>> +    {
>> +        res =3D ops->close(fd);
>> +        goto out;
>> +    }
>> +
>>       switch (files[fd].type) {
>>           default:
>>               break;
>> @@ -497,6 +563,7 @@ int close(int fd)
>>               return -1;
>>       }
>>  =20
>> + out:
>>       memset(files + fd, 0, sizeof(struct file));
>>       files[fd].type =3D FTYPE_NONE;
>>       return res;
>> @@ -521,7 +588,13 @@ int stat(const char *path, struct stat *buf)
>>  =20
>>   int fstat(int fd, struct stat *buf)
>>   {
>> +    struct file_ops *ops =3D get_file_ops(files[fd].type);
>> +
>>       init_stat(buf);
>> +
>> +    if ( ops->fstat )
>> +        return ops->fstat(fd, buf);
>> +
>>       switch (files[fd].type) {
>>   	case FTYPE_SAVEFILE:
>>   	case FTYPE_CONSOLE:
>> @@ -587,6 +660,18 @@ int fcntl(int fd, int cmd, ...)
>>   {
>>       long arg;
>>       va_list ap;
>> +    int res;
>> +    struct file_ops *ops =3D get_file_ops(files[fd].type);
>> +
>> +    if ( ops->fcntl )
>> +    {
>> +        va_start(ap, cmd);
>> +        res =3D ops->fcntl(fd, cmd, ap);
>> +        va_end(ap);
>> +
>> +        return res;
>> +    }
>> +
>>       va_start(ap, cmd);
>>       arg =3D va_arg(ap, long);
>>       va_end(ap);
>> @@ -640,18 +725,29 @@ int closedir(DIR *dir)
>>   /* We assume that only the main thread calls select(). */
>>  =20
>>   #if defined(LIBC_DEBUG) || defined(LIBC_VERBOSE)
>> -static const char file_types[] =3D {
>> -    [FTYPE_NONE]	=3D 'N',
>> -    [FTYPE_CONSOLE]	=3D 'C',
>> -    [FTYPE_XENBUS]	=3D 'S',
>> -    [FTYPE_XC]		=3D 'X',
>> -    [FTYPE_EVTCHN]	=3D 'E',
>> -    [FTYPE_SOCKET]	=3D 's',
>> -    [FTYPE_TAP]		=3D 'T',
>> -    [FTYPE_BLK]		=3D 'B',
>> -    [FTYPE_KBD]		=3D 'K',
>> -    [FTYPE_FB]		=3D 'G',
>> +static const char *file_types[] =3D {
>=20
> static const char *const file_types[]

Okay.

>=20
>> +    [FTYPE_NONE]    =3D "none",
>> +    [FTYPE_CONSOLE] =3D "console",
>> +    [FTYPE_XENBUS]  =3D "xenbus",
>> +    [FTYPE_XC]      =3D "ctrl",
>> +    [FTYPE_EVTCHN]  =3D "evtchn",
>> +    [FTYPE_SOCKET]  =3D "socket",
>> +    [FTYPE_TAP]     =3D "net",
>> +    [FTYPE_BLK]     =3D "blk",
>> +    [FTYPE_KBD]     =3D "kbd",
>> +    [FTYPE_FB]      =3D "fb",
>>   };
>> +
>> +static char *get_type_name(unsigned int type)
>=20
> const.

Okay.

>=20
>> +{
>> +    if ( type < ARRAY_SIZE(file_ops) && file_ops[type] )
>> +        return file_ops[type]->name;
>> +
>> +    if ( type < ARRAY_SIZE(file_types) && file_types[type] )
>> +        return file_types[type];
>> +
>> +    return "none";
>> +}
>>   #endif
>>   #ifdef LIBC_DEBUG
>>   static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd=
_set *exceptfds, struct timeval *timeout)
>> @@ -663,7 +759,7 @@ static void dump_set(int nfds, fd_set *readfds, fd=
_set *writefds, fd_set *except
>>   	if (FD_ISSET(i, set)) { \
>>   	    if (comma) \
>>   		printk(", "); \
>> -	    printk("%d(%c)", i, file_types[files[i].type]); \
>> +	    printk("%d(%s)", i, get_type_name(files[i].type)); \
>>   	    comma =3D 1; \
>>   	} \
>>       } \
>> @@ -697,7 +793,7 @@ static void dump_pollfds(struct pollfd *pfd, int n=
fds, int timeout)
>>           fd =3D pfd[i].fd;
>>           if (comma)
>>               printk(", ");
>> -        printk("%d(%c)/%02x", fd, file_types[files[fd].type],
>> +        printk("%d(%s)/%02x", fd, get_type_name(files[fd].type),
>>               pfd[i].events);
>>               comma =3D 1;
>>       }
>> @@ -709,6 +805,18 @@ static void dump_pollfds(struct pollfd *pfd, int =
nfds, int timeout)
>>   #define dump_pollfds(pfds, nfds, timeout)
>>   #endif
>>  =20
>> +bool select_yes(int fd)
>> +{
>> +    return true;
>> +}
>> +
>> +bool select_read_flag(int fd)
>> +{
>> +    struct file *file =3D get_file_from_fd(fd);
>> +
>> +    return file->read;
>> +}
>=20
> I don't see these getting used, even in a fallback case.

They will be used in later patches.

>=20
>> +
>>   /* Just poll without blocking */
>>   static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, =
fd_set *exceptfds)
>>   {
>> @@ -762,9 +870,35 @@ static int select_poll(int nfds, fd_set *readfds,=
 fd_set *writefds, fd_set *exce
>>       for (i =3D 0; i < nfds; i++) {
>>   	switch(files[i].type) {
>>   	default:
>> +        {
>> +            struct file_ops *ops =3D file_ops[files[i].type];
>> +
>> +            if ( ops )
>> +            {
>> +                if ( FD_ISSET(i, readfds) )
>> +                {
>> +                    if ( ops->select_rd && ops->select_rd(i) )
>> +                        n++;
>> +                    else
>> +                        FD_CLR(i, readfds);
>> +                }
>> +                if ( FD_ISSET(i, writefds) )
>> +                {
>> +                    if ( ops->select_wr && ops->select_wr(i) )
>> +                        n++;
>> +                    else
>> +                        FD_CLR(i, writefds);
>> +                }
>> +	        FD_CLR(i, exceptfds);
>=20
> Hard tab.

Thanks for noting.

>=20
>> +
>> +                break;
>> +            }
>> +
>>   	    if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i=
, exceptfds))
>>   		printk("bogus fd %d in select\n", i);
>>   	    /* Fallthrough.  */
>> +        }
>=20
> Is this fallthrough really appropriate, given the break in the ops case=
?

I think this was meant for the FTYPE_SAVEFILE case. For all other file
types this wouldn't make any sense.

Note that in the other Mini-OS series I'm setting the savefile select
callbacks appropriately.


Juergen

--------------24BCAA1F1F5DE129C8C99AE9
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------24BCAA1F1F5DE129C8C99AE9--

--PLE3ZJvZpi5M3UTKkAGKQjQ8OKjGp7roo--

--1yRxLjG8LI6TWxRXbZOs6dgGzDbd4tlbj
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHehI4FAwAAAAAACgkQsN6d1ii/Ey9k
kgf9Fpa0a8Ku0jrEAASfw4Py+jT/e4/J/ljzJu/lX6OivcZelBK5hSzanxxt+3Pen3fygNKQiscj
AtD4CNBlriFKuGOKlO9lEt2ze+qMCyfkbk3CEg+S8UiXFsFXNe0ypy7nQJ2cyxGvbE+Uj/RNU9DG
3GAR2cyLezlZqjr7N+fH+rzsh0ueJAdvYtUhbNHAPZNvhaMCx83jYYxkj+Ue+VUEIXKKs9FS1pHh
rvi1QD7rrWOH2N8xiSxBsv/ckzw1ETX/cAHGyzi/8zGCYaCDequVrLBqqfDIsduzdgDo0gsvt3g2
dzliOz4U/BNmLA1obkGB45+1S247CLCjs4PEcRe6MQ==
=qZYx
-----END PGP SIGNATURE-----

--1yRxLjG8LI6TWxRXbZOs6dgGzDbd4tlbj--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 07:35:46 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 07:35:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256258.439649 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YAb-0003NO-ET; Wed, 12 Jan 2022 07:35:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256258.439649; Wed, 12 Jan 2022 07:35:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YAb-0003NH-BZ; Wed, 12 Jan 2022 07:35:45 +0000
Received: by outflank-mailman (input) for mailman id 256258;
 Wed, 12 Jan 2022 07:35:43 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7YAZ-000372-NU
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 07:35:43 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 3ebd3003-737a-11ec-81c1-a30af7de8005;
 Wed, 12 Jan 2022 08:35:41 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 9C92C212CC;
 Wed, 12 Jan 2022 07:35:41 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 681FB13B32;
 Wed, 12 Jan 2022 07:35:41 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id UJ8OGM2E3mGxDwAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 07:35:41 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 3ebd3003-737a-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641972941; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=wvdjA7VaGoLVihs21qy5O2GV5iob1mnk5CnH267+aE0=;
	b=LUAkDjnvxtmH7aPG554O1wAzK+PZ/Q0/cdL094cMm3UzSm9r5AWUiHP3eIGf5zjRIytWmu
	zQ/jcgkXvzILijkL49gDOWTDhYlpSG3JbFaCvQp1l/Keae24hrhscVVHD3HEMoGxi36hjB
	D11Gbt+Wvp4GXo/L+ligRAndW4I2Ah8=
Subject: Re: [PATCH v2 16/18] mini-os: reset file type in close() in one place
 only
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-17-jgross@suse.com>
 <d70d8cb3-c34f-23f5-840c-c85a90547924@srcf.net>
From: Juergen Gross <jgross@suse.com>
Message-ID: <ea04bb0d-c1b5-1f0b-9ca9-f21001e42a78@suse.com>
Date: Wed, 12 Jan 2022 08:35:40 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <d70d8cb3-c34f-23f5-840c-c85a90547924@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="F2T7kkXIZYAior80ZmuWsQ8NhZRO1bbHD"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--F2T7kkXIZYAior80ZmuWsQ8NhZRO1bbHD
Content-Type: multipart/mixed; boundary="g4Z3l4Af5WbpM3ZK9FLGa4FaSetRSqegM";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <ea04bb0d-c1b5-1f0b-9ca9-f21001e42a78@suse.com>
Subject: Re: [PATCH v2 16/18] mini-os: reset file type in close() in one place
 only
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-17-jgross@suse.com>
 <d70d8cb3-c34f-23f5-840c-c85a90547924@srcf.net>
In-Reply-To: <d70d8cb3-c34f-23f5-840c-c85a90547924@srcf.net>

--g4Z3l4Af5WbpM3ZK9FLGa4FaSetRSqegM
Content-Type: multipart/mixed;
 boundary="------------5674B16F21DF3BC61C9CC0AC"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------5674B16F21DF3BC61C9CC0AC
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 11.01.22 19:11, Andrew Cooper wrote:
> On 11/01/2022 14:58, Juergen Gross wrote:
>> diff --git a/lib/sys.c b/lib/sys.c
>> index 0e6fe5d..323a7cd 100644
>> --- a/lib/sys.c
>> +++ b/lib/sys.c
>> @@ -424,87 +424,82 @@ int fsync(int fd) {
>>  =20
>>   int close(int fd)
>>   {
>> +    int res =3D 0;
>> +
>>       printk("close(%d)\n", fd);
>>       switch (files[fd].type) {
>>           default:
>> -	    files[fd].type =3D FTYPE_NONE;
>> -	    return 0;
>> +            break;
>>   #ifdef CONFIG_XENBUS
>>   	case FTYPE_XENBUS:
>>               xs_daemon_close((void*)(intptr_t) fd);
>> -            return 0;
>> +            break;
>>   #endif
>>   #ifdef HAVE_LWIP
>> -	case FTYPE_SOCKET: {
>> -	    int res =3D lwip_close(files[fd].fd);
>> -	    files[fd].type =3D FTYPE_NONE;
>> -	    return res;
>> -	}
>> +	case FTYPE_SOCKET:
>> +	    res =3D lwip_close(files[fd].fd);
>=20
> Hard tabs.
>=20
>> +            break;
>>   #endif
>>   #ifdef CONFIG_LIBXENCTRL
>>   	case FTYPE_XC:
>>   	    minios_interface_close_fd(fd);
>> -	    return 0;
>> +            break;
>>   #endif
>>   #ifdef CONFIG_LIBXENEVTCHN
>>   	case FTYPE_EVTCHN:
>>   	    minios_evtchn_close_fd(fd);
>> -            return 0;
>> +            break;
>>   #endif
>>   #ifdef CONFIG_LIBXENGNTTAB
>>   	case FTYPE_GNTMAP:
>>   	    minios_gnttab_close_fd(fd);
>> -	    return 0;
>> +            break;
>>   #endif
>>   #ifdef CONFIG_NETFRONT
>>   	case FTYPE_TAP:
>>   	    shutdown_netfront(files[fd].dev);
>> -	    files[fd].type =3D FTYPE_NONE;
>> -	    return 0;
>> +            break;
>>   #endif
>>   #ifdef CONFIG_BLKFRONT
>>   	case FTYPE_BLK:
>>               shutdown_blkfront(files[fd].dev);
>> -	    files[fd].type =3D FTYPE_NONE;
>> -	    return 0;
>> +            break;
>>   #endif
>>   #ifdef CONFIG_TPMFRONT
>>   	case FTYPE_TPMFRONT:
>>               shutdown_tpmfront(files[fd].dev);
>> -	    files[fd].type =3D FTYPE_NONE;
>> -	    return 0;
>> +            break;
>>   #endif
>>   #ifdef CONFIG_TPM_TIS
>>   	case FTYPE_TPM_TIS:
>>               shutdown_tpm_tis(files[fd].dev);
>> -	    files[fd].type =3D FTYPE_NONE;
>> -	    return 0;
>> +            break;
>>   #endif
>>   #ifdef CONFIG_KBDFRONT
>>   	case FTYPE_KBD:
>>               shutdown_kbdfront(files[fd].dev);
>> -            files[fd].type =3D FTYPE_NONE;
>> -            return 0;
>> +            break;
>>   #endif
>>   #ifdef CONFIG_FBFRONT
>>   	case FTYPE_FB:
>>               shutdown_fbfront(files[fd].dev);
>> -            files[fd].type =3D FTYPE_NONE;
>> -            return 0;
>> +            break;
>>   #endif
>>   #ifdef CONFIG_CONSFRONT
>>           case FTYPE_SAVEFILE:
>>           case FTYPE_CONSOLE:
>>               fini_consfront(files[fd].dev);
>> -            files[fd].type =3D FTYPE_NONE;
>> -            return 0;
>> +            break;
>>   #endif
>>   	case FTYPE_NONE:
>> -	    break;
>> +            printk("close(%d): Bad descriptor\n", fd);
>> +            errno =3D EBADF;
>> +            return -1;
>>       }
>> -    printk("close(%d): Bad descriptor\n", fd);
>> -    errno =3D EBADF;
>> -    return -1;
>> +
>> +    memset(files + fd, 0, sizeof(struct file));
>> +    files[fd].type =3D FTYPE_NONE;
>=20
> BUILD_BUG_ON(FTYPE_NONE !=3D 0);
>=20
> Life's too short to deal with a theoretical (and short sighted) future
> where someone might want to change FTYPE_NONE away from being 0.

Good idea.


Juergen

--------------5674B16F21DF3BC61C9CC0AC
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------5674B16F21DF3BC61C9CC0AC--

--g4Z3l4Af5WbpM3ZK9FLGa4FaSetRSqegM--

--F2T7kkXIZYAior80ZmuWsQ8NhZRO1bbHD
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHehMwFAwAAAAAACgkQsN6d1ii/Ey8h
Bgf/Ss+8SmJfO6FZSEc0g9F5GYPIHhSExeO3ZiC7S0bIMUNlWO/O5VhaeFilRJ+MwAaoupohzgua
Rkfz3/BY2JymF30v8D46rRNlY66g8XPkMbE5wn2ENF5ytlkgoyHn4w+5poegEzxI4RQlXO0WSzV1
qvz3cWQu8d7KjZJQimLgwCFOR/y0HlkhxwZ3xI837cl976s+3J9o18z4rFrmmJUPYvvuchWQI67/
GzqzXsm9BO1atQ10N2TFGR5chJ8Q/xXouQ7TwBvgjqRiKuECcq7tGoLRwStJRkThsVQx2Nny0Y87
asG9do+agnWG8QrcMj3tRWwe6p0C2q38fBDKykYLnw==
=dgfG
-----END PGP SIGNATURE-----

--F2T7kkXIZYAior80ZmuWsQ8NhZRO1bbHD--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 07:36:20 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 07:36:20 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256265.439671 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YB9-0004Jg-V7; Wed, 12 Jan 2022 07:36:19 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256265.439671; Wed, 12 Jan 2022 07:36:19 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YB9-0004JZ-RK; Wed, 12 Jan 2022 07:36:19 +0000
Received: by outflank-mailman (input) for mailman id 256265;
 Wed, 12 Jan 2022 07:36:18 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7YB8-000372-2p
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 07:36:18 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 53f04cee-737a-11ec-81c1-a30af7de8005;
 Wed, 12 Jan 2022 08:36:17 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 33762212CC;
 Wed, 12 Jan 2022 07:36:17 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0FB4413B32;
 Wed, 12 Jan 2022 07:36:17 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 4wylAvGE3mHmDwAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 07:36:17 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 53f04cee-737a-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641972977; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=ulXMt8x7Uwbak5tjeuvflHEVHVFWHqwTlNORuYJXtAA=;
	b=qI9hoXUUaL6D3P0cS2usHBEhu0DQYDJBDYfqQBZA6C9+MsZDWHsCwQ1itftVtuYcpFNWZL
	fRxNL50jXLjrEGL/FeCSi+54BFWt05ZRFoR0YG+8SdlccLzZ3eC2zVBWE1zAwOgvYEf1a9
	vAy8slt63VvX/L0xtZ2/gdMOV2CQvOA=
Subject: Re: [PATCH v2 15/18] mini-os: introduce get_file_from_fd()
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-16-jgross@suse.com>
 <3bfba2a9-7951-3234-86c8-3be116c640b6@srcf.net>
From: Juergen Gross <jgross@suse.com>
Message-ID: <eabbbdc3-f705-fef6-11b6-55f4b64b3160@suse.com>
Date: Wed, 12 Jan 2022 08:36:16 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <3bfba2a9-7951-3234-86c8-3be116c640b6@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="il78nH3fPeBZscCwsGPUCLmhVOckZ93iE"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--il78nH3fPeBZscCwsGPUCLmhVOckZ93iE
Content-Type: multipart/mixed; boundary="OhrgsaZxtdZVX7bsf5urRlF8S4AbWLADQ";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <eabbbdc3-f705-fef6-11b6-55f4b64b3160@suse.com>
Subject: Re: [PATCH v2 15/18] mini-os: introduce get_file_from_fd()
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-16-jgross@suse.com>
 <3bfba2a9-7951-3234-86c8-3be116c640b6@srcf.net>
In-Reply-To: <3bfba2a9-7951-3234-86c8-3be116c640b6@srcf.net>

--OhrgsaZxtdZVX7bsf5urRlF8S4AbWLADQ
Content-Type: multipart/mixed;
 boundary="------------2451132C3111B4069AC52F7B"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------2451132C3111B4069AC52F7B
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 11.01.22 19:17, Andrew Cooper wrote:
> On 11/01/2022 14:58, Juergen Gross wrote:
>> diff --git a/lib/sys.c b/lib/sys.c
>> index 6f2b026..0e6fe5d 100644
>> --- a/lib/sys.c
>> +++ b/lib/sys.c
>> @@ -98,6 +98,14 @@ struct file files[NOFILE] =3D {
>>       { .type =3D FTYPE_CONSOLE }, /* stderr */
>>   };
>>  =20
>> +struct file *get_file_from_fd(int fd)
>> +{
>> +    if ( fd < 0 || fd >=3D NOFILE )
>=20
> fd >=3D ARRAY_SIZE(files)=C2=A0 ?
>=20
> Generates slightly safer code in the event that `struct file
> files[NOFILE]` gets refactored.

Fine with me.


Juergen

--------------2451132C3111B4069AC52F7B
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------2451132C3111B4069AC52F7B--

--OhrgsaZxtdZVX7bsf5urRlF8S4AbWLADQ--

--il78nH3fPeBZscCwsGPUCLmhVOckZ93iE
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHehPAFAwAAAAAACgkQsN6d1ii/Ey/t
Hwf/QnmIuL+t0zZ3120Zvwe8eMKw9UhuEcfZX9I5I0CfgBZkT1dGvHP6FtMJNO+AdB8pMJAzvVFb
U+bU9lDEK/UqGA8beOBUEYUBlAlhmOi6Qs5TZkngRiV+X0C4DJs8cE533g+/QSXpcvY+UTgjbBuP
sTvmd2c6blfrM1lEvXgfomJnXlr8xlFLCJxXp+cgO/2zK/mFqz89hzbOZL5A8VnCtJNkZ4av0yA4
82WuAz77NDdgYO7rZMcZGLAic/XYIMgMBEewMANkOaQdHQNzE2ZgoTg6Og/Kl9Qk2GM1AeZOOz+L
Pc5FSNLILlZffjIpkuhaHWzfrG6gqnN+y0Db3MA7qQ==
=gur3
-----END PGP SIGNATURE-----

--il78nH3fPeBZscCwsGPUCLmhVOckZ93iE--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 07:37:13 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 07:37:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256280.439687 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YC1-0005LK-Bx; Wed, 12 Jan 2022 07:37:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256280.439687; Wed, 12 Jan 2022 07:37:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YC1-0005LD-8p; Wed, 12 Jan 2022 07:37:13 +0000
Received: by outflank-mailman (input) for mailman id 256280;
 Wed, 12 Jan 2022 07:37:12 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7YC0-0005Ks-5j
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 07:37:12 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 7407e7d4-737a-11ec-81c1-a30af7de8005;
 Wed, 12 Jan 2022 08:37:11 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 0CD6F1F3BB;
 Wed, 12 Jan 2022 07:37:11 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CB0E413B32;
 Wed, 12 Jan 2022 07:37:10 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id o8xQMCaF3mE0EAAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 07:37:10 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7407e7d4-737a-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641973031; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=AhGm1iTp4PnvvRVRnI49cIwTFpCdvA8mwMFo4R2iAH8=;
	b=Q8hhdGskyXyAVYBxdnF5drWuQooU8WvROafcG2HBm+FNVAg3ELxsBZMZCa9hFkUYznYHC7
	i+iZNyxLqu0oZFt7tPkz0ufvWghzNbN5XWvDygvKVOv2m5b+4QcakK5enWuTi2AbvVOLfj
	Q8lON1HA4QHEGCvAnFd7bhH9w0mTEeg=
Subject: Re: [PATCH v2 18/18] mini-os: remove file type FTYPE_XC
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-19-jgross@suse.com>
 <b6526d7d-4086-30b3-181a-1a34c44137e3@srcf.net>
From: Juergen Gross <jgross@suse.com>
Message-ID: <317509d0-bd6f-333f-4c29-25bd3b31f764@suse.com>
Date: Wed, 12 Jan 2022 08:37:10 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <b6526d7d-4086-30b3-181a-1a34c44137e3@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="3dw0I1xgDWDoonn4xROTzerOo6GT0Ziyp"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--3dw0I1xgDWDoonn4xROTzerOo6GT0Ziyp
Content-Type: multipart/mixed; boundary="7X9nbhgQzbCGpalpRJ59wWSu2k0u0rNra";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <317509d0-bd6f-333f-4c29-25bd3b31f764@suse.com>
Subject: Re: [PATCH v2 18/18] mini-os: remove file type FTYPE_XC
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-19-jgross@suse.com>
 <b6526d7d-4086-30b3-181a-1a34c44137e3@srcf.net>
In-Reply-To: <b6526d7d-4086-30b3-181a-1a34c44137e3@srcf.net>

--7X9nbhgQzbCGpalpRJ59wWSu2k0u0rNra
Content-Type: multipart/mixed;
 boundary="------------825673C6E0AF38904F885F74"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------825673C6E0AF38904F885F74
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 11.01.22 19:19, Andrew Cooper wrote:
> On 11/01/2022 14:58, Juergen Gross wrote:
>> The only reason for the file type FTYPE_XC has been gone long time
>> ago: it was needed for xc_map_foreign_bulk(), which has been switched
>> to use libxenforeignmemory and doesn't need this special file any
>> more.
>>
>> So remove everything related to FTYPE_XC.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>=20
> You'd have less churn in the series if this came ahead of patch 17.
> There are at least 3 hunks below that you've already converted once, an=
d
> one of those hunks already needs a hard tabs fixup.

Okay.


Juergen

--------------825673C6E0AF38904F885F74
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------825673C6E0AF38904F885F74--

--7X9nbhgQzbCGpalpRJ59wWSu2k0u0rNra--

--3dw0I1xgDWDoonn4xROTzerOo6GT0Ziyp
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHehSYFAwAAAAAACgkQsN6d1ii/Ey+6
HQgAnZ9eZIsER/rKG6rwL7rrQuTTFPlMiucGTYmZsYv6WB+4CX0BYvnVnmr8yRnDtadzWIgPTKSQ
G0g5O3I7zLmxHyGt9/GbELAVorJwxpTpHHIo/iNhh4WrOjhFwU/0/yCX2v6xuX5z/ABhpOKmB/lv
+P8BLxSTY6tePDOsULTDx4LsqEjsSZIx8BhgpiKQ/UNysqlA1wBCQ4AuPhaXSwzuBTUL6rvWYwOr
bP+mClj3tE9bFluPf7jEbYwJPNLm2ZjhZky8ncZfW/HMXAe71cEv0E0vKAYtngvZjX3kBenEJsUW
oqK9nktgFJRoRkimcw448A4b+5ICxNpzzSgVjZ3qnw==
=0IGA
-----END PGP SIGNATURE-----

--3dw0I1xgDWDoonn4xROTzerOo6GT0Ziyp--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 07:39:22 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 07:39:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256294.439706 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YE6-0006K4-D9; Wed, 12 Jan 2022 07:39:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256294.439706; Wed, 12 Jan 2022 07:39:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YE6-0006JR-8J; Wed, 12 Jan 2022 07:39:22 +0000
Received: by outflank-mailman (input) for mailman id 256294;
 Wed, 12 Jan 2022 07:39:21 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7YE5-0006Gh-1g
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 07:39:21 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id c05eaf36-737a-11ec-81c1-a30af7de8005;
 Wed, 12 Jan 2022 08:39:19 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 206F71F3BB;
 Wed, 12 Jan 2022 07:39:19 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DFAFF13B32;
 Wed, 12 Jan 2022 07:39:18 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id Llo2NKaF3mH8EAAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 07:39:18 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: c05eaf36-737a-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641973159; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=cXgN85yjDjoEng8Zh0FXXkam8JMxFoemBgYurn7Uk3o=;
	b=CwyiyZshCl5dCfkfuNwZVNp6LguYyM8hVUdCz8OD4VfD05jU3o51CrPcQ0M+IFJhM68PhJ
	PrhzX7OQfIAthogUVb3W34chYmngBCMMCqoFein0rqvjJYMjVucAoobCBkOLRBMFYLRtv5
	W+rxX8/doNFHVrblwhsL+1MeZea8STg=
Subject: Re: [PATCH v2 16/18] mini-os: reset file type in close() in one place
 only
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-17-jgross@suse.com>
 <e4956df7-d7ca-cb5f-0f0e-7f3eba5d1a50@srcf.net>
From: Juergen Gross <jgross@suse.com>
Message-ID: <dc654411-824c-4b88-1f9a-bb418c24f174@suse.com>
Date: Wed, 12 Jan 2022 08:39:18 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <e4956df7-d7ca-cb5f-0f0e-7f3eba5d1a50@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="dDWfXdCtDRarrdxRMw92aTNO7tuwzdDiJ"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--dDWfXdCtDRarrdxRMw92aTNO7tuwzdDiJ
Content-Type: multipart/mixed; boundary="O5h4rbKKvF32fnnLYMuRduY9xpSE4ALHg";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <dc654411-824c-4b88-1f9a-bb418c24f174@suse.com>
Subject: Re: [PATCH v2 16/18] mini-os: reset file type in close() in one place
 only
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-17-jgross@suse.com>
 <e4956df7-d7ca-cb5f-0f0e-7f3eba5d1a50@srcf.net>
In-Reply-To: <e4956df7-d7ca-cb5f-0f0e-7f3eba5d1a50@srcf.net>

--O5h4rbKKvF32fnnLYMuRduY9xpSE4ALHg
Content-Type: multipart/mixed;
 boundary="------------AEDA13017DDAE3689B2AB865"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------AEDA13017DDAE3689B2AB865
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 11.01.22 20:14, Andrew Cooper wrote:
> On 11/01/2022 14:58, Juergen Gross wrote:
>> diff --git a/lib/sys.c b/lib/sys.c
>> index 0e6fe5d..323a7cd 100644
>> --- a/lib/sys.c
>> +++ b/lib/sys.c
>> @@ -424,87 +424,82 @@ int fsync(int fd) {
>>  =20
>>   int close(int fd)
>>   {
>> +    int res =3D 0;
>> +
>>       printk("close(%d)\n", fd);
>>       switch (files[fd].type) {
>=20
> I know this bug is pre-existing, but the libc close() really ought to
> sanity check fd before blindly indexing files[] with it.
>=20
> I'd tentatively suggest that you want one extra goto from here, into
> wherever the EBADF logic ends up, and it's probably worth including in
> this patch.

Will do that.


Juergen

--------------AEDA13017DDAE3689B2AB865
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------AEDA13017DDAE3689B2AB865--

--O5h4rbKKvF32fnnLYMuRduY9xpSE4ALHg--

--dDWfXdCtDRarrdxRMw92aTNO7tuwzdDiJ
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHehaYFAwAAAAAACgkQsN6d1ii/Ey+9
cAgAmomz8Wrjncjsq347VgrGRh9FaKpkkBM5KM3cOhDoLRIcywuGj1JhX9Nmx97+JfA3e0C2btFq
FKf78QGliFeSEaZG3z06g/ZoP/rm4rhmwrAVwdlcA88g6NqAplMwS0+6PO2fllYHEMrrA1+ghlzc
Qcay7Mbfp7nZovsfArhGVsPT6gpzWgdJEIvlPY/u6ifo8gFJFa+Sjs0mO1Zndso3XKzbYZY3enrR
mXe7RJD2E0UA/2pi739BMSghoJ9tLxGf8vrDpVZB6SAWD4XeZuxpA/zr+QDE9PcvtI99IgTCHsrr
QVqTJJ2dbTteqn2VyVNIep4fvlnafFu+abTDfOcCJg==
=EjON
-----END PGP SIGNATURE-----

--dDWfXdCtDRarrdxRMw92aTNO7tuwzdDiJ--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 07:40:29 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 07:40:29 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256299.439716 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YFA-0007gC-Fd; Wed, 12 Jan 2022 07:40:28 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256299.439716; Wed, 12 Jan 2022 07:40:28 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YFA-0007g5-CY; Wed, 12 Jan 2022 07:40:28 +0000
Received: by outflank-mailman (input) for mailman id 256299;
 Wed, 12 Jan 2022 07:40:27 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7YF8-0007fl-W0
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 07:40:26 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e817d1c4-737a-11ec-81c1-a30af7de8005;
 Wed, 12 Jan 2022 08:40:26 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id A8BDB212CC;
 Wed, 12 Jan 2022 07:40:25 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7AD0013B32;
 Wed, 12 Jan 2022 07:40:25 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id KlBlHOmF3mGpEQAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 07:40:25 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e817d1c4-737a-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641973225; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=cwYESox3BauhwWxUxfezZENxaOMczJo28EhkGWYVvbM=;
	b=erTftiXvNtDrlAFzmeJy56K2ksTN2xwTl/lTGtDizUG86wJpsJcOt+rVudjBjxvIjeKRQf
	YlYTcqZDNEsHA84aJWQ+n3AecWRrL3PQ2tBOP+2lMimU+8B8WmbYJGsk4CSzvNm5jqDZJ7
	iux4shhjWLxp/sl6O4ALJd5oOqQNWLo=
Subject: Re: [PATCH v2 00/18] mini-os: remove struct file dependency on config
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <da22a929-0226-c3e5-2c04-92b412613219@srcf.net>
From: Juergen Gross <jgross@suse.com>
Message-ID: <857627d8-2b06-7c44-5dc7-ceb80042f1d2@suse.com>
Date: Wed, 12 Jan 2022 08:40:24 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <da22a929-0226-c3e5-2c04-92b412613219@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="fpb3LSdG6SfWGRit2GgvT489RMhyDgViM"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--fpb3LSdG6SfWGRit2GgvT489RMhyDgViM
Content-Type: multipart/mixed; boundary="I0qGaXaJNaXua9S3wZpkzgVDCoJBu7iu1";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <857627d8-2b06-7c44-5dc7-ceb80042f1d2@suse.com>
Subject: Re: [PATCH v2 00/18] mini-os: remove struct file dependency on config
References: <20220111145817.22170-1-jgross@suse.com>
 <da22a929-0226-c3e5-2c04-92b412613219@srcf.net>
In-Reply-To: <da22a929-0226-c3e5-2c04-92b412613219@srcf.net>

--I0qGaXaJNaXua9S3wZpkzgVDCoJBu7iu1
Content-Type: multipart/mixed;
 boundary="------------6BEA4F9CF6D5DCD00C40A89B"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------6BEA4F9CF6D5DCD00C40A89B
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 11.01.22 20:42, Andrew Cooper wrote:
> On 11/01/2022 14:57, Juergen Gross wrote:
>> Today the layout of struct file is depending on the Mini-OS
>> configuration. This is especially bad as the layout is exported to
>> external users like the Xen libraries built for Mini-OS, and those
>> are being built only once for multiple stubdom configurations.
>>
>> Today there is no direct problem resulting from this, as the main
>> difference between struct file layouts is a large union containing all=

>> the device specific data for the different file types. The largest
>> union member is not configuration dependant, so the build is currently=

>> not broken.
>>
>> In order to avoid any future problems this patch series is eliminating=

>> the configuration dependency by replacing most of the device specific
>> union members by a single pointer.
>>
>> The two union members used by Xen libraries can't be replaced yet, as
>> those need to be switched to use the generic pointer first.
>>
>> In order to hide the Mini-OS internal implementation of the files
>> array, patches 15-17 are introducing a common framework to access a
>> struct file via its file descriptor, and to allocate new file types
>> dynamically instead of having them all pre-defined. The file type
>> specific operations are supplied via a function vector in order to
>> remove the dependency of lib/sys.c on all the various file types.
>=20
> Patches 1 thru 15 seem fine and ready to go.=C2=A0 Would it help to get=
 those
> committed now?

With the one remark you had for patch 15 I think patches 1-14 could go
in now.


Juergen

--------------6BEA4F9CF6D5DCD00C40A89B
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------6BEA4F9CF6D5DCD00C40A89B--

--I0qGaXaJNaXua9S3wZpkzgVDCoJBu7iu1--

--fpb3LSdG6SfWGRit2GgvT489RMhyDgViM
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHehegFAwAAAAAACgkQsN6d1ii/Ey8C
Nwf9HIp/pNUN4EwBpjUa5f4SZ9sInJj6wlzf/aQq9EaaJzSGGlKwWNOxpTy/nSaOY2nIXLz5yE1f
lq/O/hxIm9/XhltXpkF6fAIAy0RTYW2N2bJIBUQEX8XsAc3c6MN/nf6KPFmc764brfKCGatrF5oU
RQdnUX9Xf7G2wmotVDrryLQhQI3jLQyN7tRpUPn8zOYWOZJMr2zmyNCvAbOzWS74oe+FLmvo3F/t
mVIAB6+YlgS5DuFO0FND/KY//AusQYEKAIt++2OVCeCGFbuxoElsG0N13DIJD9IVl/jsfu2tP8g3
gZU7xCJl1iRrMbjhSbWmW02zPYU8i77lAvZ8IvbHRA==
=DorM
-----END PGP SIGNATURE-----

--fpb3LSdG6SfWGRit2GgvT489RMhyDgViM--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 07:42:30 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 07:42:30 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256306.439743 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YH8-0000CU-3k; Wed, 12 Jan 2022 07:42:30 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256306.439743; Wed, 12 Jan 2022 07:42:30 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YH8-0000CH-0o; Wed, 12 Jan 2022 07:42:30 +0000
Received: by outflank-mailman (input) for mailman id 256306;
 Wed, 12 Jan 2022 07:42:28 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7YH6-0008NM-N5
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 07:42:28 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 303603ae-737b-11ec-9ce5-af14b9085ebd;
 Wed, 12 Jan 2022 08:42:27 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id C9FCE212CC;
 Wed, 12 Jan 2022 07:42:26 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A4E3013B32;
 Wed, 12 Jan 2022 07:42:26 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id pitDJmKG3mFkEgAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 07:42:26 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 303603ae-737b-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641973346; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=Lhwzt5otckl7vDkGGOoFlqrpCYe20IaC4ib5lp9e118=;
	b=NI3B51pdp4/isiYBo7JQQKD1KMiJELK9nHoKYHEJLLDCdZRkM6wfz31IfPpvCJ5Nr19ZKW
	B8qkGg9WMb2ctymt0SR2OSIQXl0VAh1oXtyacmlAXZY5sEV3A2MmiiWSH+xxo8ngCdX/gF
	Wygx3N5Ssd9PigYDQWbhOUVUJQNmAao=
Subject: Re: [PATCH v2 17/18] mini-os: use function vectors instead of switch
 for file operations
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-18-jgross@suse.com>
 <20220111200547.wb6mwl6zxtf3y54c@begin>
From: Juergen Gross <jgross@suse.com>
Message-ID: <e93051ed-dfc2-bae3-270d-1850f8fd9074@suse.com>
Date: Wed, 12 Jan 2022 08:42:26 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <20220111200547.wb6mwl6zxtf3y54c@begin>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="A6o6NmLF78wDvfSiwCfuJLov5Bhz2WBjE"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--A6o6NmLF78wDvfSiwCfuJLov5Bhz2WBjE
Content-Type: multipart/mixed; boundary="5cUy2A9YAcfi6KNPlgKAXodywIt6IOPMH";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org
Message-ID: <e93051ed-dfc2-bae3-270d-1850f8fd9074@suse.com>
Subject: Re: [PATCH v2 17/18] mini-os: use function vectors instead of switch
 for file operations
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-18-jgross@suse.com>
 <20220111200547.wb6mwl6zxtf3y54c@begin>
In-Reply-To: <20220111200547.wb6mwl6zxtf3y54c@begin>

--5cUy2A9YAcfi6KNPlgKAXodywIt6IOPMH
Content-Type: multipart/mixed;
 boundary="------------D505CF4405CA2D2A91045E4E"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------D505CF4405CA2D2A91045E4E
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 11.01.22 21:05, Samuel Thibault wrote:
> Juergen Gross, le mar. 11 janv. 2022 15:58:16 +0100, a ecrit:
>> @@ -370,8 +413,45 @@ int write(int fd, const void *buf, size_t nbytes)=

>>       return -1;
>>   }
>>  =20
>> +off_t lseek_default(int fd, off_t offset, int whence)
>> +{
>> +    switch ( whence )
>> +    {
>=20
> Is there a reason for making this one a separate function, unlike other=
s
> for which you kept the code in the main function?

Yes, it will be used as .lseek callback in some cases.


Juergen

--------------D505CF4405CA2D2A91045E4E
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------D505CF4405CA2D2A91045E4E--

--5cUy2A9YAcfi6KNPlgKAXodywIt6IOPMH--

--A6o6NmLF78wDvfSiwCfuJLov5Bhz2WBjE
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHehmIFAwAAAAAACgkQsN6d1ii/Ey9j
Bgf9HqL5KpUDdAgFypD0ya7nkXH9w4WqGm7iVRQobSKpm1K3gCRhv/VDaqq6klUN4tlvNlZoeBap
1w73rPWXOUB4gYq1KnuTkgfnaC7X1B2Ryf2HbWmYgRnpmnVLt0BfkfMEyFVDDRnh7mww+ZhBBkK4
5uo9aQbpPm6Q+neMir3bWc4eBdFSelqMOz6QAeAoabpGapWVTkCI1qmQbXVzbvRRvXgxwNE1jweN
f8HFcEZNQi7+ChawfcFmTRW4hMEAiE0D+geYhlmnVllbOCcKOYUdqMF9nL5fwbRdOgNRN2Av0yov
WzXoWk526ZO7S1xUJENCxRoIr+wqQbQ1nLS9bCTGlw==
=ZkMQ
-----END PGP SIGNATURE-----

--A6o6NmLF78wDvfSiwCfuJLov5Bhz2WBjE--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 07:44:23 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 07:44:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256314.439757 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YIw-0001FB-N6; Wed, 12 Jan 2022 07:44:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256314.439757; Wed, 12 Jan 2022 07:44:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YIw-0001F4-K9; Wed, 12 Jan 2022 07:44:22 +0000
Received: by outflank-mailman (input) for mailman id 256314;
 Wed, 12 Jan 2022 07:44:20 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7YIu-0001Ep-Rk
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 07:44:20 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 739110f4-737b-11ec-81c1-a30af7de8005;
 Wed, 12 Jan 2022 08:44:20 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id BB6F8212CC;
 Wed, 12 Jan 2022 07:44:19 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 94FC713B3D;
 Wed, 12 Jan 2022 07:44:19 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id hawzI9OG3mE0EwAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 07:44:19 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 739110f4-737b-11ec-81c1-a30af7de8005
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641973459; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=vOuyP8e33SO4XXRgY7JbdG0G60n/VslLgbJIHFM8vQM=;
	b=hxt94QoujoIWIOKiCdzobS6YvWsZLsp/S3Jo27NLYFk9WwJG/iaPhc1vHIPcb0gmUF0M76
	iDTRk7F0HlWzG56wl0C8nwVdiN3baG8y9fb4jqb6Hhle8e3Mwg0UfHfW3e4yGUT5PONorc
	f0ZTnmJ2X0UKP3V6/4F2R1Ezfl9i5mA=
Subject: Re: [PATCH v2 02/12] mini-os: remove gnttab specific member from
 struct file
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-3-jgross@suse.com>
 <d5ae3033-86c5-c2a4-73f8-6f5a4e1e8d26@srcf.net>
From: Juergen Gross <jgross@suse.com>
Message-ID: <d7fdedb5-adb7-6de1-628e-3b34d3462641@suse.com>
Date: Wed, 12 Jan 2022 08:44:18 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <d5ae3033-86c5-c2a4-73f8-6f5a4e1e8d26@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="PklzcbCj20tiLCYvFzPn4oR2MP5Siimcy"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--PklzcbCj20tiLCYvFzPn4oR2MP5Siimcy
Content-Type: multipart/mixed; boundary="kHqy45pNyVJSePGoM7uk3QApciNmeNuFm";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <d7fdedb5-adb7-6de1-628e-3b34d3462641@suse.com>
Subject: Re: [PATCH v2 02/12] mini-os: remove gnttab specific member from
 struct file
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-3-jgross@suse.com>
 <d5ae3033-86c5-c2a4-73f8-6f5a4e1e8d26@srcf.net>
In-Reply-To: <d5ae3033-86c5-c2a4-73f8-6f5a4e1e8d26@srcf.net>

--kHqy45pNyVJSePGoM7uk3QApciNmeNuFm
Content-Type: multipart/mixed;
 boundary="------------4E935DA7AD3555AE53E622F8"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------4E935DA7AD3555AE53E622F8
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 11.01.22 21:12, Andrew Cooper wrote:
> On 11/01/2022 15:12, Juergen Gross wrote:
>> The event channel specific union member in struct file is no longer
>=20
> Too much copy&paste from the previous patch?

Seems so, yes. :-)


Juergen

--------------4E935DA7AD3555AE53E622F8
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------4E935DA7AD3555AE53E622F8--

--kHqy45pNyVJSePGoM7uk3QApciNmeNuFm--

--PklzcbCj20tiLCYvFzPn4oR2MP5Siimcy
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHehtIFAwAAAAAACgkQsN6d1ii/Ey8G
kwf/embJlXd8gwMhOyBp0ffRq44LAAVoGIvZGkHeciRLjBTvkDy2gbXCwQZ3W6CQfYPgKK9FdZrN
FnTqCd6Ga6gfX5nUlnmOq5gdZEVgV4DVw+dv3GA7zh23lLUjQ95y1UNqmY5TXqEsDW1bLWHAnszc
htNlSxQ7n4Y7jBQDhUKlc+AGGkD2hvzoQOosBI5YF/E2HJBCY0+orCSr8DVYPd0LvFW0yIx7odLW
Ji1vzBTfXMucRYh4EnNvgAs+m6iCyKUHFrSdks9nK7d1Fcqn47eGA7nV9y6ygYcU2PDxrfcwIw2T
kRj2sYA1XpvZ6300OBiLFtOEPVfZzVSeEvIyeVfbHg==
=m1fy
-----END PGP SIGNATURE-----

--PklzcbCj20tiLCYvFzPn4oR2MP5Siimcy--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 07:52:13 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 07:52:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256321.439772 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YQW-0002mY-JW; Wed, 12 Jan 2022 07:52:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256321.439772; Wed, 12 Jan 2022 07:52:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YQW-0002mR-G6; Wed, 12 Jan 2022 07:52:12 +0000
Received: by outflank-mailman (input) for mailman id 256321;
 Wed, 12 Jan 2022 07:52:10 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7YQU-0002mG-AU
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 07:52:10 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 8b4994dc-737c-11ec-9ce5-af14b9085ebd;
 Wed, 12 Jan 2022 08:52:09 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id F2FC721117;
 Wed, 12 Jan 2022 07:52:08 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CDBEA13B2D;
 Wed, 12 Jan 2022 07:52:08 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id jfUJMaiI3mHOFgAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 07:52:08 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 8b4994dc-737c-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641973928; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=hk2t7kPAvY+3dZVTknNcVTsuYNlO1nOhXZN4p3ayKEI=;
	b=IBSbMiTL1patSiAv1lnx4JTHoe4Y5gBeT0tGQ8hbU6gPb46Sydx+WWmilXrTLt06FrDk43
	7EvBl2t0pB/EzgkRf5MYAEAjIqVD1VQMtF3TSReCsSMC5FHiFSyuqullWYIWJgTbFYNy1K
	GZKBzdK9Q6lElcoVekr5XUYPJKiKul8=
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-4-jgross@suse.com>
 <a41f6688-d14a-dad5-1625-1b98f793062e@srcf.net>
From: Juergen Gross <jgross@suse.com>
Subject: Re: [PATCH v2 03/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in xs
Message-ID: <501262b0-510b-3add-35a6-2f2ad7452518@suse.com>
Date: Wed, 12 Jan 2022 08:52:08 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <a41f6688-d14a-dad5-1625-1b98f793062e@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="A1HatdtAPfUZkXEEf8FF0CE6dXteoimh5"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--A1HatdtAPfUZkXEEf8FF0CE6dXteoimh5
Content-Type: multipart/mixed; boundary="iNLDoXZRwGxtj73uUSVYA0Sh38JtZkOCh";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <501262b0-510b-3add-35a6-2f2ad7452518@suse.com>
Subject: Re: [PATCH v2 03/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in xs
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-4-jgross@suse.com>
 <a41f6688-d14a-dad5-1625-1b98f793062e@srcf.net>
In-Reply-To: <a41f6688-d14a-dad5-1625-1b98f793062e@srcf.net>

--iNLDoXZRwGxtj73uUSVYA0Sh38JtZkOCh
Content-Type: multipart/mixed;
 boundary="------------7F36A42CF615C1CF31D88612"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------7F36A42CF615C1CF31D88612
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 11.01.22 21:21, Andrew Cooper wrote:
> On 11/01/2022 15:12, Juergen Gross wrote:
>>   void xs_daemon_close(struct xs_handle *h)
>>   {
>> -    int fd =3D _xs_fileno(h);
>> -    struct xenbus_event *event, *next;
>> -    for (event =3D files[fd].dev; event; event =3D next)
>> -    {
>> -        next =3D event->next;
>> -        free(event);
>> -    }
>> +    close(_xs_fileno(h));
>>   }
>=20
> You've deleted the sole caller of xs_daemon_close() from the main
> close() function.
>=20
> That said, I'm very confused, because nothing in minios declares it.
> The declaration appears to come from xenstore.h, which is clearly
> included unconditionally (when it ought not to be), but libxenstore als=
o
> defines the function too...
I already thought of restructuring this mess.

lib/xs.c is the Mini-OS variant of libxenstore, and as such it shares
quite some code with libxenstore.

So the correct thing to do would be to split libxenstore into a common
part and a posix/Mini-OS part, drop lib/xs.c, and use the library in
Mini-OS instead.

But this should be done in a separate series.


Juergen

--------------7F36A42CF615C1CF31D88612
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------7F36A42CF615C1CF31D88612--

--iNLDoXZRwGxtj73uUSVYA0Sh38JtZkOCh--

--A1HatdtAPfUZkXEEf8FF0CE6dXteoimh5
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHeiKgFAwAAAAAACgkQsN6d1ii/Ey/3
3Af/eV+U2Ic+PhDqt8qqfY9qumxDFU1NzSE9/DOFm4MIeaRaKSSun8+3g4gbQpB5jXZ3NM6UjS9T
31KnNjo3WCOJwBM0XsQj97gh19EnVfcBjYOK1OPVlIIXOZ4qc6VbXFgyFET0msc08HS4PeulYTev
7sWZ0Mk/QsH9V/nNXsMyZCVnCEZshjmCywrCUBn5I9e7qXM/TPEGGNTufnx+lABLbx0e3gu/2vvc
gTGfmgqpmk4lCTIQLlCm1VEDUjrFBWGEQ0DHdQlr8E9grA9/PCRQrij6WjEala0CmCcdVZaLEyh9
rXSFzVXKzP/dReSPROlmvcva9okD/6aAUKzhs8nZKA==
=GjuC
-----END PGP SIGNATURE-----

--A1HatdtAPfUZkXEEf8FF0CE6dXteoimh5--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 07:52:59 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 07:52:59 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256325.439788 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YRH-0003O3-VP; Wed, 12 Jan 2022 07:52:59 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256325.439788; Wed, 12 Jan 2022 07:52:59 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YRH-0003Nw-SM; Wed, 12 Jan 2022 07:52:59 +0000
Received: by outflank-mailman (input) for mailman id 256325;
 Wed, 12 Jan 2022 07:52:59 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7YRG-0003Lf-Rw
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 07:52:58 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id a85277c8-737c-11ec-9ce5-af14b9085ebd;
 Wed, 12 Jan 2022 08:52:58 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id C9B11212FE;
 Wed, 12 Jan 2022 07:52:57 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A86D813B2D;
 Wed, 12 Jan 2022 07:52:57 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id sOvHJ9mI3mElFwAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 07:52:57 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: a85277c8-737c-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641973977; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=NZX6Xd6yu1NNNwZyazJAe/VacMcaoafAoJclWDN8iv4=;
	b=PaXBMHiHyy4ntPGvtleZVqWeg+05BS7nOJPIB9nGKKu2f9N3T+BfE9LYjEU0Si+TCGn/xf
	VvYy/ARo9oiR7Ro2Fzah4WDKjIDj2OJ0B3t+8mz+YRd1J3vmGp6+Ui+9foSttB17PLn56+
	llWz0t3zFA+ZKaxYlhahI7sAVo5orRA=
Subject: Re: [PATCH v2 08/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in fbfront
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-9-jgross@suse.com>
 <20220111202605.sihxjumqcxbfthxf@begin>
From: Juergen Gross <jgross@suse.com>
Message-ID: <2b789a4a-e1d3-c780-124a-d2447458fbcd@suse.com>
Date: Wed, 12 Jan 2022 08:52:56 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <20220111202605.sihxjumqcxbfthxf@begin>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="rStnHN7CwdG9ixYtULxzrWAtschrgHL6K"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--rStnHN7CwdG9ixYtULxzrWAtschrgHL6K
Content-Type: multipart/mixed; boundary="V4pfDPvid7wiQddkXoxyTqv30zHstiMeo";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org
Message-ID: <2b789a4a-e1d3-c780-124a-d2447458fbcd@suse.com>
Subject: Re: [PATCH v2 08/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in fbfront
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-9-jgross@suse.com>
 <20220111202605.sihxjumqcxbfthxf@begin>
In-Reply-To: <20220111202605.sihxjumqcxbfthxf@begin>

--V4pfDPvid7wiQddkXoxyTqv30zHstiMeo
Content-Type: multipart/mixed;
 boundary="------------F767B1E7B86FFDB804FF459C"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------F767B1E7B86FFDB804FF459C
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 11.01.22 21:26, Samuel Thibault wrote:
> Juergen Gross, le mar. 11 janv. 2022 16:12:11 +0100, a ecrit:
>> +static struct file_ops fb_ops =3D {
>> +    .name =3D ".fb",
>=20
> Why a dot?

I had spare one lying around... ;-)

Thanks for noticing!


Juergen

--------------F767B1E7B86FFDB804FF459C
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------F767B1E7B86FFDB804FF459C--

--V4pfDPvid7wiQddkXoxyTqv30zHstiMeo--

--rStnHN7CwdG9ixYtULxzrWAtschrgHL6K
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHeiNgFAwAAAAAACgkQsN6d1ii/Ey9a
2QgAmOoXhIemkenfuCx2REmN+i6S97/Z7Q1ZnFZAO3AMQT9ehlMpwSn2KQXsXWs9UZiZCb4v1vP6
4oHGNSHZQAPS/JYDDGthopPF5QlKljXb4qRypNcfzk4aSrGPTVzu+MlfpNle7rDcPHLV2UitAwf8
A2bgILSES6p1WHs6/I0QMdVHG6hAZKWmaAZHu21h4/+rF7tDZdYf4TA+n1/ue4awLo6foauQJAq6
KEJKZaCyI1bbZoJNs/LqnHr/EHOMpRqRTO2KoMoFBCFMay9JcPCvBIhiR1/UAHo/POqxmbVxz8Yf
8N09aIfq34Z1x8BVJAKmF0vmOEnzLXWM9WAwqc1XLA==
=R2zL
-----END PGP SIGNATURE-----

--rStnHN7CwdG9ixYtULxzrWAtschrgHL6K--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 07:54:50 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 07:54:50 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256331.439803 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YT2-00045z-Do; Wed, 12 Jan 2022 07:54:48 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256331.439803; Wed, 12 Jan 2022 07:54:48 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YT2-00045s-AU; Wed, 12 Jan 2022 07:54:48 +0000
Received: by outflank-mailman (input) for mailman id 256331;
 Wed, 12 Jan 2022 07:54:47 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7YT0-00045Y-Sh
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 07:54:47 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id e85964f5-737c-11ec-9ce5-af14b9085ebd;
 Wed, 12 Jan 2022 08:54:45 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 3EAE01F3BB;
 Wed, 12 Jan 2022 07:54:45 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0FED613B2D;
 Wed, 12 Jan 2022 07:54:45 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id G62NAkWJ3mHyFwAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 07:54:45 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e85964f5-737c-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641974085; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=SRiBEagExziOY6AGzH3ykhtfCA+oYAzxbQdZEWcOKgk=;
	b=tQpqo6oaBI0tWjQSbRb6O7yp2JkrNMe4xIIjE2PMD0SLSvrZ6HTD4XPd82AUVNMsYrZyWr
	a+eoevh/XuSETM+HY0xNJFU4qOm1JYplEm/EM6q11/a+sDTn+nkUKtPQFynXP7+93LgeOV
	re8OdX8SU9P0rVrZBClA89qGyKA/JdE=
Subject: Re: [PATCH v2 04/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in tpm_tis
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org,
 Jason Andryuk <jandryuk@gmail.com>,
 Daniel Smith <dpsmith@apertussolutions.com>
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-5-jgross@suse.com>
 <95614df8-c22d-3e1e-b976-84bbed1b30be@srcf.net>
From: Juergen Gross <jgross@suse.com>
Message-ID: <5dba49ab-e901-3ee2-daee-5758eccdd474@suse.com>
Date: Wed, 12 Jan 2022 08:54:44 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <95614df8-c22d-3e1e-b976-84bbed1b30be@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="ZQFXopqQNJMKD1MOjysciLQ1rGKvqhrEl"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--ZQFXopqQNJMKD1MOjysciLQ1rGKvqhrEl
Content-Type: multipart/mixed; boundary="aXhJojt8iFn7yoAcRreqoTKFyybsYvxik";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org,
 Jason Andryuk <jandryuk@gmail.com>,
 Daniel Smith <dpsmith@apertussolutions.com>
Message-ID: <5dba49ab-e901-3ee2-daee-5758eccdd474@suse.com>
Subject: Re: [PATCH v2 04/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in tpm_tis
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-5-jgross@suse.com>
 <95614df8-c22d-3e1e-b976-84bbed1b30be@srcf.net>
In-Reply-To: <95614df8-c22d-3e1e-b976-84bbed1b30be@srcf.net>

--aXhJojt8iFn7yoAcRreqoTKFyybsYvxik
Content-Type: multipart/mixed;
 boundary="------------D1D33A2092A6A1CA84D4F5D7"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------D1D33A2092A6A1CA84D4F5D7
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 11.01.22 21:29, Andrew Cooper wrote:
> On 11/01/2022 15:12, Juergen Gross wrote:
>> diff --git a/tpm_tis.c b/tpm_tis.c
>> index 477f555..abea7a1 100644
>> --- a/tpm_tis.c
>> +++ b/tpm_tis.c
>> @@ -1093,6 +1097,23 @@ ssize_t tpm_getcap(struct tpm_chip *chip, uint3=
2_t subcap_id, cap_t *cap,
>>           return rc;
>>   }
>>  =20
>> +static void shutdown_tpm_tis(struct tpm_chip* tpm){
>=20
> Style, as you're moving it.=C2=A0 Also in the function.
>=20
>> @@ -1360,6 +1369,35 @@ int tpm_tis_posix_fstat(int fd, struct stat* bu=
f)
>>      return 0;
>>   }
>>  =20
>> +static struct file_ops tpm_tis_ops =3D {
>> +    .name =3D "tpm_tis",
>> +    .read =3D tpm_tis_posix_read,
>> +    .write =3D tpm_tis_posix_write,
>> +    .lseek =3D lseek_default,
>> +    .close =3D tpm_tis_close,
>> +    .fstat =3D tpm_tis_posix_fstat,
>> +};
>> +
>> +int tpm_tis_open(struct tpm_chip* tpm)
>=20
> Style.

Ah, yes I should have corrected this while moving the function.

>=20
>> +{
>> +   struct file *file;
>> +   static unsigned int ftype_tis;
>> +
>> +   /* Silently prevent multiple opens */
>> +   if(tpm->fd !=3D -1) {
>> +      return tpm->fd;
>> +   }
>=20
> Another WTF moment.=C2=A0 We silently swallow multiple open()s, but don=
't
> refcout close()s ?
>=20
> This cannot be correct, or sensible, behaviour.
>=20
> Jason/Daniel - thoughts?

I just moved the function, but I can change this, of course.


Juergen

--------------D1D33A2092A6A1CA84D4F5D7
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------D1D33A2092A6A1CA84D4F5D7--

--aXhJojt8iFn7yoAcRreqoTKFyybsYvxik--

--ZQFXopqQNJMKD1MOjysciLQ1rGKvqhrEl
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHeiUQFAwAAAAAACgkQsN6d1ii/Ey/p
oggAnZkFKpvDP7SDKPNwET5ol194uwLJSMsKmC0mTvl5FptiwWTzcVqoRxGv1rOBueTZA2c57JXi
a66vdN/pnUWoGw7byCKt6edGGeasvfwMYjTxgnaThT9KEHU1XUxz9VpcsMqDlQ5+qygMpjOfNEkV
GSBANAcHnYNKQNjSkN64rlEVLtvVEqFkXW7WVgEl1z6AIjd5Tl0xHQ9GCSarilPnBTxBusUxWSrY
pkaaRYpMEJPxMYo/eCBUcdVu5Itwqvjo+38a8NHnuAxRU3AytNx6c3Pm6bTkjXkzWfnaL1nZasXl
Wpc84sF/+SWYIxZ+P92L9IpttH7kyIR1ZedYC0ClpA==
=Oxid
-----END PGP SIGNATURE-----

--ZQFXopqQNJMKD1MOjysciLQ1rGKvqhrEl--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 07:57:13 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 07:57:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256337.439817 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YVM-0004qx-13; Wed, 12 Jan 2022 07:57:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256337.439817; Wed, 12 Jan 2022 07:57:11 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7YVL-0004qq-U6; Wed, 12 Jan 2022 07:57:11 +0000
Received: by outflank-mailman (input) for mailman id 256337;
 Wed, 12 Jan 2022 07:57:10 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7YVK-0004qf-DX
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 07:57:10 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 3e337b6e-737d-11ec-9ce5-af14b9085ebd;
 Wed, 12 Jan 2022 08:57:09 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 23B9C21123;
 Wed, 12 Jan 2022 07:57:09 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 018CF13E10;
 Wed, 12 Jan 2022 07:57:08 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id hm8SOtSJ3mEIGQAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 07:57:08 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 3e337b6e-737d-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641974229; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=DoxsaNjgHsTESg7pJau2nkw4GFuS687AqbBCr4DynRM=;
	b=Z8+yFintsw0+tq8SiWnAVE5FgwH7N9GQuxip/gv64vNwCT7RHrADS/ocRdT5VVYizDr48z
	i/1LC6vNm22HnhGKVt1esEQMvdq2lHS9fzKVqp1zQfbe9wzryPQxe+t2XEYf401AZzAy8W
	oMxiZ1BmWIjmvfSWRm7+wLFcQEzSmPs=
Subject: Re: [PATCH v2 09/12] mini-os: use file_ops and get_file_from_fd() for
 console
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-10-jgross@suse.com>
 <20220111203501.tywfn4czhwavhgrf@begin>
From: Juergen Gross <jgross@suse.com>
Message-ID: <bb7d4313-2500-3e60-8a51-93e909739c90@suse.com>
Date: Wed, 12 Jan 2022 08:57:07 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <20220111203501.tywfn4czhwavhgrf@begin>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="PLvpBkRijSY4uPCJ9lGjFLYi4wXmC9nb6"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--PLvpBkRijSY4uPCJ9lGjFLYi4wXmC9nb6
Content-Type: multipart/mixed; boundary="0W2V7LbSkIGyKqt9FNI0Fx5UhfeFO4NjS";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org, wl@xen.org
Message-ID: <bb7d4313-2500-3e60-8a51-93e909739c90@suse.com>
Subject: Re: [PATCH v2 09/12] mini-os: use file_ops and get_file_from_fd() for
 console
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-10-jgross@suse.com>
 <20220111203501.tywfn4czhwavhgrf@begin>
In-Reply-To: <20220111203501.tywfn4czhwavhgrf@begin>

--0W2V7LbSkIGyKqt9FNI0Fx5UhfeFO4NjS
Content-Type: multipart/mixed;
 boundary="------------3F6770108827E3580B54194D"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------3F6770108827E3580B54194D
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 11.01.22 21:35, Samuel Thibault wrote:
> Juergen Gross, le mar. 11 janv. 2022 16:12:12 +0100, a ecrit:
>> +static int consfront_fstat(int fd, struct stat *buf)
>> +{
>> +    struct file *file =3D get_file_from_fd(fd);
>> +
>> +    buf->st_mode =3D S_IRUSR | S_IWUSR;
>> +    buf->st_mode |=3D (file->type =3D=3D FTYPE_CONSOLE) ? S_IFCHR : S=
_IFREG;
>> +    buf->st_atime =3D buf->st_mtime =3D buf->st_ctime =3D time(NULL);=

>> +
>> +    return 0;
>> +}
>=20
> This seems to be missing filling st_uid, st_gid, etc.?

Not really. Those are set to zero via the call of init_stat()
in fstat().


Juergen

--------------3F6770108827E3580B54194D
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------3F6770108827E3580B54194D--

--0W2V7LbSkIGyKqt9FNI0Fx5UhfeFO4NjS--

--PLvpBkRijSY4uPCJ9lGjFLYi4wXmC9nb6
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHeidMFAwAAAAAACgkQsN6d1ii/Ey8C
Lwf+PYUVsUVFwvyJ8uBpkwccVOCnT/OuRV2iS6p7iaQ0rCUi/4joHE97NCYmE16z6oCiFLECOqLD
ne8ehDaFI2UYK+9OeHX7oCK9a+XKosJwiG7P24RwP2grFiwGGOx96y8cejKMmlrNEsbww4ZWJX4I
avkh9s789Qk6Nci3mQPwvB9f840myFsNfD/Re+WPzA64355nfeRyY01ioGd7MI5rr0u+R4FLq2h3
Yeub6/NqZlePDzwcUTYd5G8JKvwYsTnfiVxHBAbTMvFXE8ENN+iD0pibjALRKaE5bD+rdiQmxlgu
cwPsQi7e3l82RDevt5cCWForkKFIvauWUtrP7+1CnQ==
=2X8o
-----END PGP SIGNATURE-----

--PLvpBkRijSY4uPCJ9lGjFLYi4wXmC9nb6--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 08:22:28 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 08:22:28 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256373.439893 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ytm-0002SO-Q6; Wed, 12 Jan 2022 08:22:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256373.439893; Wed, 12 Jan 2022 08:22:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7Ytm-0002SG-MN; Wed, 12 Jan 2022 08:22:26 +0000
Received: by outflank-mailman (input) for mailman id 256373;
 Wed, 12 Jan 2022 08:22:25 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7Ytk-0002Bn-VP
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 08:22:25 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id c44b9c79-7380-11ec-9ce5-af14b9085ebd;
 Wed, 12 Jan 2022 09:22:23 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id A06F9212FE;
 Wed, 12 Jan 2022 08:22:22 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 72DB713B2D;
 Wed, 12 Jan 2022 08:22:22 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id ++xEGr6P3mG7JwAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 08:22:22 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: c44b9c79-7380-11ec-9ce5-af14b9085ebd
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641975742; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=FKItPEUI7pf6sItCPZzvaufN4aoECeCfTQdu9BEtzxg=;
	b=FhoCGUQFpboG5Ol1sypP9cR5OH0DLxYw06PAde3hwX5rkFpfFDobMYY8yipoWDg5Q3NAOp
	WrD02r6xpUVytltk220gAOf8ZuUSdKS6gYpVeka4zWgmz63m3x2xkZyKpDYkgmEKu2UNYt
	6cXQFVByHS7ox2QUI6GiVmoSd5bvi/Y=
Subject: Re: [PATCH v2 17/18] mini-os: use function vectors instead of switch
 for file operations
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-18-jgross@suse.com>
 <a2d4c905-c477-8553-85a7-90168d914b6e@srcf.net>
 <08672989-53be-1551-f001-0d2c0435b586@suse.com>
 <559223b1-68c1-87fb-7b7b-190f8671b4c2@srcf.net>
From: Juergen Gross <jgross@suse.com>
Message-ID: <d46a971c-d1d3-3b34-a7ed-72993794cff8@suse.com>
Date: Wed, 12 Jan 2022 09:22:21 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <559223b1-68c1-87fb-7b7b-190f8671b4c2@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="W22var4iBcFz7w8czGU65G56eXkO74ClW"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--W22var4iBcFz7w8czGU65G56eXkO74ClW
Content-Type: multipart/mixed; boundary="bBdyGxgh5A6HGnH8u5mhYkpn79SDPVquS";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <d46a971c-d1d3-3b34-a7ed-72993794cff8@suse.com>
Subject: Re: [PATCH v2 17/18] mini-os: use function vectors instead of switch
 for file operations
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-18-jgross@suse.com>
 <a2d4c905-c477-8553-85a7-90168d914b6e@srcf.net>
 <08672989-53be-1551-f001-0d2c0435b586@suse.com>
 <559223b1-68c1-87fb-7b7b-190f8671b4c2@srcf.net>
In-Reply-To: <559223b1-68c1-87fb-7b7b-190f8671b4c2@srcf.net>

--bBdyGxgh5A6HGnH8u5mhYkpn79SDPVquS
Content-Type: multipart/mixed;
 boundary="------------2F50F40C2F1CACFB0E92204E"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------2F50F40C2F1CACFB0E92204E
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 12.01.22 09:19, Andrew Cooper wrote:
> On 12/01/2022 07:34, Juergen Gross wrote:
>> On 11.01.22 19:08, Andrew Cooper wrote:
>>> On 11/01/2022 14:58, Juergen Gross wrote:
>>>> +
>>>> +off_t lseek_default(int fd, off_t offset, int whence);
>>>> +bool select_yes(int fd);
>>>> +bool select_read_flag(int fd);
>>>> +
>>>>  =C2=A0 LIST_HEAD(evtchn_port_list, evtchn_port_info);
>>>>  =C2=A0 =C2=A0 struct evtchn_port_info {
>>>> @@ -183,7 +210,7 @@ struct evtchn_port_info {
>>>>  =C2=A0 };
>>>>  =C2=A0 =C2=A0 struct file {
>>>> -=C2=A0=C2=A0=C2=A0 enum fd_type type;
>>>> +=C2=A0=C2=A0=C2=A0 unsigned int type;
>>>>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bool read;=C2=A0=C2=A0=C2=A0 /* mayb=
e available for read */
>>>>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 off_t offset;
>>>>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 union {
>>>> @@ -199,7 +226,7 @@ struct file {
>>>>  =C2=A0 extern struct file files[];
>>>>  =C2=A0 =C2=A0 struct file *get_file_from_fd(int fd);
>>>> -int alloc_fd(enum fd_type type);
>>>> +int alloc_fd(unsigned int type);
>>>>  =C2=A0 void close_all_files(void);
>>>>  =C2=A0 extern struct thread *main_thread;
>>>>  =C2=A0 void sparse(unsigned long data, size_t size);
>>>> diff --git a/lib/sys.c b/lib/sys.c
>>>> index 323a7cd..c327247 100644
>>>> --- a/lib/sys.c
>>>> +++ b/lib/sys.c
>>>> @@ -98,6 +98,39 @@ struct file files[NOFILE] =3D {
>>>>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { .type =3D FTYPE_CONSOLE }, /* stde=
rr */
>>>>  =C2=A0 };
>>>>  =C2=A0 +static struct file_ops file_ops_none =3D {
>>>> +=C2=A0=C2=A0=C2=A0 .name =3D "none",
>>>> +};
>>>> +
>>>> +static struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] =3D {
>>>> +=C2=A0=C2=A0=C2=A0 [FTYPE_NONE] =3D &file_ops_none,
>>>> +};
>>>
>>> Both want to be const, because all file_ops ought to live in rodata.
>>
>> file_ops[] can't be const, it will just point to const data.
>=20
> Oh, of course.
>=20
>>>> @@ -709,6 +805,18 @@ static void dump_pollfds(struct pollfd *pfd,
>>>> int nfds, int timeout)
>>>>  =C2=A0 #define dump_pollfds(pfds, nfds, timeout)
>>>>  =C2=A0 #endif
>>>>  =C2=A0 +bool select_yes(int fd)
>>>> +{
>>>> +=C2=A0=C2=A0=C2=A0 return true;
>>>> +}
>>>> +
>>>> +bool select_read_flag(int fd)
>>>> +{
>>>> +=C2=A0=C2=A0=C2=A0 struct file *file =3D get_file_from_fd(fd);
>>>> +
>>>> +=C2=A0=C2=A0=C2=A0 return file->read;
>>>> +}
>>>
>>> I don't see these getting used, even in a fallback case.
>>
>> They will be used in later patches.
>=20
> Yeah - I found them in later patches.=C2=A0 It's probably worth a note =
in the
> commit message saying "provide some functions useful for file_ops in
> future patches", particularly as it's actually a later series which
> takes them (due to the ordering constraints).

Okay, will add that note.


Juergen

--------------2F50F40C2F1CACFB0E92204E
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------2F50F40C2F1CACFB0E92204E--

--bBdyGxgh5A6HGnH8u5mhYkpn79SDPVquS--

--W22var4iBcFz7w8czGU65G56eXkO74ClW
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHej70FAwAAAAAACgkQsN6d1ii/Ey9R
bQf+LoVbc17nessp8jx2KgiOsajmotA3/TMu6v7vaiIlxdAsQH3Rx8QkJVp0rBNf6kkKU/K2E2NG
5i2wGnMV/8QSMnps4KRXR7lOp3wXL4mVgJWGuKx2MBMhu8yO3y60yB6UWidUWwL+sk3pyEv+WXrn
5h8r57lTcQEXvUe53EEDHp7XE/eRjdMUEek+r6Pd4lAuCMT6PpciOU7Y23VOIGOZh7mAibilSro9
UNPLl7TWoNxlkQdy9mt2KyObPLJrhbxYwcAQxFe7Er0ZGZ5UDq9vdHoAcZ+wlHRfMbbLr3UY8BnW
N3G4Ok1i+DhKueiTlstH9aCuDdKHt4a3iG9D0tgw7g==
=Y03c
-----END PGP SIGNATURE-----

--W22var4iBcFz7w8czGU65G56eXkO74ClW--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 10:30:17 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 10:30:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256442.440040 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7atT-0005N3-8Q; Wed, 12 Jan 2022 10:30:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256442.440040; Wed, 12 Jan 2022 10:30:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7atT-0005Mw-5E; Wed, 12 Jan 2022 10:30:15 +0000
Received: by outflank-mailman (input) for mailman id 256442;
 Wed, 12 Jan 2022 10:30:14 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=qR4C=R4=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7atS-0005Mq-Bi
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 10:30:14 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 9e581b47-7392-11ec-9c70-5536b2d1e4e1;
 Wed, 12 Jan 2022 11:30:11 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 7492040E;
 Wed, 12 Jan 2022 11:30:09 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id UOZffL4rreGZ; Wed, 12 Jan 2022 11:30:08 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 5669F1A5;
 Wed, 12 Jan 2022 11:30:08 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7atL-00HOFv-Ej;
 Wed, 12 Jan 2022 11:30:07 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 9e581b47-7392-11ec-9c70-5536b2d1e4e1
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Wed, 12 Jan 2022 11:30:07 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 09/12] mini-os: use file_ops and get_file_from_fd()
 for console
Message-ID: <20220112103007.7szlvucbyxfje6r7@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-10-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20220111151215.22955-10-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 7492040E
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 16:12:12 +0100, a ecrit:
> Add struct file_ops for the console related file types (FTYPE_CONSOLE
> and savefile). FTYPE_CONSOLE remains statically defined, as it is used
> to statically init stdin, stdout and stderr.
> 
> Instead of directly accessing the files[] array use get_file_from_fd().
> 
> With CONSOLE now handled via file_ops the bogus file descriptor case in
> select_poll() now needs to be handled more explicit instead of dropping
> into console handling, assuming that this case was basically meant to
> cover SAVEFILE.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

modulo the int fd / file * thing,

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  console/xenbus.c       | 125 +++++++++++++++++++++++++++++++++++++++++
>  console/xencons_ring.c |   6 +-
>  include/console.h      |   5 ++
>  include/lib.h          |   3 +-
>  lib/sys.c              |  87 +++++++---------------------
>  5 files changed, 155 insertions(+), 71 deletions(-)
> 
> diff --git a/console/xenbus.c b/console/xenbus.c
> index 05fc31c..b856c84 100644
> --- a/console/xenbus.c
> +++ b/console/xenbus.c
> @@ -192,3 +192,128 @@ void fini_consfront(struct consfront_dev *dev)
>  {
>      if (dev) free_consfront(dev);
>  }
> +
> +#ifdef HAVE_LIBC
> +static int consfront_read(int fd, void *buf, size_t nbytes)
> +{
> +    int ret;
> +    struct file *file = get_file_from_fd(fd);
> +    DEFINE_WAIT(w);
> +
> +    while ( 1 )
> +    {
> +        add_waiter(w, console_queue);
> +        ret = xencons_ring_recv(file->dev, buf, nbytes);
> +        if ( ret )
> +            break;
> +        schedule();
> +    }
> +
> +    remove_waiter(w, console_queue);
> +
> +    return ret;
> +}
> +
> +static int savefile_write(int fd, const void *buf, size_t nbytes)
> +{
> +    int ret = 0, tot = nbytes;
> +    struct file *file = get_file_from_fd(fd);
> +
> +    while ( nbytes > 0 )
> +    {
> +        ret = xencons_ring_send(file->dev, (char *)buf, nbytes);
> +        nbytes -= ret;
> +        buf = (char *)buf + ret;
> +    }
> +
> +    return tot - nbytes;
> +}
> +
> +static int console_write(int fd, const void *buf, size_t nbytes)
> +{
> +    struct file *file = get_file_from_fd(fd);
> +
> +    console_print(file->dev, (char *)buf, nbytes);
> +
> +    return nbytes;
> +}
> +
> +static int consfront_close_fd(int fd)
> +{
> +    struct file *file = get_file_from_fd(fd);
> +
> +    fini_consfront(file->dev);
> +
> +    return 0;
> +}
> +
> +static int consfront_fstat(int fd, struct stat *buf)
> +{
> +    struct file *file = get_file_from_fd(fd);
> +
> +    buf->st_mode = S_IRUSR | S_IWUSR;
> +    buf->st_mode |= (file->type == FTYPE_CONSOLE) ? S_IFCHR : S_IFREG;
> +    buf->st_atime = buf->st_mtime = buf->st_ctime = time(NULL);
> +
> +    return 0;
> +}
> +
> +static bool consfront_select_rd(int fd)
> +{
> +    struct file *file = get_file_from_fd(fd);
> +
> +    return xencons_ring_avail(file->dev);
> +}
> +
> +static struct file_ops savefile_ops = {
> +    .name = "savefile",
> +    .read = consfront_read,
> +    .write = savefile_write,
> +    .close = consfront_close_fd,
> +    .fstat = consfront_fstat,
> +    .select_rd = consfront_select_rd,
> +    .select_wr = select_yes,
> +};
> +
> +struct file_ops console_ops = {
> +    .name = "console",
> +    .read = consfront_read,
> +    .write = console_write,
> +    .close = consfront_close_fd,
> +    .fstat = consfront_fstat,
> +    .select_rd = consfront_select_rd,
> +    .select_wr = select_yes,
> +};
> +
> +int open_consfront(char *nodename)
> +{
> +    struct consfront_dev *dev;
> +    static unsigned int ftype_savefile;
> +    unsigned int ftype;
> +    struct file *file;
> +
> +    dev = init_consfront(nodename);
> +    if ( !dev )
> +        return -1;
> +
> +    if ( nodename )
> +    {
> +        if ( !ftype_savefile )
> +            ftype_savefile = alloc_file_type(&savefile_ops);
> +        ftype = ftype_savefile;
> +    }
> +    else
> +        ftype = FTYPE_CONSOLE;
> +
> +    dev->fd = alloc_fd(ftype);
> +    file = get_file_from_fd(dev->fd);
> +    if ( !file )
> +    {
> +        fini_consfront(dev);
> +        return -1;
> +    }
> +    file->dev = dev;
> +
> +    return dev->fd;
> +}
> +#endif
> diff --git a/console/xencons_ring.c b/console/xencons_ring.c
> index c348f3c..efedf46 100644
> --- a/console/xencons_ring.c
> +++ b/console/xencons_ring.c
> @@ -99,10 +99,10 @@ void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data)
>  {
>  	struct consfront_dev *dev = (struct consfront_dev *) data;
>  #ifdef HAVE_LIBC
> -        int fd = dev ? dev->fd : -1;
> +        struct file *file = dev ? get_file_from_fd(dev->fd) : NULL;
>  
> -        if (fd != -1)
> -            files[fd].read = true;
> +        if ( file )
> +            file->read = true;
>  
>          wake_up(&console_queue);
>  #else
> diff --git a/include/console.h b/include/console.h
> index 0d7bf07..8c615d0 100644
> --- a/include/console.h
> +++ b/include/console.h
> @@ -39,6 +39,7 @@
>  #include <mini-os/os.h>
>  #include <mini-os/traps.h>
>  #include <mini-os/types.h>
> +#include <mini-os/lib.h>
>  #include <xen/grant_table.h>
>  #include <xenbus.h>
>  #include <xen/io/console.h>
> @@ -93,5 +94,9 @@ int xencons_ring_send_no_notify(struct consfront_dev *dev, const char *data, uns
>  int xencons_ring_avail(struct consfront_dev *dev);
>  int xencons_ring_recv(struct consfront_dev *dev, char *data, unsigned len);
>  void free_consfront(struct consfront_dev *dev);
> +#ifdef HAVE_LIBC
> +extern struct file_ops console_ops;
> +int open_consfront(char *nodename);
> +#endif
>  
>  #endif /* _LIB_CONSOLE_H_ */
> diff --git a/include/lib.h b/include/lib.h
> index 653a16e..c171fe8 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -160,8 +160,7 @@ void sanity_check(void);
>  #define FTYPE_FILE       2
>  #define FTYPE_SOCKET     3
>  #define FTYPE_MEM        4
> -#define FTYPE_SAVEFILE   5
> -#define FTYPE_N          6
> +#define FTYPE_N          5
>  #define FTYPE_SPARE     16
>  
>  typedef int file_read_func(int fd, void *buf, size_t nbytes);
> diff --git a/lib/sys.c b/lib/sys.c
> index 4fb844f..3a8aa68 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -101,6 +101,9 @@ static struct file_ops file_ops_none = {
>  
>  static struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
>      [FTYPE_NONE] = &file_ops_none,
> +#ifdef CONFIG_CONSFRONT
> +    [FTYPE_CONSOLE] = &console_ops,
> +#endif
>  };
>  
>  unsigned int alloc_file_type(struct file_ops *ops)
> @@ -211,31 +214,26 @@ int mkdir(const char *pathname, mode_t mode)
>  #ifdef CONFIG_CONSFRONT
>  int posix_openpt(int flags)
>  {
> -    struct consfront_dev *dev;
> +    int fd;
>  
>      /* Ignore flags */
> +    fd = open_consfront(NULL);
> +    printk("fd(%d) = posix_openpt\n", fd);
>  
> -    dev = init_consfront(NULL);
> -    dev->fd = alloc_fd(FTYPE_CONSOLE);
> -    files[dev->fd].dev = dev;
> -
> -    printk("fd(%d) = posix_openpt\n", dev->fd);
> -    return(dev->fd);
> +    return fd;
>  }
>  
>  int open_savefile(const char *path, int save)
>  {
> -    struct consfront_dev *dev;
> +    int fd;
>      char nodename[64];
>  
>      snprintf(nodename, sizeof(nodename), "device/console/%d", save ? SAVE_CONSOLE : RESTORE_CONSOLE);
>  
> -    dev = init_consfront(nodename);
> -    dev->fd = alloc_fd(FTYPE_SAVEFILE);
> -    files[dev->fd].dev = dev;
> +    fd = open_consfront(nodename);
> +    printk("fd(%d) = open_savefile\n", fd);
>  
> -    printk("fd(%d) = open_savefile\n", dev->fd);
> -    return(dev->fd);
> +    return fd;
>  }
>  #else
>  int posix_openpt(int flags)
> @@ -285,20 +283,6 @@ int read(int fd, void *buf, size_t nbytes)
>          return ops->read(fd, buf, nbytes);
>  
>      switch (files[fd].type) {
> -        case FTYPE_SAVEFILE:
> -	case FTYPE_CONSOLE: {
> -	    int ret;
> -            DEFINE_WAIT(w);
> -            while(1) {
> -                add_waiter(w, console_queue);
> -                ret = xencons_ring_recv(files[fd].dev, buf, nbytes);
> -                if (ret)
> -                    break;
> -                schedule();
> -            }
> -            remove_waiter(w, console_queue);
> -            return ret;
> -        }
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
>  	    return lwip_read(files[fd].fd, buf, nbytes);
> @@ -319,18 +303,6 @@ int write(int fd, const void *buf, size_t nbytes)
>          return ops->write(fd, buf, nbytes);
>  
>      switch (files[fd].type) {
> -        case FTYPE_SAVEFILE: {
> -                int ret = 0, tot = nbytes;
> -                while (nbytes > 0) {
> -                    ret = xencons_ring_send(files[fd].dev, (char *)buf, nbytes);
> -                    nbytes -= ret;
> -                    buf = (char *)buf + ret;
> -                }
> -                return tot - nbytes;
> -            }
> -	case FTYPE_CONSOLE:
> -	    console_print(files[fd].dev, (char *)buf, nbytes);
> -	    return nbytes;
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
>  	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
> @@ -418,12 +390,6 @@ int close(int fd)
>  	case FTYPE_SOCKET:
>  	    res = lwip_close(files[fd].fd);
>              break;
> -#endif
> -#ifdef CONFIG_CONSFRONT
> -        case FTYPE_SAVEFILE:
> -        case FTYPE_CONSOLE:
> -            fini_consfront(files[fd].dev);
> -            break;
>  #endif
>  	case FTYPE_NONE:
>              printk("close(%d): Bad descriptor\n", fd);
> @@ -464,15 +430,8 @@ int fstat(int fd, struct stat *buf)
>          return ops->fstat(fd, buf);
>  
>      switch (files[fd].type) {
> -	case FTYPE_SAVEFILE:
> -	case FTYPE_CONSOLE:
>  	case FTYPE_SOCKET: {
> -            if (files[fd].type == FTYPE_CONSOLE)
> -                buf->st_mode = S_IFCHR|S_IRUSR|S_IWUSR;
> -            else if (files[fd].type == FTYPE_SOCKET)
> -                buf->st_mode = S_IFSOCK|S_IRUSR|S_IWUSR;
> -            else if (files[fd].type == FTYPE_SAVEFILE)
> -                buf->st_mode = S_IFREG|S_IRUSR|S_IWUSR;
> +            buf->st_mode = S_IFSOCK|S_IRUSR|S_IWUSR;
>  	    buf->st_uid = 0;
>  	    buf->st_gid = 0;
>  	    buf->st_size = 0;
> @@ -583,7 +542,6 @@ int closedir(DIR *dir)
>  #if defined(LIBC_DEBUG) || defined(LIBC_VERBOSE)
>  static const char *file_types[] = {
>      [FTYPE_NONE]    = "none",
> -    [FTYPE_CONSOLE] = "console",
>      [FTYPE_SOCKET]  = "socket",
>  };
>  
> @@ -744,21 +702,18 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>              }
>  
>  	    if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
> +            {
>  		printk("bogus fd %d in select\n", i);
> -	    /* Fallthrough.  */
> -        }
> -
> -	case FTYPE_CONSOLE:
> -	    if (FD_ISSET(i, readfds)) {
> -                if (xencons_ring_avail(files[i].dev))
> -		    n++;
> -		else
> -		    FD_CLR(i, readfds);
> +                if ( FD_ISSET(i, readfds) )
> +                    FD_CLR(i, readfds);
> +                if ( FD_ISSET(i, writefds) )
> +                    FD_CLR(i, writefds);
> +                if ( FD_ISSET(i, exceptfds) )
> +                    FD_CLR(i, exceptfds);
>              }
> -	    if (FD_ISSET(i, writefds))
> -                n++;
> -	    FD_CLR(i, exceptfds);
>  	    break;
> +        }
> +
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
>  	    if (FD_ISSET(i, readfds)) {
> -- 
> 2.26.2
> 

-- 
Samuel
<y> t1 faich
<y> les programmes ils segfaultent jamais quand on veut
 -+- #ens-mim en plein débogage -+-


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 10:30:37 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 10:30:37 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256445.440055 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7atp-0005uP-Q4; Wed, 12 Jan 2022 10:30:37 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256445.440055; Wed, 12 Jan 2022 10:30:37 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7atp-0005uH-M1; Wed, 12 Jan 2022 10:30:37 +0000
Received: by outflank-mailman (input) for mailman id 256445;
 Wed, 12 Jan 2022 10:30:35 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=qR4C=R4=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7atn-0005sd-OJ
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 10:30:35 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ac62ea03-7392-11ec-bd6f-bfb69f65cdc7;
 Wed, 12 Jan 2022 11:30:34 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 72F1540E;
 Wed, 12 Jan 2022 11:30:33 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id iOeJ9QxSmz-F; Wed, 12 Jan 2022 11:30:32 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id AA94E1A5;
 Wed, 12 Jan 2022 11:30:32 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7atk-00HPHR-A3;
 Wed, 12 Jan 2022 11:30:32 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ac62ea03-7392-11ec-bd6f-bfb69f65cdc7
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Wed, 12 Jan 2022 11:30:32 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 10/12] mini-os: add struct file_ops for file type
 socket
Message-ID: <20220112103032.y4sgydgj24jjiphl@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-11-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111151215.22955-11-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 72F1540E
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mar. 11 janv. 2022 16:12:13 +0100, a ecrit:
> Even with some special handling needed in select_poll(), add a struct
> file_ops for FTYPE_SOCKET. Due to the need of the special handling it
> isn't possible to use a dynamically allocated file type.
> 
> Most functions calling the file_ops methods can be simplified a lot now
> that no file type specific handling is left. Same applies to the file
> type name printing in debug/verbose mode.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

modulo the int fd / file * thing,

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  lib/sys.c | 153 +++++++++++++++++++++++++-----------------------------
>  1 file changed, 70 insertions(+), 83 deletions(-)
> 
> diff --git a/lib/sys.c b/lib/sys.c
> index 3a8aa68..12deaed 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -99,11 +99,70 @@ static struct file_ops file_ops_none = {
>      .name = "none",
>  };
>  
> +#ifdef HAVE_LWIP
> +static int socket_read(int fd, void *buf, size_t nbytes)
> +{
> +    return lwip_read(fd, buf, nbytes);
> +}
> +
> +static int socket_write(int fd, const void *buf, size_t nbytes)
> +{
> +    return lwip_write(fd, (void *)buf, nbytes);
> +}
> +
> +static int close_socket_fd(int fd)
> +{
> +    struct file *file = get_file_from_fd(fd);
> +
> +    return lwip_close(file->fd);
> +}
> +
> +static int socket_fstat(int fd, struct stat *buf)
> +{
> +    buf->st_mode = S_IFSOCK | S_IRUSR | S_IWUSR;
> +    buf->st_atime = buf->st_mtime = buf->st_ctime = time(NULL);
> +
> +    return 0;
> +}
> +
> +static int socket_fcntl(int fd, int cmd, va_list args)
> +{
> +    long arg;
> +    struct file *file = get_file_from_fd(fd);
> +
> +    arg = va_arg(args, long);
> +
> +    if ( cmd == F_SETFL && !(arg & ~O_NONBLOCK) )
> +    {
> +        /* Only flag supported: non-blocking mode */
> +        uint32_t nblock = !!(arg & O_NONBLOCK);
> +
> +        return lwip_ioctl(file->fd, FIONBIO, &nblock);
> +    }
> +
> +    printk("fcntl(%d, %d, %lx/%lo)\n", fd, cmd, arg, arg);
> +    errno = ENOSYS;
> +    return -1;
> +}
> +
> +static struct file_ops socket_ops = {
> +    .name = "socket",
> +    .read = socket_read,
> +    .write = socket_write,
> +    .close = close_socket_fd,
> +    .fstat = socket_fstat,
> +    .fcntl = socket_fcntl,
> +};
> +#endif
> +
>  static struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
>      [FTYPE_NONE] = &file_ops_none,
>  #ifdef CONFIG_CONSFRONT
>      [FTYPE_CONSOLE] = &console_ops,
>  #endif
> +#ifdef HAVE_LWIP
> +    [FTYPE_SOCKET] = &socket_ops,
> +#endif
>  };
>  
>  unsigned int alloc_file_type(struct file_ops *ops)
> @@ -282,14 +341,6 @@ int read(int fd, void *buf, size_t nbytes)
>      if ( ops->read )
>          return ops->read(fd, buf, nbytes);
>  
> -    switch (files[fd].type) {
> -#ifdef HAVE_LWIP
> -	case FTYPE_SOCKET:
> -	    return lwip_read(files[fd].fd, buf, nbytes);
> -#endif
> -	default:
> -	    break;
> -    }
>      printk("read(%d): Bad descriptor\n", fd);
>      errno = EBADF;
>      return -1;
> @@ -302,14 +353,6 @@ int write(int fd, const void *buf, size_t nbytes)
>      if ( ops->write )
>          return ops->write(fd, buf, nbytes);
>  
> -    switch (files[fd].type) {
> -#ifdef HAVE_LWIP
> -	case FTYPE_SOCKET:
> -	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
> -#endif
> -	default:
> -	    break;
> -    }
>      printk("write(%d): Bad descriptor\n", fd);
>      errno = EBADF;
>      return -1;
> @@ -378,26 +421,14 @@ int close(int fd)
>  
>      printk("close(%d)\n", fd);
>      if ( ops->close )
> -    {
>          res = ops->close(fd);
> -        goto out;
> -    }
> -
> -    switch (files[fd].type) {
> -        default:
> -            break;
> -#ifdef HAVE_LWIP
> -	case FTYPE_SOCKET:
> -	    res = lwip_close(files[fd].fd);
> -            break;
> -#endif
> -	case FTYPE_NONE:
> -            printk("close(%d): Bad descriptor\n", fd);
> -            errno = EBADF;
> -            return -1;
> +    else if ( files[fd].type == FTYPE_NONE )
> +    {
> +        printk("close(%d): Bad descriptor\n", fd);
> +        errno = EBADF;
> +        return -1;
>      }
>  
> - out:
>      memset(files + fd, 0, sizeof(struct file));
>      files[fd].type = FTYPE_NONE;
>      return res;
> @@ -429,21 +460,6 @@ int fstat(int fd, struct stat *buf)
>      if ( ops->fstat )
>          return ops->fstat(fd, buf);
>  
> -    switch (files[fd].type) {
> -	case FTYPE_SOCKET: {
> -            buf->st_mode = S_IFSOCK|S_IRUSR|S_IWUSR;
> -	    buf->st_uid = 0;
> -	    buf->st_gid = 0;
> -	    buf->st_size = 0;
> -	    buf->st_atime = 
> -	    buf->st_mtime = 
> -	    buf->st_ctime = time(NULL);
> -	    return 0;
> -	}
> -	default:
> -	    break;
> -    }
> -
>      printk("statf(%d): Bad descriptor\n", fd);
>      errno = EBADF;
>      return -1;
> @@ -491,21 +507,9 @@ int fcntl(int fd, int cmd, ...)
>      arg = va_arg(ap, long);
>      va_end(ap);
>  
> -    switch (cmd) {
> -#ifdef HAVE_LWIP
> -	case F_SETFL:
> -	    if (files[fd].type == FTYPE_SOCKET && !(arg & ~O_NONBLOCK)) {
> -		/* Only flag supported: non-blocking mode */
> -		uint32_t nblock = !!(arg & O_NONBLOCK);
> -		return lwip_ioctl(files[fd].fd, FIONBIO, &nblock);
> -	    }
> -	    /* Fallthrough */
> -#endif
> -	default:
> -	    printk("fcntl(%d, %d, %lx/%lo)\n", fd, cmd, arg, arg);
> -	    errno = ENOSYS;
> -	    return -1;
> -    }
> +    printk("fcntl(%d, %d, %lx/%lo)\n", fd, cmd, arg, arg);
> +    errno = ENOSYS;
> +    return -1;
>  }
>  
>  DIR *opendir(const char *name)
> @@ -539,23 +543,6 @@ int closedir(DIR *dir)
>  
>  /* We assume that only the main thread calls select(). */
>  
> -#if defined(LIBC_DEBUG) || defined(LIBC_VERBOSE)
> -static const char *file_types[] = {
> -    [FTYPE_NONE]    = "none",
> -    [FTYPE_SOCKET]  = "socket",
> -};
> -
> -static char *get_type_name(unsigned int type)
> -{
> -    if ( type < ARRAY_SIZE(file_ops) && file_ops[type] )
> -        return file_ops[type]->name;
> -
> -    if ( type < ARRAY_SIZE(file_types) && file_types[type] )
> -        return file_types[type];
> -
> -    return "none";
> -}
> -#endif
>  #ifdef LIBC_DEBUG
>  static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
>  {
> @@ -566,7 +553,7 @@ static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *except
>  	if (FD_ISSET(i, set)) { \
>  	    if (comma) \
>  		printk(", "); \
> -	    printk("%d(%s)", i, get_type_name(files[i].type)); \
> +	    printk("%d(%s)", i, get_file_ops(files[i].type)->name); \
>  	    comma = 1; \
>  	} \
>      } \
> @@ -600,7 +587,7 @@ static void dump_pollfds(struct pollfd *pfd, int nfds, int timeout)
>          fd = pfd[i].fd;
>          if (comma)
>              printk(", ");
> -        printk("%d(%s)/%02x", fd, get_type_name(files[fd].type),
> +        printk("%d(%s)/%02x", fd, get_file_ops(files[fd].type)->name,
>              pfd[i].events);
>              comma = 1;
>      }
> @@ -754,7 +741,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  	printk("%d(%d): ", nb, sock_n);
>  	for (i = 0; i < nfds; i++) {
>  	    if (nbread[i] || nbwrite[i] || nbexcept[i])
> -		printk(" %d(%c):", i, get_type_name(files[i].type));
> +		printk(" %d(%c):", i, get_file_ops(files[i].type)->name);
>  	    if (nbread[i])
>  	    	printk(" %dR", nbread[i]);
>  	    if (nbwrite[i])
> -- 
> 2.26.2
> 

-- 
Samuel
Running Windows on a Pentium is like having a brand new Porsche but only
be able to drive backwards with the handbrake on.
(Unknown source)


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 10:30:41 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 10:30:41 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256448.440069 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7att-0006G1-5O; Wed, 12 Jan 2022 10:30:41 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256448.440069; Wed, 12 Jan 2022 10:30:41 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7att-0006Fv-2P; Wed, 12 Jan 2022 10:30:41 +0000
Received: by outflank-mailman (input) for mailman id 256448;
 Wed, 12 Jan 2022 10:30:40 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=qR4C=R4=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7ats-0005sd-K6
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 10:30:40 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id b003d5d7-7392-11ec-bd6f-bfb69f65cdc7;
 Wed, 12 Jan 2022 11:30:40 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 8B4A3416;
 Wed, 12 Jan 2022 11:30:39 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id Ba3ceNDcRovm; Wed, 12 Jan 2022 11:30:39 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 2C7B140E;
 Wed, 12 Jan 2022 11:30:39 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n7atq-00HPZ4-P9;
 Wed, 12 Jan 2022 11:30:38 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: b003d5d7-7392-11ec-bd6f-bfb69f65cdc7
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Wed, 12 Jan 2022 11:30:38 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [PATCH v2 09/12] mini-os: use file_ops and get_file_from_fd()
 for console
Message-ID: <20220112103038.oubgjjanalwcyfit@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-10-jgross@suse.com>
 <20220111203501.tywfn4czhwavhgrf@begin>
 <bb7d4313-2500-3e60-8a51-93e909739c90@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <bb7d4313-2500-3e60-8a51-93e909739c90@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 8B4A3416
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le mer. 12 janv. 2022 08:57:07 +0100, a ecrit:
> On 11.01.22 21:35, Samuel Thibault wrote:
> > Juergen Gross, le mar. 11 janv. 2022 16:12:12 +0100, a ecrit:
> > > +static int consfront_fstat(int fd, struct stat *buf)
> > > +{
> > > +    struct file *file = get_file_from_fd(fd);
> > > +
> > > +    buf->st_mode = S_IRUSR | S_IWUSR;
> > > +    buf->st_mode |= (file->type == FTYPE_CONSOLE) ? S_IFCHR : S_IFREG;
> > > +    buf->st_atime = buf->st_mtime = buf->st_ctime = time(NULL);
> > > +
> > > +    return 0;
> > > +}
> > 
> > This seems to be missing filling st_uid, st_gid, etc.?
> 
> Not really. Those are set to zero via the call of init_stat()
> in fstat().

Ah, I missed that call indeed.

Samuel


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 11:30:42 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 11:30:42 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256558.440394 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7bpv-00033c-11; Wed, 12 Jan 2022 11:30:39 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256558.440394; Wed, 12 Jan 2022 11:30:38 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7bpu-00032v-Sl; Wed, 12 Jan 2022 11:30:38 +0000
Received: by outflank-mailman (input) for mailman id 256558;
 Wed, 12 Jan 2022 11:30:37 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7bpt-0002ze-QD
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 11:30:37 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 0f7b8d60-739b-11ec-bd6f-bfb69f65cdc7;
 Wed, 12 Jan 2022 12:30:36 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id A36E31F3CE;
 Wed, 12 Jan 2022 11:30:35 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7FC4E13B42;
 Wed, 12 Jan 2022 11:30:35 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id T1T4Hdu73mEtFAAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 11:30:35 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 0f7b8d60-739b-11ec-bd6f-bfb69f65cdc7
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641987035; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=admoSzsRYndfJq4zb3YGkUaexcFGyJbMdWcz9wV5FAQ=;
	b=tehbMhfzxhPP4fhvUV8T6PZ8N3Ob2LyG6+mZ7d+veBOxV/Nsw/qCJebg2+kPYKYDhf9sXy
	k9jID/HjxSuPZ0O5E6qevGoQm3ZyluEkP6Hjp3kz/2rqw0fHNUjZIpiRyXGMoXLQFzIuOR
	Ac0rridz46sWc1p5gojAYPVpNvU59Uk=
Subject: Re: [PATCH v2 09/12] mini-os: use file_ops and get_file_from_fd() for
 console
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-10-jgross@suse.com>
 <bfa154a6-88e3-8ce9-d959-7220ea7a7e64@srcf.net>
From: Juergen Gross <jgross@suse.com>
Message-ID: <fc1e1631-2906-b3d5-19e0-d2fedc268422@suse.com>
Date: Wed, 12 Jan 2022 12:30:34 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <bfa154a6-88e3-8ce9-d959-7220ea7a7e64@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="AkqgYSlS9SXMIHsB11ds2eZ8s0lV1f7Uh"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--AkqgYSlS9SXMIHsB11ds2eZ8s0lV1f7Uh
Content-Type: multipart/mixed; boundary="g23jRSqbHMKv1xLKeEuiJH082y0aada46";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <fc1e1631-2906-b3d5-19e0-d2fedc268422@suse.com>
Subject: Re: [PATCH v2 09/12] mini-os: use file_ops and get_file_from_fd() for
 console
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-10-jgross@suse.com>
 <bfa154a6-88e3-8ce9-d959-7220ea7a7e64@srcf.net>
In-Reply-To: <bfa154a6-88e3-8ce9-d959-7220ea7a7e64@srcf.net>

--g23jRSqbHMKv1xLKeEuiJH082y0aada46
Content-Type: multipart/mixed;
 boundary="------------688BF55A7E77BE8BB995E931"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------688BF55A7E77BE8BB995E931
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 12.01.22 12:23, Andrew Cooper wrote:
> On 11/01/2022 15:12, Juergen Gross wrote:
>> +static int savefile_write(int fd, const void *buf, size_t nbytes)
>> +{
>> +    int ret =3D 0, tot =3D nbytes;
>> +    struct file *file =3D get_file_from_fd(fd);
>> +
>> +    while ( nbytes > 0 )
>> +    {
>> +        ret =3D xencons_ring_send(file->dev, (char *)buf, nbytes);
>> +        nbytes -=3D ret;
>> +        buf =3D (char *)buf + ret;
>> +    }
>> +
>> +    return tot - nbytes;
>> +}
>> +
>> +static int console_write(int fd, const void *buf, size_t nbytes)
>> +{
>> +    struct file *file =3D get_file_from_fd(fd);
>> +
>> +    console_print(file->dev, (char *)buf, nbytes);
>=20
> I've just noticed this while committing the previous series, and I know=

> it is a preexisting bug, but the casts here are utterly unsafe, because=

> they're casting away constness.
>=20
> console_print() is easy to fix, and just requires a prototype
> adjustment.=C2=A0 That said, it also desperately also needs to fix 'int=

> length' to size_t to avoid problems with negative length VLAs on the st=
ack.
>=20
> xencons_ring_send() already takes const char *, so I'm pretty sure you
> can just drop the casts here.=C2=A0 It too ought to not truncate size_t=
 bytes
> to "unsigned".

Okay, will do that.


Juergen


--------------688BF55A7E77BE8BB995E931
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------688BF55A7E77BE8BB995E931--

--g23jRSqbHMKv1xLKeEuiJH082y0aada46--

--AkqgYSlS9SXMIHsB11ds2eZ8s0lV1f7Uh
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHeu9oFAwAAAAAACgkQsN6d1ii/Ey8d
aQf/axVxv8M94puJS0qP9I7GI4H/meJSveItNGxAXRAvqileOpntsKEv4dsPWqSgvfEYOb8h4ER7
mU5DafKbK2tJdVbnu+wpwgPrZwg0I6VICngUWLdGCis9oAfN5WxTpKY5DrO40Ihfnr1pwAnt5hX+
NT2jMz55TuaqOd52twMV1GmSjIBqMdmYooAuRUGGkgcX3V6WCkM3Z6TLj7jvYmdu24pEjP0UIKVB
w6KHSulxSvLG4NK7e65iPYdOFOzCbJyrbE7Hr8JLA1qYLAP7nbQkKFIIc+rj1fQl41BnESVn2QAJ
buWeS3vUPtxnOU/BxJ/omed2zZ0zK6cm2pL28U2xIQ==
=u+A8
-----END PGP SIGNATURE-----

--AkqgYSlS9SXMIHsB11ds2eZ8s0lV1f7Uh--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 11:31:05 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 11:31:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256561.440403 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7bqL-0003eA-1s; Wed, 12 Jan 2022 11:31:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256561.440403; Wed, 12 Jan 2022 11:31:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7bqK-0003e3-VI; Wed, 12 Jan 2022 11:31:04 +0000
Received: by outflank-mailman (input) for mailman id 256561;
 Wed, 12 Jan 2022 11:31:03 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7bqI-0003bv-TP
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 11:31:03 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 1ea89a70-739b-11ec-9c70-5536b2d1e4e1;
 Wed, 12 Jan 2022 12:31:01 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 3CBCC21123;
 Wed, 12 Jan 2022 11:31:01 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0EF0013B42;
 Wed, 12 Jan 2022 11:31:01 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id Y5xpAPW73mF7FAAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 11:31:01 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 1ea89a70-739b-11ec-9c70-5536b2d1e4e1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641987061; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=8++ZaXuFsbuKeuWecKBic5Tbd5/gCtHPshj1oXIVG8Q=;
	b=KVCE2J2FJs32Q6i7clz/37kYuxmLAaji8lpxgxr67ixVZxRhxpZbruLgg7ruILU+VX1Fg/
	0WpFD8KZ6LLgD0Sjt4t1oi73e3VFwA94P2YkTF+3pnSgECd5gRDzu/ewaRc8MIfibCUwcZ
	dW8SIXYQqqarEyk/pgCYkLo21Ah5RKI=
Subject: Re: [PATCH v2 10/12] mini-os: add struct file_ops for file type
 socket
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-11-jgross@suse.com>
 <37ade49f-e277-99a4-4dd7-e1e6cb327ffb@srcf.net>
From: Juergen Gross <jgross@suse.com>
Message-ID: <ba59005a-4f9b-076e-f524-79d769f379c9@suse.com>
Date: Wed, 12 Jan 2022 12:31:00 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <37ade49f-e277-99a4-4dd7-e1e6cb327ffb@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="C0wjhvaLe52S38BZGA3txtUasNMTosj4o"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--C0wjhvaLe52S38BZGA3txtUasNMTosj4o
Content-Type: multipart/mixed; boundary="3jxSrtCs6pN2YoqPq5ykFQdbY6wokLlta";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <ba59005a-4f9b-076e-f524-79d769f379c9@suse.com>
Subject: Re: [PATCH v2 10/12] mini-os: add struct file_ops for file type
 socket
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-11-jgross@suse.com>
 <37ade49f-e277-99a4-4dd7-e1e6cb327ffb@srcf.net>
In-Reply-To: <37ade49f-e277-99a4-4dd7-e1e6cb327ffb@srcf.net>

--3jxSrtCs6pN2YoqPq5ykFQdbY6wokLlta
Content-Type: multipart/mixed;
 boundary="------------38D0AB273F0FF548EF8706CD"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------38D0AB273F0FF548EF8706CD
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 12.01.22 12:25, Andrew Cooper wrote:
> On 11/01/2022 15:12, Juergen Gross wrote:
>> +static int socket_write(int fd, const void *buf, size_t nbytes)
>> +{
>> +    return lwip_write(fd, (void *)buf, nbytes);
>=20
> This void cast was bogus before, and can be dropped.=C2=A0 lwip_write()=

> already takes a const pointer.

Okay.


Juergen


--------------38D0AB273F0FF548EF8706CD
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------38D0AB273F0FF548EF8706CD--

--3jxSrtCs6pN2YoqPq5ykFQdbY6wokLlta--

--C0wjhvaLe52S38BZGA3txtUasNMTosj4o
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHeu/QFAwAAAAAACgkQsN6d1ii/Ey96
cAf/QZsUMhkCQunis0QWbfQyYQH8M5S4FKfZviCAxtts3lBKi8pTFBdo9UsM5ylW9VW5xHI6drre
CtttF8ZivPeFuLlL6PzTjYsQMd3m3f0RIrhAseTW7PGiPHXD/hUFGIyQ47MA+dkeBQsxm61W68OE
G3a8zh+VrDE00H+TFuw/GJAyHM7EibYJSps8B9vjwfDKVE4ig+99a4iObhkeyzNWkJ/uvRWdAzip
QvBzudPkhLKJE5z8VsFxyFhFX2a86bzpHsEGgEg4VBcC1deIKihuR0ZsPejsMZ6YeC0mfk+6GNeX
+3Qn9C8hT0q3txzMIrAPDQTfITFpUSlSHjlaVWZErA==
=KaE0
-----END PGP SIGNATURE-----

--C0wjhvaLe52S38BZGA3txtUasNMTosj4o--


From minios-devel-bounces@lists.xenproject.org Wed Jan 12 11:32:28 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 12 Jan 2022 11:32:28 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256570.440418 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7brf-0004YC-Ic; Wed, 12 Jan 2022 11:32:27 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256570.440418; Wed, 12 Jan 2022 11:32:27 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n7brf-0004Y2-FR; Wed, 12 Jan 2022 11:32:27 +0000
Received: by outflank-mailman (input) for mailman id 256570;
 Wed, 12 Jan 2022 11:32:26 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=zSVc=R4=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n7bre-0004Xt-Hs
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 11:32:26 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 50d4f2f1-739b-11ec-9c70-5536b2d1e4e1;
 Wed, 12 Jan 2022 12:32:25 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 6797E218E6;
 Wed, 12 Jan 2022 11:32:25 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4094913B42;
 Wed, 12 Jan 2022 11:32:25 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 46WADkm83mE/FQAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 12 Jan 2022 11:32:25 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 50d4f2f1-739b-11ec-9c70-5536b2d1e4e1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1641987145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=eMvdzorta42Ya0fr9SWXzplMPwcOKwBhZz6kh21VkQU=;
	b=b9Xw1tC0hijT0OlGyuWRQGsdVRHpSmvt6PPLqckJFshju5KPF2bVKw4LA54ZAMTPLIpRdL
	/x57MBscChsIL4+j4+/2KAodD9W4gNOX/pR20fL1XKAnbgzxqe8kKqtg5MkmoRJxCJNq0k
	7xtjhkBoWEsnpNz2plfm+rNbss3n4eA=
Subject: Re: [PATCH v2 10/12] mini-os: add struct file_ops for file type
 socket
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-11-jgross@suse.com>
 <659743cb-abc9-31b5-d6b2-0a21aa76bbb4@srcf.net>
From: Juergen Gross <jgross@suse.com>
Message-ID: <cf84e6f4-efcb-e206-5cc0-769fe6399de5@suse.com>
Date: Wed, 12 Jan 2022 12:32:24 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <659743cb-abc9-31b5-d6b2-0a21aa76bbb4@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="GcR583zDw8ysJBNlY1wNTSt8p40QHj58M"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--GcR583zDw8ysJBNlY1wNTSt8p40QHj58M
Content-Type: multipart/mixed; boundary="rxS368b4vpEaeEMrVpCx481MrTpmO0jXa";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <cf84e6f4-efcb-e206-5cc0-769fe6399de5@suse.com>
Subject: Re: [PATCH v2 10/12] mini-os: add struct file_ops for file type
 socket
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-11-jgross@suse.com>
 <659743cb-abc9-31b5-d6b2-0a21aa76bbb4@srcf.net>
In-Reply-To: <659743cb-abc9-31b5-d6b2-0a21aa76bbb4@srcf.net>

--rxS368b4vpEaeEMrVpCx481MrTpmO0jXa
Content-Type: multipart/mixed;
 boundary="------------A1FDA99D8985E049B4B30829"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------A1FDA99D8985E049B4B30829
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 12.01.22 12:28, Andrew Cooper wrote:
> On 11/01/2022 15:12, Juergen Gross wrote:
>> diff --git a/lib/sys.c b/lib/sys.c
>> index 3a8aa68..12deaed 100644
>> --- a/lib/sys.c
>> +++ b/lib/sys.c
>> @@ -99,11 +99,70 @@ static struct file_ops file_ops_none =3D {
>>       .name =3D "none",
>>   };
>>  =20
>> +#ifdef HAVE_LWIP
>> +static int socket_read(int fd, void *buf, size_t nbytes)
>> +{
>> +    return lwip_read(fd, buf, nbytes);
>> +}
>> +
>> +static int socket_write(int fd, const void *buf, size_t nbytes)
>> +{
>> +    return lwip_write(fd, (void *)buf, nbytes);
>> +}
>> +
>> +static int close_socket_fd(int fd)
>> +{
>> +    struct file *file =3D get_file_from_fd(fd);
>> +
>> +    return lwip_close(file->fd);
>> +}
>=20
> Actually, on further thoughts...
>=20
>> +static struct file_ops socket_ops =3D {
>> +    .name =3D "socket",
>> +    .read =3D socket_read,
>> +    .write =3D socket_write,
>> +    .close =3D close_socket_fd,
>> +    .fstat =3D socket_fstat,
>> +    .fcntl =3D socket_fcntl,
>> +};
>=20
> read, write and close should dispatch directly to lwip_* and not bounce=

> through a no-op local function.

Not with changing the first parameter to struct file *.

BTW, this patch had a bug, as the calls need to use file->fd instead of
fd.


Juergen

--------------A1FDA99D8985E049B4B30829
Content-Type: application/pgp-keys;
 name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Transfer-Encoding: quoted-printable
Content-Description: OpenPGP public key
Content-Disposition: attachment;
 filename="OpenPGP_0xB0DE9DD628BF132F.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy=
cWx
w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O=
f8Z
d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y=
9bf
IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq=
G7/
377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR=
3Jv
c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA=
QIe
AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT=
hpw
dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0=
MbD
1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbv=
oPH
Z8SlM4KWm8rG+lIkGurqqu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v=
5QL
+qHI3EIPtyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVyZ=
2Vu
IEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJCAcDAgEGFQgCC=
QoL
BBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4RF7HoZhPVPogNVbC4YA6lW7Dr=
Wf0
teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz78X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC=
/nu
AFVGy+67q2DH8As3KPu0344TBDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0Lh=
ITT
d9jLzdDad1pQSToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLm=
XBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkMnQfvUewRz=
80h
SnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMBAgAjBQJTjHDXAhsDBwsJC=
AcD
AgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJn=
FOX
gMLdBQgBlVPO3/D9R8LtF9DBAFPNhlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1=
jnD
kfJZr6jrbjgyoZHiw/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0=
N51
N5JfVRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwPOoE+l=
otu
fe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK/1xMI3/+8jbO0tsn1=
tqS
EUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1c2UuZGU+wsB5BBMBAgAjBQJTjHDrA=
hsD
BwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3=
g3O
ZUEBmDHVVbqMtzwlmNC4k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5=
dM7
wRqzgJpJwK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu5=
D+j
LRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzBTNh30FVKK1Evm=
V2x
AKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37IoN1EblHI//x/e2AaIHpzK5h88N=
Eaw
QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW=
nHI
s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR=
wgn
BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV=
bVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk=
pEd
IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA=
QAB
wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw=
Tbe
8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1=
vJz
Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8=
VGi
wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW=
svi
uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX=
zXs
ZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------A1FDA99D8985E049B4B30829--

--rxS368b4vpEaeEMrVpCx481MrTpmO0jXa--

--GcR583zDw8ysJBNlY1wNTSt8p40QHj58M
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHevEgFAwAAAAAACgkQsN6d1ii/Ey/0
+wf+KvhMxYFTHIudZ+A2MSKm5mzsrcOgcVsxcnVB3usK4t0o1h+tPNrxfviTmo89wwX7Z2gYKBXp
E9WCYuDxQfQI5wThLrsc4uKBJkKr2gU2xz0Xk8QS2y13QJRzrXFIAuxvVM+WaBRyaoVQTp6cpfcr
CZWTNbsmeHkr3to2AdYmNjRvGs5RIJPz+CAJwEkLpVMWa86nq1D3xiTmYDUPUScFG5Yv1v9yBWvr
O8FDU3q6k3zDnPkVOSNXUGX1QgxrgLhD67CPPe+m/1J5OCmzg2NrFPb8s2EtyH6qQPXTh6W1HhkZ
uAxfPfcs+N+VYjNCLZYSETmWMPHqDkrM8JwSNp0bpQ==
=OvWj
-----END PGP SIGNATURE-----

--GcR583zDw8ysJBNlY1wNTSt8p40QHj58M--


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 06:45:38 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 06:45:38 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257772.443032 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n8zIE-0008Se-7T; Sun, 16 Jan 2022 06:45:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257772.443032; Sun, 16 Jan 2022 06:45:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n8zIE-0008SX-3k; Sun, 16 Jan 2022 06:45:34 +0000
Received: by outflank-mailman (input) for mailman id 257772;
 Sun, 16 Jan 2022 06:45:33 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n8zID-0008SH-Eq
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 06:45:33 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e56722e7-7697-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 07:45:32 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 2085E1F3B2;
 Sun, 16 Jan 2022 06:45:30 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EABF313350;
 Sun, 16 Jan 2022 06:45:29 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 8BQdOAm/42H0eQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 06:45:29 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e56722e7-7697-11ec-a115-11989b9578b4
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642315530; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=7gNDOfInVfcNlQrXw2pw9v+H3MpjcRV3L7PS0stFBOo=;
	b=Gq18xKWfycegxkOc2K08BzGK4gxRqZRSeaKgjvUjTDmZJSEaYFFdNxPROi6msHdvphQ/kY
	OChWev3wte86QRL8c4LInH5R/HDNveeIlTzGJrTGbrHUDoS8uGs0lr5/IczUhyoV/N8P3I
	vBSB+0fqlXd/qp+S6fLBklbsEaH7UzY=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 2/5] reset file type in close() in one place only
Date: Sun, 16 Jan 2022 07:45:24 +0100
Message-Id: <20220116064527.23519-3-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116064527.23519-1-jgross@suse.com>
References: <20220116064527.23519-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Today the file type in struct file is set to FTYPE_NONE for each
file type individually. Do that at the end of close() handling for
all types.

While at it wipe the complete struct file, too, in order to avoid
old data creeping into a new allocated struct file.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V2:
- new patch
V3:
- add error handling (Andrew Cooper)
- use BUILD_BUG_ON() (Andrew Cooper)
---
 lib/sys.c | 56 ++++++++++++++++++++++++++++---------------------------
 lib/xs.c  |  1 -
 2 files changed, 29 insertions(+), 28 deletions(-)

diff --git a/lib/sys.c b/lib/sys.c
index 9a03875c..7df77cc6 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -265,7 +265,7 @@ int read(int fd, void *buf, size_t nbytes)
             return ret;
         }
 #ifdef HAVE_LWIP
-	case FTYPE_SOCKET:
+        case FTYPE_SOCKET:
 	    return lwip_read(files[fd].fd, buf, nbytes);
 #endif
 #ifdef CONFIG_NETFRONT
@@ -424,84 +424,86 @@ int fsync(int fd) {
 
 int close(int fd)
 {
+    int res = 0;
+
+    if ( fd < 0 || fd >= ARRAY_SIZE(files) )
+        goto error;
+
     printk("close(%d)\n", fd);
     switch (files[fd].type) {
         default:
-	    files[fd].type = FTYPE_NONE;
-	    return 0;
+            break;
 #ifdef CONFIG_XENBUS
 	case FTYPE_XENBUS:
             xs_daemon_close((void*)(intptr_t) fd);
-            return 0;
+            break;
 #endif
 #ifdef HAVE_LWIP
-	case FTYPE_SOCKET: {
-	    int res = lwip_close(files[fd].fd);
-	    files[fd].type = FTYPE_NONE;
-	    return res;
-	}
+	case FTYPE_SOCKET:
+            res = lwip_close(files[fd].fd);
+            break;
 #endif
 #ifdef CONFIG_LIBXENCTRL
 	case FTYPE_XC:
 	    minios_interface_close_fd(fd);
-	    return 0;
+            break;
 #endif
 #ifdef CONFIG_LIBXENEVTCHN
 	case FTYPE_EVTCHN:
 	    minios_evtchn_close_fd(fd);
-            return 0;
+            break;
 #endif
 #ifdef CONFIG_LIBXENGNTTAB
 	case FTYPE_GNTMAP:
 	    minios_gnttab_close_fd(fd);
-	    return 0;
+            break;
 #endif
 #ifdef CONFIG_NETFRONT
 	case FTYPE_TAP:
 	    shutdown_netfront(files[fd].dev);
-	    files[fd].type = FTYPE_NONE;
-	    return 0;
+            break;
 #endif
 #ifdef CONFIG_BLKFRONT
 	case FTYPE_BLK:
             shutdown_blkfront(files[fd].dev);
-	    files[fd].type = FTYPE_NONE;
-	    return 0;
+            break;
 #endif
 #ifdef CONFIG_TPMFRONT
 	case FTYPE_TPMFRONT:
             shutdown_tpmfront(files[fd].dev);
-	    files[fd].type = FTYPE_NONE;
-	    return 0;
+            break;
 #endif
 #ifdef CONFIG_TPM_TIS
 	case FTYPE_TPM_TIS:
             shutdown_tpm_tis(files[fd].dev);
-	    files[fd].type = FTYPE_NONE;
-	    return 0;
+            break;
 #endif
 #ifdef CONFIG_KBDFRONT
 	case FTYPE_KBD:
             shutdown_kbdfront(files[fd].dev);
-            files[fd].type = FTYPE_NONE;
-            return 0;
+            break;
 #endif
 #ifdef CONFIG_FBFRONT
 	case FTYPE_FB:
             shutdown_fbfront(files[fd].dev);
-            files[fd].type = FTYPE_NONE;
-            return 0;
+            break;
 #endif
 #ifdef CONFIG_CONSFRONT
         case FTYPE_SAVEFILE:
         case FTYPE_CONSOLE:
             fini_consfront(files[fd].dev);
-            files[fd].type = FTYPE_NONE;
-            return 0;
+            break;
 #endif
 	case FTYPE_NONE:
-	    break;
+            goto error;
     }
+
+    memset(files + fd, 0, sizeof(struct file));
+    BUILD_BUG_ON(FTYPE_NONE != 0);
+
+    return res;
+
+ error:
     printk("close(%d): Bad descriptor\n", fd);
     errno = EBADF;
     return -1;
diff --git a/lib/xs.c b/lib/xs.c
index 0459f52f..4af0f960 100644
--- a/lib/xs.c
+++ b/lib/xs.c
@@ -35,7 +35,6 @@ void xs_daemon_close(struct xs_handle *h)
         next = event->next;
         free(event);
     }
-    files[fd].type = FTYPE_NONE;
 }
 
 int xs_fileno(struct xs_handle *h)
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 06:45:38 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 06:45:38 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257773.443036 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n8zIE-0008Sy-BR; Sun, 16 Jan 2022 06:45:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257773.443036; Sun, 16 Jan 2022 06:45:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n8zIE-0008Si-5k; Sun, 16 Jan 2022 06:45:34 +0000
Received: by outflank-mailman (input) for mailman id 257773;
 Sun, 16 Jan 2022 06:45:33 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n8zID-0008SI-RI
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 06:45:33 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id e55a6a37-7697-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 07:45:32 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id F02511F3AF;
 Sun, 16 Jan 2022 06:45:29 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BA9E013ABD;
 Sun, 16 Jan 2022 06:45:29 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id gKtILAm/42H0eQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 06:45:29 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e55a6a37-7697-11ec-9bbc-9dff3e4ee8c5
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642315529; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=3GoDjpDXFuZrudyOquKeoDi2JAufp1li+iMTg9O8+0U=;
	b=LOLd7RxCvyVRaao+x4dTavf06lBa9kyEh5im5XCdUCSuA+4oMDHyguqmMrkp+9SoR7N1ny
	EgXotHgErhIXkGwLLlK6Bf66WGUiAbXKimysZhqnLadPjC/9te7GatmnAuW2clV8LHOfQ+
	inm1PXlURZyxTEfMN3BUJki/amJ8Ur4=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 1/5] introduce get_file_from_fd()
Date: Sun, 16 Jan 2022 07:45:23 +0100
Message-Id: <20220116064527.23519-2-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116064527.23519-1-jgross@suse.com>
References: <20220116064527.23519-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Exporting the files[] array especially for components outside the
mini-os source tree is limiting the ability to change any file handling
in mini-os.

Introduce a new function get_file_from_fd() to return the struct file
pointer (or NULL) for a given file descriptor.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
V3:
- use ARRAY_SIZE() for boundary check (Andrew Cooper)
---
 include/lib.h | 1 +
 lib/sys.c     | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/include/lib.h b/include/lib.h
index 91364ba7..7a0546bd 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -198,6 +198,7 @@ struct file {
 
 extern struct file files[];
 
+struct file *get_file_from_fd(int fd);
 int alloc_fd(enum fd_type type);
 void close_all_files(void);
 extern struct thread *main_thread;
diff --git a/lib/sys.c b/lib/sys.c
index 6f2b026d..9a03875c 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -98,6 +98,14 @@ struct file files[NOFILE] = {
     { .type = FTYPE_CONSOLE }, /* stderr */
 };
 
+struct file *get_file_from_fd(int fd)
+{
+    if ( fd < 0 || fd >= ARRAY_SIZE(files) )
+        return NULL;
+
+    return (files[fd].type == FTYPE_NONE) ? NULL : files + fd;
+}
+
 DECLARE_WAIT_QUEUE_HEAD(event_queue);
 
 int alloc_fd(enum fd_type type)
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 06:45:38 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 06:45:38 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257780.443079 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n8zII-0000nQ-Nz; Sun, 16 Jan 2022 06:45:38 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257780.443079; Sun, 16 Jan 2022 06:45:38 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n8zII-0000ll-HF; Sun, 16 Jan 2022 06:45:38 +0000
Received: by outflank-mailman (input) for mailman id 257780;
 Sun, 16 Jan 2022 06:45:37 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n8zIH-0008SI-4V
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 06:45:37 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id e5c13b56-7697-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 07:45:32 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id B4FB7219C8;
 Sun, 16 Jan 2022 06:45:30 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8B3DE13ABD;
 Sun, 16 Jan 2022 06:45:30 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id cGS/IAq/42H0eQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 06:45:30 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e5c13b56-7697-11ec-9bbc-9dff3e4ee8c5
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642315530; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=sMF8pqUc94a10+353xWoWiPfMeUftk07LIrUu9q2Fz8=;
	b=dR4rbD/G7KbYn4CT4GiZWXUD6uomLLLQdYtB4cY6dLjUqm7e69v4zR9T/1YrWBD6o+0dM1
	G+wKHa/tl3GSo4icxK0ls6IPHs1yIdjg0dMf08dI2R25cWTmUt/F7E2UV2lUvCrRIT39T6
	CM1kOrnaSEv6OBEQN2fa3N9hoSW4jjM=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 5/5] add CONFIG_LIBXS item
Date: Sun, 16 Jan 2022 07:45:27 +0100
Message-Id: <20220116064527.23519-6-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116064527.23519-1-jgross@suse.com>
References: <20220116064527.23519-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Mini-OS contains a stripped down version of libxenstore in lib/xs.c.
Today it is being built always if CONFIG_XENBUS is set and libc
support is enabled.

In order to allow a Mini-OS specific build of libxenstore to be used
instead add a new CONFIG_LIBXS item which per default will have the
same setting as CONFIG_XENBUS. A user wanting to replace lib/xs.c
with libxenstore would just need to set CONFIG_XENBUS=y and
CONFIG_LIBXS=n.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V3:
- new patch
---
 Config.mk                     | 10 ++++++++--
 Makefile                      |  2 +-
 arch/x86/testbuild/all-no     |  1 +
 arch/x86/testbuild/all-yes    |  1 +
 arch/x86/testbuild/newxen-yes |  1 +
 lib/sys.c                     |  4 ++--
 6 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/Config.mk b/Config.mk
index 1e083881..03023033 100644
--- a/Config.mk
+++ b/Config.mk
@@ -171,7 +171,10 @@ endif
 # arch/*/testbuild/*-yes and arch/*/testbuild/*-no should set ALL possible
 # CONFIG_ variables.
 
-# Configuration defaults
+# Configuration defaults:
+# CONFIG-y contains all items defaulting to "y"
+# CONFIG-n contains all items defaulting to "n"
+# CONFIG-x contains all items being calculated if not set explicitly
 CONFIG-y += CONFIG_START_NETWORK
 CONFIG-y += CONFIG_SPARSE_BSS
 CONFIG-y += CONFIG_BLKFRONT
@@ -205,7 +208,10 @@ CONFIG-$(lwip) += CONFIG_LWIP
 $(foreach i,$(CONFIG-y),$(eval $(i) ?= y))
 $(foreach i,$(CONFIG-n),$(eval $(i) ?= n))
 
-CONFIG-all := $(CONFIG-y) $(CONFIG-n)
+CONFIG-x += CONFIG_LIBXS
+CONFIG_LIBXS ?= $(CONFIG_XENBUS)
+
+CONFIG-all := $(CONFIG-y) $(CONFIG-n) $(CONFIG-x)
 
 # Export config items as compiler directives
 $(foreach i,$(CONFIG-all),$(eval DEFINES-$($(i)) += -D$(i)))
diff --git a/Makefile b/Makefile
index 06b60fc7..9f95d197 100644
--- a/Makefile
+++ b/Makefile
@@ -65,7 +65,7 @@ src-y += lib/stack_chk_fail.c
 src-y += lib/string.c
 src-y += lib/sys.c
 src-y += lib/xmalloc.c
-src-$(CONFIG_XENBUS) += lib/xs.c
+src-$(CONFIG_LIBXS) += lib/xs.c
 
 src-$(CONFIG_XENBUS) += xenbus/xenbus.c
 
diff --git a/arch/x86/testbuild/all-no b/arch/x86/testbuild/all-no
index d6fc2608..46f974de 100644
--- a/arch/x86/testbuild/all-no
+++ b/arch/x86/testbuild/all-no
@@ -13,6 +13,7 @@ CONFIG_FBFRONT = n
 CONFIG_KBDFRONT = n
 CONFIG_CONSFRONT = n
 CONFIG_XENBUS = n
+CONFIG_LIBXS = n
 CONFIG_LIBXENEVTCHN = n
 CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/arch/x86/testbuild/all-yes b/arch/x86/testbuild/all-yes
index 98bbfebf..3ead12f1 100644
--- a/arch/x86/testbuild/all-yes
+++ b/arch/x86/testbuild/all-yes
@@ -13,6 +13,7 @@ CONFIG_FBFRONT = y
 CONFIG_KBDFRONT = y
 CONFIG_CONSFRONT = y
 CONFIG_XENBUS = y
+CONFIG_LIBXS = y
 CONFIG_BALLOON = y
 CONFIG_USE_XEN_CONSOLE = y
 # The following are special: they need support from outside
diff --git a/arch/x86/testbuild/newxen-yes b/arch/x86/testbuild/newxen-yes
index 06032004..5c0b3c80 100644
--- a/arch/x86/testbuild/newxen-yes
+++ b/arch/x86/testbuild/newxen-yes
@@ -13,6 +13,7 @@ CONFIG_FBFRONT = y
 CONFIG_KBDFRONT = y
 CONFIG_CONSFRONT = y
 CONFIG_XENBUS = y
+CONFIG_LIBXS = y
 CONFIG_BALLOON = y
 CONFIG_USE_XEN_CONSOLE = y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
diff --git a/lib/sys.c b/lib/sys.c
index 7be01fd3..e0ac5099 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -523,7 +523,7 @@ int close(int fd)
     switch (file->type) {
         default:
             break;
-#ifdef CONFIG_XENBUS
+#ifdef CONFIG_LIBXS
 	case FTYPE_XENBUS:
             xs_daemon_close((void*)(intptr_t) fd);
             break;
@@ -958,7 +958,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
                 n++;
 	    FD_CLR(i, exceptfds);
 	    break;
-#ifdef CONFIG_XENBUS
+#ifdef CONFIG_LIBXS
 	case FTYPE_XENBUS:
 	    if (FD_ISSET(i, readfds)) {
                 if (files[i].dev)
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 06:45:39 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 06:45:39 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257777.443066 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n8zIG-0000Zx-U5; Sun, 16 Jan 2022 06:45:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257777.443066; Sun, 16 Jan 2022 06:45:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n8zIG-0000ZH-Pq; Sun, 16 Jan 2022 06:45:36 +0000
Received: by outflank-mailman (input) for mailman id 257777;
 Sun, 16 Jan 2022 06:45:35 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n8zIF-0008SI-48
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 06:45:35 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id e55a9af7-7697-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 07:45:32 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id BCE8C212BD;
 Sun, 16 Jan 2022 06:45:29 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8898E13350;
 Sun, 16 Jan 2022 06:45:29 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id mnpkHwm/42H0eQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 06:45:29 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e55a9af7-7697-11ec-9bbc-9dff3e4ee8c5
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642315529; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:  content-transfer-encoding:content-transfer-encoding;
	bh=fEaIPFQ9C+0YacrD1yDplQpHXBb+arhcA+WHK9zKCzQ=;
	b=Pxv+tid21+U/5LIolLklPGhe73TaxiXEua1D8g5Ii4wNEWRWRIOWLziyRRD/strMXVyu1z
	vjKNf0GKV7RR/Fg/pHzyWs8rZQVnrCJdiG6csvOcHqT1oODUw+uw5A4YUX+GOEvjsccRdM
	G4hwzqBERnmda6JTfjm9dmqWxd3Pgx4=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 0/5] mini-os: remove struct file dependency on config
Date: Sun, 16 Jan 2022 07:45:22 +0100
Message-Id: <20220116064527.23519-1-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Today the layout of struct file is depending on the Mini-OS
configuration. This is especially bad as the layout is exported to
external users like the Xen libraries built for Mini-OS, and those
are being built only once for multiple stubdom configurations.

Today there is no direct problem resulting from this, as the main
difference between struct file layouts is a large union containing all
the device specific data for the different file types. The largest
union member is not configuration dependant, so the build is currently
not broken.

In order to avoid any future problems this patch series is eliminating
the configuration dependency by replacing most of the device specific
union members by a single pointer.

The two union members used by Xen libraries can't be replaced yet, as
those need to be switched to use the generic pointer first.

In order to hide the Mini-OS internal implementation of the files
array, patches 1, 2, and  4 are introducing a common framework to
access a struct file via its file descriptor, and to allocate new file
types dynamically instead of having them all pre-defined. The file type
specific operations are supplied via a function vector in order to
remove the dependency of lib/sys.c on all the various file types.

Patch 5 is preparing a possible future support of libxenstore instead
of using the Mini-OS internal variant located in lib/xs.c.

Changes in v3:
- first 14 patches already applied
- added patch 5

Changes in V2:
- added 3 more patches

Juergen Gross (5):
  introduce get_file_from_fd()
  reset file type in close() in one place only
  remove file type FTYPE_XC
  use function vectors instead of switch for file operations
  add CONFIG_LIBXS item

 Config.mk                     |  11 +-
 Makefile                      |   2 +-
 arch/x86/testbuild/all-no     |   2 +-
 arch/x86/testbuild/all-yes    |   2 +-
 arch/x86/testbuild/newxen-yes |   2 +-
 include/lib.h                 |  59 ++++--
 lib/sys.c                     | 345 ++++++++++++++++++++++++++--------
 lib/xs.c                      |   1 -
 8 files changed, 313 insertions(+), 111 deletions(-)

-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 06:45:39 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 06:45:39 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257776.443053 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n8zIG-0000Aa-03; Sun, 16 Jan 2022 06:45:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257776.443053; Sun, 16 Jan 2022 06:45:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n8zIF-0000A1-OL; Sun, 16 Jan 2022 06:45:35 +0000
Received: by outflank-mailman (input) for mailman id 257776;
 Sun, 16 Jan 2022 06:45:35 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n8zIE-0008SH-TN
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 06:45:35 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id e585290c-7697-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 07:45:32 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 50CC41F45F;
 Sun, 16 Jan 2022 06:45:30 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 26CC413350;
 Sun, 16 Jan 2022 06:45:30 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id YGkkCAq/42H0eQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 06:45:30 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e585290c-7697-11ec-a115-11989b9578b4
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642315530; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=ETpovp+31TFjCpvLCv0O3rPi8bZ/B9q/oQBK6QgCQZw=;
	b=UiJJ71mN31xttAy/iMQhq68XNaZdnpgNvD0TzGtyyO2EIE3iPFXgib1W9+yJWPQSQ/oQox
	I2FJmPbZOOf+bLTHJVTQD9uDVdJQ6lX8BX0dKtncWtSZhebT+NAAs/JbZfgarwrp0xR/6Z
	8RvYqQpo/1FF0GFIjzA0ytbkppLHLfk=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 3/5] remove file type FTYPE_XC
Date: Sun, 16 Jan 2022 07:45:25 +0100
Message-Id: <20220116064527.23519-4-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116064527.23519-1-jgross@suse.com>
References: <20220116064527.23519-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

The only reason for the file type FTYPE_XC has been gone long time
ago: it was needed for xc_map_foreign_bulk(), which has been switched
to use libxenforeignmemory and doesn't need this special file any
more.

So remove everything related to FTYPE_XC.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V2:
- new patch
V3:
- moved patch in series (Andrew Cooper)
---
 Config.mk                     |  1 -
 arch/x86/testbuild/all-no     |  1 -
 arch/x86/testbuild/all-yes    |  1 -
 arch/x86/testbuild/newxen-yes |  1 -
 include/lib.h                 |  1 -
 lib/sys.c                     | 13 -------------
 6 files changed, 18 deletions(-)

diff --git a/Config.mk b/Config.mk
index 5e660891..1e083881 100644
--- a/Config.mk
+++ b/Config.mk
@@ -197,7 +197,6 @@ CONFIG-n += CONFIG_PARAVIRT
 endif
 # Support legacy CONFIG_XC value
 CONFIG_XC ?= $(libc)
-CONFIG-$(CONFIG_XC) += CONFIG_LIBXENCTRL
 CONFIG-$(CONFIG_XC) += CONFIG_LIBXENEVTCHN
 CONFIG-$(CONFIG_XC) += CONFIG_LIBXENGNTTAB
 
diff --git a/arch/x86/testbuild/all-no b/arch/x86/testbuild/all-no
index 7972ecd5..d6fc2608 100644
--- a/arch/x86/testbuild/all-no
+++ b/arch/x86/testbuild/all-no
@@ -13,7 +13,6 @@ CONFIG_FBFRONT = n
 CONFIG_KBDFRONT = n
 CONFIG_CONSFRONT = n
 CONFIG_XENBUS = n
-CONFIG_LIBXENCTRL = n
 CONFIG_LIBXENEVTCHN = n
 CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/arch/x86/testbuild/all-yes b/arch/x86/testbuild/all-yes
index bc8eea57..98bbfebf 100644
--- a/arch/x86/testbuild/all-yes
+++ b/arch/x86/testbuild/all-yes
@@ -16,7 +16,6 @@ CONFIG_XENBUS = y
 CONFIG_BALLOON = y
 CONFIG_USE_XEN_CONSOLE = y
 # The following are special: they need support from outside
-CONFIG_LIBXENCTRL = n
 CONFIG_LIBXENEVTCHN = n
 CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/arch/x86/testbuild/newxen-yes b/arch/x86/testbuild/newxen-yes
index f72123b5..06032004 100644
--- a/arch/x86/testbuild/newxen-yes
+++ b/arch/x86/testbuild/newxen-yes
@@ -17,7 +17,6 @@ CONFIG_BALLOON = y
 CONFIG_USE_XEN_CONSOLE = y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
 # The following are special: they need support from outside
-CONFIG_LIBXENCTRL = n
 CONFIG_LIBXENEVTCHN = n
 CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/include/lib.h b/include/lib.h
index 7a0546bd..7ca90768 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -159,7 +159,6 @@ enum fd_type {
     FTYPE_CONSOLE,
     FTYPE_FILE,
     FTYPE_XENBUS,
-    FTYPE_XC,
     FTYPE_EVTCHN,
     FTYPE_GNTMAP,
     FTYPE_SOCKET,
diff --git a/lib/sys.c b/lib/sys.c
index 7df77cc6..a24687b7 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -87,7 +87,6 @@
     }
 
 #define NOFILE 32
-extern void minios_interface_close_fd(int fd);
 extern void minios_evtchn_close_fd(int fd);
 extern void minios_gnttab_close_fd(int fd);
 
@@ -443,11 +442,6 @@ int close(int fd)
             res = lwip_close(files[fd].fd);
             break;
 #endif
-#ifdef CONFIG_LIBXENCTRL
-	case FTYPE_XC:
-	    minios_interface_close_fd(fd);
-            break;
-#endif
 #ifdef CONFIG_LIBXENEVTCHN
 	case FTYPE_EVTCHN:
 	    minios_evtchn_close_fd(fd);
@@ -651,7 +645,6 @@ static const char file_types[] = {
     [FTYPE_NONE]	= 'N',
     [FTYPE_CONSOLE]	= 'C',
     [FTYPE_XENBUS]	= 'S',
-    [FTYPE_XC]		= 'X',
     [FTYPE_EVTCHN]	= 'E',
     [FTYPE_SOCKET]	= 's',
     [FTYPE_TAP]		= 'T',
@@ -1383,12 +1376,6 @@ void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset
 
     if (fd == -1)
         return map_zero(n, 1);
-#ifdef CONFIG_LIBXENCTRL
-    else if (files[fd].type == FTYPE_XC) {
-        unsigned long zero = 0;
-        return map_frames_ex(&zero, n, 0, 0, 1, DOMID_SELF, NULL, 0);
-    }
-#endif
     else if (files[fd].type == FTYPE_MEM) {
         unsigned long first_mfn = offset >> PAGE_SHIFT;
         return map_frames_ex(&first_mfn, n, 0, 1, 1, DOMID_IO, NULL, _PAGE_PRESENT|_PAGE_RW);
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 06:45:41 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 06:45:41 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257783.443110 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n8zIL-0001Zo-TW; Sun, 16 Jan 2022 06:45:41 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257783.443110; Sun, 16 Jan 2022 06:45:41 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n8zIL-0001Z7-NQ; Sun, 16 Jan 2022 06:45:41 +0000
Received: by outflank-mailman (input) for mailman id 257783;
 Sun, 16 Jan 2022 06:45:40 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n8zIK-0008SI-4q
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 06:45:40 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id e5a49238-7697-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 07:45:32 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 86B7F219C7;
 Sun, 16 Jan 2022 06:45:30 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 57CAB13350;
 Sun, 16 Jan 2022 06:45:30 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id qB8QFAq/42H0eQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 06:45:30 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e5a49238-7697-11ec-9bbc-9dff3e4ee8c5
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642315530; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=SkNjxyCrVquhfa9HVdl9OpDQbBK9fSye710YsOCgA5k=;
	b=byi+k86lKAlwts0BB/kn4fLt+/fUfhHyXnjWpmb29k86L6d3Wzq7iFCUOZMhp4HIfN68yF
	EVYMu+uQl+/iNqzSM3xIm1YM5YeV1YXvpa1/0QNCjoBurhvksv9w2s4txmrLcHjdIIU4np
	thDFnRVXY0ql92+APK8/YV5uN9B/JuI=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 4/5] use function vectors instead of switch for file operations
Date: Sun, 16 Jan 2022 07:45:26 +0100
Message-Id: <20220116064527.23519-5-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116064527.23519-1-jgross@suse.com>
References: <20220116064527.23519-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Introduce file type specific function vectors for all the needed file
operations which are file type specific in order to prepare replacing
the large switch statements in each generic file function.

Add a function to allocate a new file type dynamically in order to
prepare removing direct dependencies to external components in the
future. For this reason switch the file type from an enum to an
unsigned int. Prepare removal of some statically defines file types
by putting them at the end of the defined list.

Change the debug output for the file type from a single character to
a string in order to support a future removal of the file_types[]
array.

Provide some functions useful for file_ops in future patches.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V2:
- new patch
V3:
- drop typedefs for callbacks (Andrew Cooper)
- const (Andrew Cooper)
- drop loop from alloc_file_type() (Andrew Cooper)
- switch to struct file * as first parameter of callbacks (Andrew Cooper)
---
 include/lib.h |  57 +++++++----
 lib/sys.c     | 268 ++++++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 263 insertions(+), 62 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 7ca90768..44696806 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -66,6 +66,7 @@
 
 #ifdef HAVE_LIBC
 #include <sys/queue.h>
+#include <sys/stat.h>
 #include <stdio.h>
 #include <string.h>
 #else
@@ -154,23 +155,23 @@ do {                                                           \
 void sanity_check(void);
 
 #ifdef HAVE_LIBC
-enum fd_type {
-    FTYPE_NONE = 0,
-    FTYPE_CONSOLE,
-    FTYPE_FILE,
-    FTYPE_XENBUS,
-    FTYPE_EVTCHN,
-    FTYPE_GNTMAP,
-    FTYPE_SOCKET,
-    FTYPE_TAP,
-    FTYPE_BLK,
-    FTYPE_KBD,
-    FTYPE_FB,
-    FTYPE_MEM,
-    FTYPE_SAVEFILE,
-    FTYPE_TPMFRONT,
-    FTYPE_TPM_TIS,
-};
+#define FTYPE_NONE       0
+#define FTYPE_CONSOLE    1
+#define FTYPE_FILE       2
+#define FTYPE_SOCKET     3
+#define FTYPE_MEM        4
+#define FTYPE_SAVEFILE   5
+#define FTYPE_FB         6
+#define FTYPE_KBD        7
+#define FTYPE_TAP        8
+#define FTYPE_BLK        9
+#define FTYPE_TPMFRONT  10
+#define FTYPE_TPM_TIS   11
+#define FTYPE_XENBUS    12
+#define FTYPE_GNTMAP    13
+#define FTYPE_EVTCHN    14
+#define FTYPE_N         15
+#define FTYPE_SPARE     16
 
 LIST_HEAD(evtchn_port_list, evtchn_port_info);
 
@@ -182,7 +183,7 @@ struct evtchn_port_info {
 };
 
 struct file {
-    enum fd_type type;
+    unsigned int type;
     bool read;	/* maybe available for read */
     off_t offset;
     union {
@@ -197,8 +198,26 @@ struct file {
 
 extern struct file files[];
 
+struct file_ops {
+    const char *name;
+    int (*read)(struct file *file, void *buf, size_t nbytes);
+    int (*write)(struct file *file, const void *buf, size_t nbytes);
+    off_t (*lseek)(struct file *file, off_t offset, int whence);
+    int (*close)(struct file *file);
+    int (*fstat)(struct file *file, struct stat *buf);
+    int (*fcntl)(struct file *file, int cmd, va_list args);
+    bool (*select_rd)(struct file *file);
+    bool (*select_wr)(struct file *file);
+};
+
+unsigned int alloc_file_type(const struct file_ops *ops);
+
+off_t lseek_default(struct file *file, off_t offset, int whence);
+bool select_yes(struct file *file);
+bool select_read_flag(struct file *file);
+
 struct file *get_file_from_fd(int fd);
-int alloc_fd(enum fd_type type);
+int alloc_fd(unsigned int type);
 void close_all_files(void);
 extern struct thread *main_thread;
 void sparse(unsigned long data, size_t size);
diff --git a/lib/sys.c b/lib/sys.c
index a24687b7..7be01fd3 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -97,6 +97,40 @@ struct file files[NOFILE] = {
     { .type = FTYPE_CONSOLE }, /* stderr */
 };
 
+static const struct file_ops file_ops_none = {
+    .name = "none",
+};
+
+static const struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
+    [FTYPE_NONE] = &file_ops_none,
+};
+
+unsigned int alloc_file_type(const struct file_ops *ops)
+{
+    static unsigned int i = FTYPE_N;
+    unsigned int ret;
+
+    pthread_mutex_lock(&fd_lock);
+
+    BUG_ON(i == ARRAY_SIZE(file_ops));
+    ret = i++;
+    file_ops[ret] = ops;
+
+    pthread_mutex_unlock(&fd_lock);
+
+    printk("New file type \"%s\"(%u) allocated\n", ops->name, ret);
+
+    return ret;
+}
+
+static const struct file_ops *get_file_ops(unsigned int type)
+{
+    if ( type >= ARRAY_SIZE(file_ops) || !file_ops[type] )
+        return &file_ops_none;
+
+    return file_ops[type];
+}
+
 struct file *get_file_from_fd(int fd)
 {
     if ( fd < 0 || fd >= ARRAY_SIZE(files) )
@@ -107,7 +141,7 @@ struct file *get_file_from_fd(int fd)
 
 DECLARE_WAIT_QUEUE_HEAD(event_queue);
 
-int alloc_fd(enum fd_type type)
+int alloc_fd(unsigned int type)
 {
     int i;
     pthread_mutex_lock(&fd_lock);
@@ -248,7 +282,17 @@ int isatty(int fd)
 
 int read(int fd, void *buf, size_t nbytes)
 {
-    switch (files[fd].type) {
+    struct file *file = get_file_from_fd(fd);
+    const struct file_ops *ops;
+
+    if ( !file )
+        goto error;
+
+    ops = get_file_ops(file->type);
+    if ( ops->read )
+        return ops->read(file, buf, nbytes);
+
+    switch (file->type) {
         case FTYPE_SAVEFILE:
 	case FTYPE_CONSOLE: {
 	    int ret;
@@ -320,6 +364,8 @@ int read(int fd, void *buf, size_t nbytes)
 	default:
 	    break;
     }
+
+ error:
     printk("read(%d): Bad descriptor\n", fd);
     errno = EBADF;
     return -1;
@@ -327,7 +373,17 @@ int read(int fd, void *buf, size_t nbytes)
 
 int write(int fd, const void *buf, size_t nbytes)
 {
-    switch (files[fd].type) {
+    struct file *file = get_file_from_fd(fd);
+    const struct file_ops *ops;
+
+    if ( !file )
+        goto error;
+
+    ops = get_file_ops(file->type);
+    if ( ops->write )
+        return ops->write(file, buf, nbytes);
+
+    switch (file->type) {
         case FTYPE_SAVEFILE: {
                 int ret = 0, tot = nbytes;
                 while (nbytes > 0) {
@@ -364,14 +420,61 @@ int write(int fd, const void *buf, size_t nbytes)
 	default:
 	    break;
     }
+
+ error:
     printk("write(%d): Bad descriptor\n", fd);
     errno = EBADF;
     return -1;
 }
 
+off_t lseek_default(struct file *file, off_t offset, int whence)
+{
+    switch ( whence )
+    {
+    case SEEK_SET:
+        file->offset = offset;
+        break;
+
+    case SEEK_CUR:
+        file->offset += offset;
+        break;
+
+    case SEEK_END:
+    {
+        struct stat st;
+        int ret;
+
+        ret = fstat(file - files, &st);
+        if ( ret )
+            return -1;
+        file->offset = st.st_size + offset;
+        break;
+    }
+
+    default:
+        errno = EINVAL;
+        return -1;
+    }
+
+    return file->offset;
+}
+
 off_t lseek(int fd, off_t offset, int whence)
 {
-    switch(files[fd].type) {
+    struct file *file = get_file_from_fd(fd);
+    const struct file_ops *ops;
+
+    if ( !file )
+    {
+        errno = EBADF;
+        return (off_t)-1;
+    }
+
+    ops = get_file_ops(file->type);
+    if ( ops->lseek )
+        return ops->lseek(file, offset, whence);
+
+    switch(file->type) {
 #ifdef CONFIG_BLKFRONT
        case FTYPE_BLK:
           break;
@@ -392,28 +495,7 @@ off_t lseek(int fd, off_t offset, int whence)
           return (off_t) -1;
     }
 
-    switch (whence) {
-       case SEEK_SET:
-          files[fd].offset = offset;
-          break;
-       case SEEK_CUR:
-          files[fd].offset += offset;
-          break;
-       case SEEK_END:
-          {
-             struct stat st;
-             int ret;
-             ret = fstat(fd, &st);
-             if (ret)
-                return -1;
-             files[fd].offset = st.st_size + offset;
-             break;
-          }
-       default:
-          errno = EINVAL;
-          return -1;
-    }
-    return files[fd].offset;
+    return lseek_default(file, offset, whence);
 }
 
 int fsync(int fd) {
@@ -424,12 +506,21 @@ int fsync(int fd) {
 int close(int fd)
 {
     int res = 0;
+    struct file *file = get_file_from_fd(fd);
+    const struct file_ops *ops;
 
-    if ( fd < 0 || fd >= ARRAY_SIZE(files) )
+    if ( !file )
         goto error;
 
+    ops = get_file_ops(file->type);
     printk("close(%d)\n", fd);
-    switch (files[fd].type) {
+    if ( ops->close )
+    {
+        res = ops->close(file);
+        goto out;
+    }
+
+    switch (file->type) {
         default:
             break;
 #ifdef CONFIG_XENBUS
@@ -492,6 +583,7 @@ int close(int fd)
             goto error;
     }
 
+ out:
     memset(files + fd, 0, sizeof(struct file));
     BUILD_BUG_ON(FTYPE_NONE != 0);
 
@@ -522,8 +614,19 @@ int stat(const char *path, struct stat *buf)
 
 int fstat(int fd, struct stat *buf)
 {
+    struct file *file = get_file_from_fd(fd);
+    const struct file_ops *ops;
+
+    if ( !file )
+        goto error;
+
     init_stat(buf);
-    switch (files[fd].type) {
+
+    ops = get_file_ops(file->type);
+    if ( ops->fstat )
+        return ops->fstat(file, buf);
+
+    switch (file->type) {
 	case FTYPE_SAVEFILE:
 	case FTYPE_CONSOLE:
 	case FTYPE_SOCKET: {
@@ -557,6 +660,7 @@ int fstat(int fd, struct stat *buf)
 	    break;
     }
 
+ error:
     printk("statf(%d): Bad descriptor\n", fd);
     errno = EBADF;
     return -1;
@@ -588,6 +692,27 @@ int fcntl(int fd, int cmd, ...)
 {
     long arg;
     va_list ap;
+    int res;
+    struct file *file = get_file_from_fd(fd);
+    const struct file_ops *ops;
+
+    if ( !file )
+    {
+        errno = EBADF;
+        return -1;
+    }
+
+    ops = get_file_ops(files[fd].type);
+
+    if ( ops->fcntl )
+    {
+        va_start(ap, cmd);
+        res = ops->fcntl(file, cmd, ap);
+        va_end(ap);
+
+        return res;
+    }
+
     va_start(ap, cmd);
     arg = va_arg(ap, long);
     va_end(ap);
@@ -641,17 +766,28 @@ int closedir(DIR *dir)
 /* We assume that only the main thread calls select(). */
 
 #if defined(LIBC_DEBUG) || defined(LIBC_VERBOSE)
-static const char file_types[] = {
-    [FTYPE_NONE]	= 'N',
-    [FTYPE_CONSOLE]	= 'C',
-    [FTYPE_XENBUS]	= 'S',
-    [FTYPE_EVTCHN]	= 'E',
-    [FTYPE_SOCKET]	= 's',
-    [FTYPE_TAP]		= 'T',
-    [FTYPE_BLK]		= 'B',
-    [FTYPE_KBD]		= 'K',
-    [FTYPE_FB]		= 'G',
+static const char *const file_types[] = {
+    [FTYPE_NONE]    = "none",
+    [FTYPE_CONSOLE] = "console",
+    [FTYPE_XENBUS]  = "xenbus",
+    [FTYPE_EVTCHN]  = "evtchn",
+    [FTYPE_SOCKET]  = "socket",
+    [FTYPE_TAP]     = "net",
+    [FTYPE_BLK]     = "blk",
+    [FTYPE_KBD]     = "kbd",
+    [FTYPE_FB]      = "fb",
 };
+
+static const char *get_type_name(unsigned int type)
+{
+    if ( type < ARRAY_SIZE(file_ops) && file_ops[type] )
+        return file_ops[type]->name;
+
+    if ( type < ARRAY_SIZE(file_types) && file_types[type] )
+        return file_types[type];
+
+    return "none";
+}
 #endif
 #ifdef LIBC_DEBUG
 static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
@@ -663,7 +799,7 @@ static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *except
 	if (FD_ISSET(i, set)) { \
 	    if (comma) \
 		printk(", "); \
-	    printk("%d(%c)", i, file_types[files[i].type]); \
+            printk("%d(%s)", i, get_type_name(files[i].type)); \
 	    comma = 1; \
 	} \
     } \
@@ -697,7 +833,7 @@ static void dump_pollfds(struct pollfd *pfd, int nfds, int timeout)
         fd = pfd[i].fd;
         if (comma)
             printk(", ");
-        printk("%d(%c)/%02x", fd, file_types[files[fd].type],
+        printk("%d(%s)/%02x", fd, get_type_name(files[fd].type),
             pfd[i].events);
             comma = 1;
     }
@@ -709,6 +845,16 @@ static void dump_pollfds(struct pollfd *pfd, int nfds, int timeout)
 #define dump_pollfds(pfds, nfds, timeout)
 #endif
 
+bool select_yes(struct file *file)
+{
+    return true;
+}
+
+bool select_read_flag(struct file *file)
+{
+    return file->read;
+}
+
 /* Just poll without blocking */
 static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
 {
@@ -760,11 +906,47 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 
     /* Then see others as well. */
     for (i = 0; i < nfds; i++) {
-	switch(files[i].type) {
+        struct file *file = get_file_from_fd(i);
+
+        if ( !file )
+        {
+            FD_CLR(i, readfds);
+            FD_CLR(i, writefds);
+            FD_CLR(i, exceptfds);
+            continue;
+        }
+
+        switch(file->type) {
 	default:
+        {
+            const struct file_ops *ops = file_ops[file->type];
+
+            if ( ops )
+            {
+                if ( FD_ISSET(i, readfds) )
+                {
+                    if ( ops->select_rd && ops->select_rd(file) )
+                        n++;
+                    else
+                        FD_CLR(i, readfds);
+                }
+                if ( FD_ISSET(i, writefds) )
+                {
+                    if ( ops->select_wr && ops->select_wr(file) )
+                        n++;
+                    else
+                        FD_CLR(i, writefds);
+                }
+                FD_CLR(i, exceptfds);
+
+                break;
+            }
+
 	    if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
 		printk("bogus fd %d in select\n", i);
 	    /* Fallthrough.  */
+        }
+
 	case FTYPE_CONSOLE:
 	    if (FD_ISSET(i, readfds)) {
                 if (xencons_ring_avail(files[i].dev))
@@ -842,7 +1024,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 	printk("%d(%d): ", nb, sock_n);
 	for (i = 0; i < nfds; i++) {
 	    if (nbread[i] || nbwrite[i] || nbexcept[i])
-		printk(" %d(%c):", i, file_types[files[i].type]);
+                printk(" %d(%c):", i, get_type_name(files[i].type));
 	    if (nbread[i])
 	    	printk(" %dR", nbread[i]);
 	    if (nbwrite[i])
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 08:33:34 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 08:33:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257818.443169 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yi-0008J1-QS; Sun, 16 Jan 2022 08:33:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257818.443169; Sun, 16 Jan 2022 08:33:32 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yi-0008Im-Lp; Sun, 16 Jan 2022 08:33:32 +0000
Received: by outflank-mailman (input) for mailman id 257818;
 Sun, 16 Jan 2022 08:33:32 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n90yi-0008IQ-5i
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 08:33:32 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id fbdcf1d2-76a6-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 09:33:30 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id B8B4B1F3B3;
 Sun, 16 Jan 2022 08:33:30 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8EBD813AB5;
 Sun, 16 Jan 2022 08:33:30 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id ICuiIVrY42HyFQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 08:33:30 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fbdcf1d2-76a6-11ec-9bbc-9dff3e4ee8c5
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642322010; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=xMC2cVvglpwHtHj58DJ+I44rqFmTlB+K2cTWldEOzOc=;
	b=Z8BC/NvAOFa5H57kZB92bNQ6WlKFk3IuPrew6E4KfZN1ovw1oeBoQjyQgkNIioIqRzGK1A
	SJwPi+08i71eetf7eN6D54DfhGrY6P0BJWC61wBt8u/Jx5iwSNGOv5eQUaVritwbgzsub2
	4sLRrt8Cp3NThPxtOON3N+eG1KacYFw=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 01/12] remove event channel specific struct file definitions
Date: Sun, 16 Jan 2022 09:33:17 +0100
Message-Id: <20220116083328.26524-2-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116083328.26524-1-jgross@suse.com>
References: <20220116083328.26524-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

The event channel specific union member in struct file is no longer
needed, so remove it together with the associated structure
definitions.

The event channel file type and its associated handling can be removed,
too, as libxenevtchn is now supplying a struct file_ops via a call of
alloc_file_type().

This removes all contents of CONFIG_LIBXENEVTCHN guarded sections, so
this config option can be removed.

Add an extern declaration for event_queue as it is used by
libxenevtchn.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V3:
- add extern declaration for event_queue (Andrew Cooper)
---
 Config.mk                     |  1 -
 arch/x86/testbuild/all-no     |  1 -
 arch/x86/testbuild/all-yes    |  1 -
 arch/x86/testbuild/newxen-yes |  1 -
 include/lib.h                 | 17 +++--------------
 lib/sys.c                     |  7 -------
 6 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/Config.mk b/Config.mk
index 03023033..52eb26d8 100644
--- a/Config.mk
+++ b/Config.mk
@@ -200,7 +200,6 @@ CONFIG-n += CONFIG_PARAVIRT
 endif
 # Support legacy CONFIG_XC value
 CONFIG_XC ?= $(libc)
-CONFIG-$(CONFIG_XC) += CONFIG_LIBXENEVTCHN
 CONFIG-$(CONFIG_XC) += CONFIG_LIBXENGNTTAB
 
 CONFIG-$(lwip) += CONFIG_LWIP
diff --git a/arch/x86/testbuild/all-no b/arch/x86/testbuild/all-no
index 46f974de..15c954ff 100644
--- a/arch/x86/testbuild/all-no
+++ b/arch/x86/testbuild/all-no
@@ -14,7 +14,6 @@ CONFIG_KBDFRONT = n
 CONFIG_CONSFRONT = n
 CONFIG_XENBUS = n
 CONFIG_LIBXS = n
-CONFIG_LIBXENEVTCHN = n
 CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
 CONFIG_BALLOON = n
diff --git a/arch/x86/testbuild/all-yes b/arch/x86/testbuild/all-yes
index 3ead12f1..9964d42f 100644
--- a/arch/x86/testbuild/all-yes
+++ b/arch/x86/testbuild/all-yes
@@ -17,6 +17,5 @@ CONFIG_LIBXS = y
 CONFIG_BALLOON = y
 CONFIG_USE_XEN_CONSOLE = y
 # The following are special: they need support from outside
-CONFIG_LIBXENEVTCHN = n
 CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/arch/x86/testbuild/newxen-yes b/arch/x86/testbuild/newxen-yes
index 5c0b3c80..c2519938 100644
--- a/arch/x86/testbuild/newxen-yes
+++ b/arch/x86/testbuild/newxen-yes
@@ -18,6 +18,5 @@ CONFIG_BALLOON = y
 CONFIG_USE_XEN_CONSOLE = y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
 # The following are special: they need support from outside
-CONFIG_LIBXENEVTCHN = n
 CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/include/lib.h b/include/lib.h
index 44696806..5f24be5d 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -155,6 +155,8 @@ do {                                                           \
 void sanity_check(void);
 
 #ifdef HAVE_LIBC
+extern struct wait_queue_head event_queue;
+
 #define FTYPE_NONE       0
 #define FTYPE_CONSOLE    1
 #define FTYPE_FILE       2
@@ -169,19 +171,9 @@ void sanity_check(void);
 #define FTYPE_TPM_TIS   11
 #define FTYPE_XENBUS    12
 #define FTYPE_GNTMAP    13
-#define FTYPE_EVTCHN    14
-#define FTYPE_N         15
+#define FTYPE_N         14
 #define FTYPE_SPARE     16
 
-LIST_HEAD(evtchn_port_list, evtchn_port_info);
-
-struct evtchn_port_info {
-        LIST_ENTRY(evtchn_port_info) list;
-        evtchn_port_t port;
-        unsigned long pending;
-        int bound;
-};
-
 struct file {
     unsigned int type;
     bool read;	/* maybe available for read */
@@ -189,9 +181,6 @@ struct file {
     union {
         int fd; /* Any fd from an upper layer. */
         void *dev;
-	struct {
-	    struct evtchn_port_list ports;
-	} evtchn;
 	struct gntmap gntmap;
     };
 };
diff --git a/lib/sys.c b/lib/sys.c
index e0ac5099..34f0193d 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -533,11 +533,6 @@ int close(int fd)
             res = lwip_close(files[fd].fd);
             break;
 #endif
-#ifdef CONFIG_LIBXENEVTCHN
-	case FTYPE_EVTCHN:
-	    minios_evtchn_close_fd(fd);
-            break;
-#endif
 #ifdef CONFIG_LIBXENGNTTAB
 	case FTYPE_GNTMAP:
 	    minios_gnttab_close_fd(fd);
@@ -770,7 +765,6 @@ static const char *const file_types[] = {
     [FTYPE_NONE]    = "none",
     [FTYPE_CONSOLE] = "console",
     [FTYPE_XENBUS]  = "xenbus",
-    [FTYPE_EVTCHN]  = "evtchn",
     [FTYPE_SOCKET]  = "socket",
     [FTYPE_TAP]     = "net",
     [FTYPE_BLK]     = "blk",
@@ -970,7 +964,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 	    FD_CLR(i, exceptfds);
 	    break;
 #endif
-	case FTYPE_EVTCHN:
 	case FTYPE_TAP:
 	case FTYPE_BLK:
 	case FTYPE_KBD:
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 08:33:35 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 08:33:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257817.443166 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yi-0008If-Nt; Sun, 16 Jan 2022 08:33:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257817.443166; Sun, 16 Jan 2022 08:33:32 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yi-0008Ib-KL; Sun, 16 Jan 2022 08:33:32 +0000
Received: by outflank-mailman (input) for mailman id 257817;
 Sun, 16 Jan 2022 08:33:32 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n90yh-0008IP-Vi
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 08:33:31 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id fc1c0e24-76a6-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 09:33:31 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 9032E1F3B2;
 Sun, 16 Jan 2022 08:33:30 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5EFEB1346A;
 Sun, 16 Jan 2022 08:33:30 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 5EhsFVrY42HyFQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 08:33:30 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fc1c0e24-76a6-11ec-a115-11989b9578b4
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642322010; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:  content-transfer-encoding:content-transfer-encoding;
	bh=JI/T0GvQlHTteR5uYoRyKUlc2h5rd/vS7Yv8hXR+F9M=;
	b=guGamLRDLCwk3pjvKnmwEaH1VX6Xn0iiqV9S2TwgA3kXYajVrpCdiFNJ8ddo23GBzSfo9y
	RdsOewsy/234pfVUnfHwgABlXnN3OrVaGjNqSVDK0le/mOsKE88vZV+kSYI5zgDGPbcRNB
	RzSk4agvSNr709PNwWGhp1oQCqyunwc=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 00/12] remove device specific struct file members
Date: Sun, 16 Jan 2022 09:33:16 +0100
Message-Id: <20220116083328.26524-1-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

This series is a followup to the series sent recently:

https://lists.xen.org/archives/html/xen-devel/2022-01/threads.html#00635

It contains the last cleanups related to struct file and can only be
applied after the Xen libraries have stopped using the related union
members:

https://lists.xen.org/archives/html/xen-devel/2022-01/threads.html#00643

The three series applied have been tested to work with:

- xenstorepvh-stubdom
- pv-grub
- ioemu-stubdom

Changes in V3:
- comments addressed

Changes in V2:
- add many patches for using alloc_file_type() and struct file_ops

Juergen Gross (12):
  remove event channel specific struct file definitions
  remove gnttab specific member from struct file
  use alloc_file_type() and get_file_from_fd() in xs
  use alloc_file_type() and get_file_from_fd() in tpm_tis
  use alloc_file_type() and get_file_from_fd() in tpmfront
  use alloc_file_type() and get_file_from_fd() in blkfront
  use alloc_file_type() and get_file_from_fd() in netfront
  use alloc_file_type() and get_file_from_fd() in fbfront
  use file_ops and get_file_from_fd() for console
  add struct file_ops for file type socket
  add struct file_ops for FTYPE_FILE
  make files array private to sys.c

 Config.mk                     |   2 -
 arch/x86/testbuild/all-no     |   2 -
 arch/x86/testbuild/all-yes    |   2 -
 arch/x86/testbuild/newxen-yes |   2 -
 blkfront.c                    |  92 ++++++--
 console/console.c             |   2 +-
 console/xenbus.c              | 112 +++++++++
 console/xencons_ring.c        |   6 +-
 fbfront.c                     | 127 ++++++++--
 gntmap.c                      |   2 +-
 include/blkfront.h            |   5 -
 include/console.h             |   7 +-
 include/lib.h                 |  29 +--
 include/netfront.h            |   3 +-
 include/tpm_tis.h             |   6 -
 include/tpmfront.h            |   5 -
 lib/sys.c                     | 424 ++++++++--------------------------
 lib/xs.c                      |  65 ++++--
 netfront.c                    |  65 +++++-
 tpm_tis.c                     | 121 ++++++----
 tpmfront.c                    | 100 +++++---
 xenbus/xenbus.c               |   1 +
 22 files changed, 649 insertions(+), 531 deletions(-)

-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 08:33:35 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 08:33:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257821.443196 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yl-0000PP-E0; Sun, 16 Jan 2022 08:33:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257821.443196; Sun, 16 Jan 2022 08:33:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yl-0000P0-9U; Sun, 16 Jan 2022 08:33:35 +0000
Received: by outflank-mailman (input) for mailman id 257821;
 Sun, 16 Jan 2022 08:33:33 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n90yj-0008IP-OT
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 08:33:33 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id fc3fcfa4-76a6-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 09:33:31 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id E9384219A8;
 Sun, 16 Jan 2022 08:33:30 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BF0691346A;
 Sun, 16 Jan 2022 08:33:30 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id KKZoLVrY42HyFQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 08:33:30 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fc3fcfa4-76a6-11ec-a115-11989b9578b4
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642322010; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=qdHeJugvWS+GzJaTnlBhH4gNO7kfbGMjcepHl4bCr44=;
	b=NMXCYAVn3u48qz/nj5DiauAFFiSxg6SiVsgRSmzrrMeo41l5GGj4hKFz3UgACcl9kuH1qI
	PrZMTnIYatgYIgsZTiJOhz5ntI/xmkt8/0ITGZ9kNlFm4joLLK647eohlZkxocMw5P7rcW
	MXgVM7w2VUdrNRtyx2OmTa/txOY6OEg=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 02/12] remove gnttab specific member from struct file
Date: Sun, 16 Jan 2022 09:33:18 +0100
Message-Id: <20220116083328.26524-3-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116083328.26524-1-jgross@suse.com>
References: <20220116083328.26524-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

The gnttab specific union member in struct file is no longer
needed, so remove it.

The gnttab file type and its associated handling can be removed, too,
as libxengnttab is now supplying a struct file_ops via a call of
alloc_file_type().

This removes all contents of CONFIG_LIBXENGNTTAB guarded sections, so
this config option can be removed.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 Config.mk                     | 1 -
 arch/x86/testbuild/all-no     | 1 -
 arch/x86/testbuild/all-yes    | 1 -
 arch/x86/testbuild/newxen-yes | 1 -
 gntmap.c                      | 2 +-
 include/lib.h                 | 4 +---
 lib/sys.c                     | 5 -----
 7 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/Config.mk b/Config.mk
index 52eb26d8..1a24b30e 100644
--- a/Config.mk
+++ b/Config.mk
@@ -200,7 +200,6 @@ CONFIG-n += CONFIG_PARAVIRT
 endif
 # Support legacy CONFIG_XC value
 CONFIG_XC ?= $(libc)
-CONFIG-$(CONFIG_XC) += CONFIG_LIBXENGNTTAB
 
 CONFIG-$(lwip) += CONFIG_LWIP
 
diff --git a/arch/x86/testbuild/all-no b/arch/x86/testbuild/all-no
index 15c954ff..f79a1012 100644
--- a/arch/x86/testbuild/all-no
+++ b/arch/x86/testbuild/all-no
@@ -14,7 +14,6 @@ CONFIG_KBDFRONT = n
 CONFIG_CONSFRONT = n
 CONFIG_XENBUS = n
 CONFIG_LIBXS = n
-CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
 CONFIG_BALLOON = n
 CONFIG_USE_XEN_CONSOLE = n
diff --git a/arch/x86/testbuild/all-yes b/arch/x86/testbuild/all-yes
index 9964d42f..faa3af32 100644
--- a/arch/x86/testbuild/all-yes
+++ b/arch/x86/testbuild/all-yes
@@ -17,5 +17,4 @@ CONFIG_LIBXS = y
 CONFIG_BALLOON = y
 CONFIG_USE_XEN_CONSOLE = y
 # The following are special: they need support from outside
-CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/arch/x86/testbuild/newxen-yes b/arch/x86/testbuild/newxen-yes
index c2519938..dc83e670 100644
--- a/arch/x86/testbuild/newxen-yes
+++ b/arch/x86/testbuild/newxen-yes
@@ -18,5 +18,4 @@ CONFIG_BALLOON = y
 CONFIG_USE_XEN_CONSOLE = y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
 # The following are special: they need support from outside
-CONFIG_LIBXENGNTTAB = n
 CONFIG_LWIP = n
diff --git a/gntmap.c b/gntmap.c
index 6fa1dac1..3422ab23 100644
--- a/gntmap.c
+++ b/gntmap.c
@@ -3,7 +3,7 @@
  *
  * Diego Ongaro <diego.ongaro@citrix.com>, July 2008
  *
- * Files of type FTYPE_GNTMAP contain a gntmap, which is an array of
+ * Files of libxengnttab contain a gntmap, which is an array of
  * (host address, grant handle) pairs. Grant handles come from a hypervisor map
  * operation and are needed for the corresponding unmap.
  *
diff --git a/include/lib.h b/include/lib.h
index 5f24be5d..5838b0d4 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -170,8 +170,7 @@ extern struct wait_queue_head event_queue;
 #define FTYPE_TPMFRONT  10
 #define FTYPE_TPM_TIS   11
 #define FTYPE_XENBUS    12
-#define FTYPE_GNTMAP    13
-#define FTYPE_N         14
+#define FTYPE_N         13
 #define FTYPE_SPARE     16
 
 struct file {
@@ -181,7 +180,6 @@ struct file {
     union {
         int fd; /* Any fd from an upper layer. */
         void *dev;
-	struct gntmap gntmap;
     };
 };
 
diff --git a/lib/sys.c b/lib/sys.c
index 34f0193d..6ba26294 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -533,11 +533,6 @@ int close(int fd)
             res = lwip_close(files[fd].fd);
             break;
 #endif
-#ifdef CONFIG_LIBXENGNTTAB
-	case FTYPE_GNTMAP:
-	    minios_gnttab_close_fd(fd);
-            break;
-#endif
 #ifdef CONFIG_NETFRONT
 	case FTYPE_TAP:
 	    shutdown_netfront(files[fd].dev);
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 08:33:35 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 08:33:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257822.443199 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yl-0000Q8-He; Sun, 16 Jan 2022 08:33:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257822.443199; Sun, 16 Jan 2022 08:33:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yl-0000Pb-Ba; Sun, 16 Jan 2022 08:33:35 +0000
Received: by outflank-mailman (input) for mailman id 257822;
 Sun, 16 Jan 2022 08:33:34 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n90yj-0008IQ-UT
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 08:33:34 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id fc522c0f-76a6-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 09:33:31 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 8B1211F45F;
 Sun, 16 Jan 2022 08:33:31 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5D8631346A;
 Sun, 16 Jan 2022 08:33:31 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id GPWRFVvY42HyFQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 08:33:31 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fc522c0f-76a6-11ec-9bbc-9dff3e4ee8c5
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642322011; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=g38pTaT4/z9XKrWqRxaUROnYf4HhbDG2ikYR2ifx7WM=;
	b=mRfbTabA5NNamgetFyP0/9CEZSIsACvFyE7wvMvi7WZQbEwd9I8EF3FzbslncBWJJXw88t
	DLVcFBNXUSK0SMfQT7JY/zVBW3SfGKCWOv4WiPgKw9RX1iX+6xlAMHtYrLQNsSdh4IBZua
	pBg3lOrmPtV/d5YYpTTkDsRcNV0nAJc=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 05/12] use alloc_file_type() and get_file_from_fd() in tpmfront
Date: Sun, 16 Jan 2022 09:33:21 +0100
Message-Id: <20220116083328.26524-6-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116083328.26524-1-jgross@suse.com>
References: <20220116083328.26524-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Allocate a file type dynamically via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V3:
- switch to struct file * parameter for callbacks
- use __attribute__((constructor))
---
 include/lib.h      |   3 +-
 include/tpmfront.h |   5 ---
 lib/sys.c          |  23 -----------
 tpmfront.c         | 100 ++++++++++++++++++++++++++++++---------------
 4 files changed, 69 insertions(+), 62 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 9dfb4689..9b7eaae7 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -167,8 +167,7 @@ extern struct wait_queue_head event_queue;
 #define FTYPE_KBD        7
 #define FTYPE_TAP        8
 #define FTYPE_BLK        9
-#define FTYPE_TPMFRONT  10
-#define FTYPE_N         11
+#define FTYPE_N         10
 #define FTYPE_SPARE     16
 
 struct file {
diff --git a/include/tpmfront.h b/include/tpmfront.h
index b7da50e3..a527371b 100644
--- a/include/tpmfront.h
+++ b/include/tpmfront.h
@@ -81,7 +81,6 @@ int tpmfront_cmd(struct tpmfront_dev* dev, uint8_t* req, size_t reqlen, uint8_t*
 int tpmfront_set_locality(struct tpmfront_dev* dev, int locality);
 
 #ifdef HAVE_LIBC
-#include <sys/stat.h>
 /* POSIX IO functions:
  * use tpmfront_open() to get a file descriptor to the tpm device
  * use write() on the fd to send a command to the backend. You must
@@ -90,10 +89,6 @@ int tpmfront_set_locality(struct tpmfront_dev* dev, int locality);
  * fstat() to get the size of the response and lseek() to seek on it.
  */
 int tpmfront_open(struct tpmfront_dev* dev);
-int tpmfront_posix_read(int fd, uint8_t* buf, size_t count);
-int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count);
-int tpmfront_posix_fstat(int fd, struct stat* buf);
 #endif
 
-
 #endif
diff --git a/lib/sys.c b/lib/sys.c
index 2fc81f20..39f51980 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -28,7 +28,6 @@
 #include <netfront.h>
 #include <blkfront.h>
 #include <fbfront.h>
-#include <tpmfront.h>
 #include <xenbus.h>
 #include <xenstore.h>
 #include <poll.h>
@@ -349,11 +348,6 @@ int read(int fd, void *buf, size_t nbytes)
         case FTYPE_BLK: {
 	    return blkfront_posix_read(fd, buf, nbytes);
         }
-#endif
-#ifdef CONFIG_TPMFRONT
-        case FTYPE_TPMFRONT: {
-	    return tpmfront_posix_read(fd, buf, nbytes);
-        }
 #endif
 	default:
 	    break;
@@ -402,10 +396,6 @@ int write(int fd, const void *buf, size_t nbytes)
 #ifdef CONFIG_BLKFRONT
 	case FTYPE_BLK:
 	    return blkfront_posix_write(fd, buf, nbytes);
-#endif
-#ifdef CONFIG_TPMFRONT
-	case FTYPE_TPMFRONT:
-	    return tpmfront_posix_write(fd, buf, nbytes);
 #endif
 	default:
 	    break;
@@ -468,10 +458,6 @@ off_t lseek(int fd, off_t offset, int whence)
 #ifdef CONFIG_BLKFRONT
        case FTYPE_BLK:
           break;
-#endif
-#ifdef CONFIG_TPMFRONT
-       case FTYPE_TPMFRONT:
-          break;
 #endif
        case FTYPE_FILE:
           break;
@@ -524,11 +510,6 @@ int close(int fd)
             shutdown_blkfront(files[fd].dev);
             break;
 #endif
-#ifdef CONFIG_TPMFRONT
-	case FTYPE_TPMFRONT:
-            shutdown_tpmfront(files[fd].dev);
-            break;
-#endif
 #ifdef CONFIG_KBDFRONT
 	case FTYPE_KBD:
             shutdown_kbdfront(files[fd].dev);
@@ -613,10 +594,6 @@ int fstat(int fd, struct stat *buf)
 #ifdef CONFIG_BLKFRONT
 	case FTYPE_BLK:
 	   return blkfront_posix_fstat(fd, buf);
-#endif
-#ifdef CONFIG_TPMFRONT
-	case FTYPE_TPMFRONT:
-	   return tpmfront_posix_fstat(fd, buf);
 #endif
 	default:
 	    break;
diff --git a/tpmfront.c b/tpmfront.c
index 0a2fefc5..13163ad6 100644
--- a/tpmfront.c
+++ b/tpmfront.c
@@ -49,6 +49,10 @@
 void tpmfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) {
    struct tpmfront_dev* dev = (struct tpmfront_dev*) data;
    tpmif_shared_page_t *shr = dev->page;
+#ifdef HAVE_LIBC
+    struct file *file = get_file_from_fd(dev->fd);
+#endif
+
    /*If we get a response when we didnt make a request, just ignore it */
    if(!dev->waiting) {
       return;
@@ -65,8 +69,9 @@ void tpmfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) {
 
    dev->waiting = 0;
 #ifdef HAVE_LIBC
-   if(dev->fd >= 0) {
-      files[dev->fd].read = true;
+   if ( file )
+   {
+      file->read = true;
    }
 #endif
    wake_up(&dev->waitq);
@@ -405,6 +410,10 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
 #ifdef TPMFRONT_PRINT_DEBUG
    int i;
 #endif
+#ifdef HAVE_LIBC
+    struct file *file = dev ? get_file_from_fd(dev->fd) : NULL;
+#endif
+
    /* Error Checking */
    if(dev == NULL || dev->state != XenbusStateConnected) {
       TPMFRONT_ERR("Tried to send message through disconnected frontend\n");
@@ -437,9 +446,10 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
    dev->waiting = 1;
    dev->resplen = 0;
 #ifdef HAVE_LIBC
-   if(dev->fd >= 0) {
-      files[dev->fd].read = false;
-      files[dev->fd].offset = 0;
+   if ( file )
+   {
+      file->read = false;
+      file->offset = 0;
       dev->respgot = false;
    }
 #endif
@@ -529,25 +539,11 @@ int tpmfront_set_locality(struct tpmfront_dev* dev, int locality)
 
 #ifdef HAVE_LIBC
 #include <errno.h>
-int tpmfront_open(struct tpmfront_dev* dev)
-{
-   /* Silently prevent multiple opens */
-   if(dev->fd != -1) {
-      return dev->fd;
-   }
 
-   dev->fd = alloc_fd(FTYPE_TPMFRONT);
-   printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
-   files[dev->fd].dev = dev;
-   dev->respgot = false;
-   return dev->fd;
-}
-
-int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count)
+static int tpmfront_posix_write(struct file *file, const void *buf, size_t count)
 {
    int rc;
-   struct tpmfront_dev* dev;
-   dev = files[fd].dev;
+   struct tpmfront_dev *dev = file->dev;
 
    if(count == 0) {
       return 0;
@@ -566,14 +562,12 @@ int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count)
    return count;
 }
 
-int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
+static int tpmfront_posix_read(struct file *file, void *buf, size_t count)
 {
    int rc;
    uint8_t* dummybuf;
    size_t dummysz;
-   struct tpmfront_dev* dev;
-
-   dev = files[fd].dev;
+   struct tpmfront_dev *dev = file->dev;
 
    if(count == 0) {
       return 0;
@@ -588,29 +582,32 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
    }
 
    /* handle EOF case */
-   if(files[dev->fd].offset >= dev->resplen) {
+   if ( file->offset >= dev->resplen )
+   {
       return 0;
    }
 
    /* Compute the number of bytes and do the copy operation */
-   if((rc = min(count, dev->resplen - files[dev->fd].offset)) != 0) {
-      memcpy(buf, dev->respbuf + files[dev->fd].offset, rc);
-      files[dev->fd].offset += rc;
+   if ( (rc = min(count, dev->resplen - file->offset)) != 0 )
+   {
+      memcpy(buf, dev->respbuf + file->offset, rc);
+      file->offset += rc;
    }
 
    return rc;
 }
 
-int tpmfront_posix_fstat(int fd, struct stat* buf)
+static int tpmfront_posix_fstat(struct file *file, struct stat *buf)
 {
    uint8_t* dummybuf;
    size_t dummysz;
    int rc;
-   struct tpmfront_dev* dev = files[fd].dev;
+   struct tpmfront_dev *dev = file->dev;
 
    /* If we have a response waiting, then read it now from the backend
     * so we can get its length*/
-   if(dev->waiting || (files[dev->fd].read && !dev->respgot)) {
+   if ( dev->waiting || (file->read && !dev->respgot) )
+   {
       if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
 	 errno = EIO;
 	 return -1;
@@ -626,5 +623,44 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
    return 0;
 }
 
+static int tpmfront_close_fd(struct file *file)
+{
+    shutdown_tpmfront(file->dev);
+
+    return 0;
+}
+
+static const struct file_ops tpmfront_ops = {
+    .name = "tpmfront",
+    .read = tpmfront_posix_read,
+    .write = tpmfront_posix_write,
+    .lseek = lseek_default,
+    .close = tpmfront_close_fd,
+    .fstat = tpmfront_posix_fstat,
+};
+
+static unsigned int ftype_tpmfront;
+
+__attribute__((constructor))
+static void tpmfront_initialize(void)
+{
+    ftype_tpmfront = alloc_file_type(&tpmfront_ops);
+}
+
+int tpmfront_open(struct tpmfront_dev *dev)
+{
+    struct file *file;
+
+    /* Silently prevent multiple opens */
+    if ( dev->fd != -1 )
+        return dev->fd;
+
+    dev->fd = alloc_fd(ftype_tpmfront);
+    printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
+    file = get_file_from_fd(dev->fd);
+    file->dev = dev;
+    dev->respgot = false;
+    return dev->fd;
+}
 
 #endif
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 08:33:37 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 08:33:37 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257825.443217 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yn-0000kV-Qp; Sun, 16 Jan 2022 08:33:37 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257825.443217; Sun, 16 Jan 2022 08:33:37 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yn-0000j7-F9; Sun, 16 Jan 2022 08:33:37 +0000
Received: by outflank-mailman (input) for mailman id 257825;
 Sun, 16 Jan 2022 08:33:35 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n90yl-0008IP-Oi
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 08:33:35 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id fc5c7437-76a6-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 09:33:31 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 24AED219C7;
 Sun, 16 Jan 2022 08:33:31 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EEDB31346A;
 Sun, 16 Jan 2022 08:33:30 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id gFAeOVrY42HyFQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 08:33:30 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fc5c7437-76a6-11ec-a115-11989b9578b4
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642322011; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=BA1FXffCj1pRX9eT2SPzxm7/juZIBKAdcFoxvIMicZM=;
	b=p2M7YRDOPXHlt5FZ7r0mAq2b0Nt69Rb574mg1OrScenyE0vv73xEFn8qZ2lnkAwV6L9w4o
	NPamkQW6L776NZGmgt628jaUlrzJ6T+R49bG1iL7Hda0EqkYGGc+tOItb56DTjAmx2N7Im
	J8urN7vxH3savtG1N9kPKesKhVjNwj4=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 03/12] use alloc_file_type() and get_file_from_fd() in xs
Date: Sun, 16 Jan 2022 09:33:19 +0100
Message-Id: <20220116083328.26524-4-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116083328.26524-1-jgross@suse.com>
References: <20220116083328.26524-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Allocate the needed file type via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V3:
- switch to struct file * parameter for callbacks
- use __attribute__((constructor))
---
 include/lib.h   |  3 +--
 lib/sys.c       | 18 --------------
 lib/xs.c        | 65 +++++++++++++++++++++++++++++++++++++------------
 xenbus/xenbus.c |  1 +
 4 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 5838b0d4..c5e47786 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -169,8 +169,7 @@ extern struct wait_queue_head event_queue;
 #define FTYPE_BLK        9
 #define FTYPE_TPMFRONT  10
 #define FTYPE_TPM_TIS   11
-#define FTYPE_XENBUS    12
-#define FTYPE_N         13
+#define FTYPE_N         12
 #define FTYPE_SPARE     16
 
 struct file {
diff --git a/lib/sys.c b/lib/sys.c
index 6ba26294..53870aa4 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -523,11 +523,6 @@ int close(int fd)
     switch (file->type) {
         default:
             break;
-#ifdef CONFIG_LIBXS
-	case FTYPE_XENBUS:
-            xs_daemon_close((void*)(intptr_t) fd);
-            break;
-#endif
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
             res = lwip_close(files[fd].fd);
@@ -759,7 +754,6 @@ int closedir(DIR *dir)
 static const char *const file_types[] = {
     [FTYPE_NONE]    = "none",
     [FTYPE_CONSOLE] = "console",
-    [FTYPE_XENBUS]  = "xenbus",
     [FTYPE_SOCKET]  = "socket",
     [FTYPE_TAP]     = "net",
     [FTYPE_BLK]     = "blk",
@@ -947,18 +941,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
                 n++;
 	    FD_CLR(i, exceptfds);
 	    break;
-#ifdef CONFIG_LIBXS
-	case FTYPE_XENBUS:
-	    if (FD_ISSET(i, readfds)) {
-                if (files[i].dev)
-		    n++;
-		else
-		    FD_CLR(i, readfds);
-	    }
-	    FD_CLR(i, writefds);
-	    FD_CLR(i, exceptfds);
-	    break;
-#endif
 	case FTYPE_TAP:
 	case FTYPE_BLK:
 	case FTYPE_KBD:
diff --git a/lib/xs.c b/lib/xs.c
index 4af0f960..c12341aa 100644
--- a/lib/xs.c
+++ b/lib/xs.c
@@ -18,23 +18,56 @@ static inline int _xs_fileno(struct xs_handle *h) {
     return (intptr_t) h;
 }
 
+static int xs_close_fd(struct file *file)
+{
+    struct xenbus_event *event, *next;
+
+    for (event = file->dev; event; event = next)
+    {
+        next = event->next;
+        free(event);
+    }
+
+    return 0;
+}
+
+static bool xs_can_read(struct file *file)
+{
+    return file && file->dev;
+}
+
+static const struct file_ops xenbus_ops = {
+    .name = "xenbus",
+    .close = xs_close_fd,
+    .select_rd = xs_can_read,
+};
+
+static unsigned int ftype_xenbus;
+
+__attribute__((constructor))
+static void xs_initialize(void)
+{
+    ftype_xenbus = alloc_file_type(&xenbus_ops);
+}
+
 struct xs_handle *xs_daemon_open()
 {
-    int fd = alloc_fd(FTYPE_XENBUS);
-    files[fd].dev = NULL;
-    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].dev);
+    int fd;
+    struct file *file;
+
+    fd = alloc_fd(ftype_xenbus);
+    file = get_file_from_fd(fd);
+    if ( !file )
+        return NULL;
+
+    file->dev = NULL;
+    printk("xs_daemon_open -> %d, %p\n", fd, &file->dev);
     return (void*)(intptr_t) fd;
 }
 
 void xs_daemon_close(struct xs_handle *h)
 {
-    int fd = _xs_fileno(h);
-    struct xenbus_event *event, *next;
-    for (event = files[fd].dev; event; event = next)
-    {
-        next = event->next;
-        free(event);
-    }
+    close(_xs_fileno(h));
 }
 
 int xs_fileno(struct xs_handle *h)
@@ -169,18 +202,20 @@ char **xs_directory(struct xs_handle *h, xs_transaction_t t,
 
 bool xs_watch(struct xs_handle *h, const char *path, const char *token)
 {
-    int fd = _xs_fileno(h);
+    struct file *file = get_file_from_fd(_xs_fileno(h));
+
     printk("xs_watch(%s, %s)\n", path, token);
     return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token,
-                   (xenbus_event_queue *)&files[fd].dev));
+                   (xenbus_event_queue *)&file->dev));
 }
 
 char **xs_read_watch(struct xs_handle *h, unsigned int *num)
 {
-    int fd = _xs_fileno(h);
     struct xenbus_event *event;
-    event = files[fd].dev;
-    files[fd].dev = event->next;
+    struct file *file = get_file_from_fd(_xs_fileno(h));
+
+    event = file->dev;
+    file->dev = event->next;
     printk("xs_read_watch() -> %s %s\n", event->path, event->token);
     *num = 2;
     return (char **) &event->path;
diff --git a/xenbus/xenbus.c b/xenbus/xenbus.c
index b687678f..785389fb 100644
--- a/xenbus/xenbus.c
+++ b/xenbus/xenbus.c
@@ -393,6 +393,7 @@ static int allocate_xenbus_id(void)
 void init_xenbus(void)
 {
     int err;
+
     DEBUG("init_xenbus called.\n");
     create_thread("xenstore", xenbus_thread_func, NULL);
     DEBUG("buf at %p.\n", xenstore_buf);
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 08:33:38 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 08:33:38 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257826.443221 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yo-0000l3-4M; Sun, 16 Jan 2022 08:33:38 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257826.443221; Sun, 16 Jan 2022 08:33:38 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yn-0000jq-II; Sun, 16 Jan 2022 08:33:37 +0000
Received: by outflank-mailman (input) for mailman id 257826;
 Sun, 16 Jan 2022 08:33:36 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n90yl-0008IQ-Ub
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 08:33:36 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id fc710686-76a6-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 09:33:31 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id BB119219C8;
 Sun, 16 Jan 2022 08:33:31 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 90E761346A;
 Sun, 16 Jan 2022 08:33:31 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id WGg2IlvY42HyFQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 08:33:31 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fc710686-76a6-11ec-9bbc-9dff3e4ee8c5
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642322011; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=FFReguV4y++M9NUukSuxH+eG17KkgvbSsHOjbRhtUks=;
	b=Tr9a4POanzkbMhoSmBb9h3eLdK4XMXem0XTRAILtKVbPbd7bIfhWz0s/QaNk8tZqOsGTlo
	EVCVbE8P9WVFwY3Lik4axLUHqEHsO5egyd7uP/sHOKsqwJthNdpTdQzEDx0WjIkewfB7Yo
	99Jd+/ggIcGKXO6YS2qbjKUch7gFsR8=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 06/12] use alloc_file_type() and get_file_from_fd() in blkfront
Date: Sun, 16 Jan 2022 09:33:22 +0100
Message-Id: <20220116083328.26524-7-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116083328.26524-1-jgross@suse.com>
References: <20220116083328.26524-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Allocate the file type dynamically via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V3:
- switch to struct file * parameter for callbacks
- use __attribute__((constructor))
---
 blkfront.c         | 92 ++++++++++++++++++++++++++++++++++------------
 include/blkfront.h |  5 ---
 include/lib.h      |  3 +-
 lib/sys.c          | 24 ------------
 4 files changed, 69 insertions(+), 55 deletions(-)

diff --git a/blkfront.c b/blkfront.c
index e3f42bef..ed902702 100644
--- a/blkfront.c
+++ b/blkfront.c
@@ -59,10 +59,10 @@ void blkfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
 {
 #ifdef HAVE_LIBC
     struct blkfront_dev *dev = data;
-    int fd = dev->fd;
+    struct file *file = get_file_from_fd(dev->fd);
 
-    if (fd != -1)
-        files[fd].read = true;
+    if ( file )
+        file->read = true;
 #endif
     wake_up(&blkfront_queue);
 }
@@ -483,9 +483,13 @@ int blkfront_aio_poll(struct blkfront_dev *dev)
 
 moretodo:
 #ifdef HAVE_LIBC
-    if (dev->fd != -1) {
-        files[dev->fd].read = false;
-        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
+    {
+        struct file *file = get_file_from_fd(dev->fd);
+
+        if ( file ) {
+            file->read = false;
+            mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
+        }
     }
 #endif
 
@@ -554,22 +558,11 @@ moretodo:
 }
 
 #ifdef HAVE_LIBC
-int blkfront_open(struct blkfront_dev *dev)
+static int blkfront_posix_rwop(struct file *file, uint8_t *buf, size_t count,
+                               bool write)
 {
-    /* Silently prevent multiple opens */
-    if(dev->fd != -1) {
-       return dev->fd;
-    }
-    dev->fd = alloc_fd(FTYPE_BLK);
-    printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].dev = dev;
-    return dev->fd;
-}
-
-int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
-{
-   struct blkfront_dev* dev = files[fd].dev;
-   off_t offset = files[fd].offset;
+   struct blkfront_dev *dev = file->dev;
+   off_t offset = file->offset;
    struct blkfront_aiocb aiocb;
    unsigned long long disksize = dev->info.sectors * dev->info.sector_size;
    unsigned int blocksize = dev->info.sector_size;
@@ -711,14 +704,24 @@ int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
    }
 
    free(copybuf);
-   files[fd].offset += rc;
+   file->offset += rc;
    return rc;
 
 }
 
-int blkfront_posix_fstat(int fd, struct stat* buf)
+static int blkfront_posix_read(struct file *file, void *buf, size_t nbytes)
 {
-   struct blkfront_dev* dev = files[fd].dev;
+    return blkfront_posix_rwop(file, buf, nbytes, false);
+}
+
+static int blkfront_posix_write(struct file *file, const void *buf, size_t nbytes)
+{
+    return blkfront_posix_rwop(file, (void *)buf, nbytes, true);
+}
+
+static int blkfront_posix_fstat(struct file *file, struct stat *buf)
+{
+   struct blkfront_dev *dev = file->dev;
 
    buf->st_mode = dev->info.mode;
    buf->st_uid = 0;
@@ -728,4 +731,45 @@ int blkfront_posix_fstat(int fd, struct stat* buf)
 
    return 0;
 }
+
+static int blkfront_close_fd(struct file *file)
+{
+    shutdown_blkfront(file->dev);
+
+    return 0;
+}
+
+static const struct file_ops blk_ops = {
+    .name = "blk",
+    .read = blkfront_posix_read,
+    .write = blkfront_posix_write,
+    .lseek = lseek_default,
+    .close = blkfront_close_fd,
+    .fstat = blkfront_posix_fstat,
+    .select_rd = select_read_flag,
+};
+
+static unsigned int ftype_blk;
+
+__attribute__((constructor))
+static void blkfron_initialize(void)
+{
+    ftype_blk = alloc_file_type(&blk_ops);
+}
+
+int blkfront_open(struct blkfront_dev *dev)
+{
+    struct file *file;
+
+    /* Silently prevent multiple opens */
+    if ( dev->fd != -1 )
+        return dev->fd;
+
+    dev->fd = alloc_fd(ftype_blk);
+    printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
+    file = get_file_from_fd(dev->fd);
+    file->dev = dev;
+
+    return dev->fd;
+}
 #endif
diff --git a/include/blkfront.h b/include/blkfront.h
index 3528af9d..7f84a0a2 100644
--- a/include/blkfront.h
+++ b/include/blkfront.h
@@ -28,17 +28,12 @@ struct blkfront_info
 };
 struct blkfront_dev *init_blkfront(char *nodename, struct blkfront_info *info);
 #ifdef HAVE_LIBC
-#include <sys/stat.h>
 /* POSIX IO functions:
  * use blkfront_open() to get a file descriptor to the block device
  * Don't use the other blkfront posix functions here directly, instead use
  * read(), write(), lseek() and fstat() on the file descriptor
  */
 int blkfront_open(struct blkfront_dev *dev);
-int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write);
-#define blkfront_posix_write(fd, buf, count) blkfront_posix_rwop(fd, (uint8_t*)buf, count, 1)
-#define blkfront_posix_read(fd, buf, count) blkfront_posix_rwop(fd, (uint8_t*)buf, count, 0)
-int blkfront_posix_fstat(int fd, struct stat* buf);
 #endif
 void blkfront_aio(struct blkfront_aiocb *aiocbp, int write);
 #define blkfront_aio_read(aiocbp) blkfront_aio(aiocbp, 0)
diff --git a/include/lib.h b/include/lib.h
index 9b7eaae7..2f472b00 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -166,8 +166,7 @@ extern struct wait_queue_head event_queue;
 #define FTYPE_FB         6
 #define FTYPE_KBD        7
 #define FTYPE_TAP        8
-#define FTYPE_BLK        9
-#define FTYPE_N         10
+#define FTYPE_N          9
 #define FTYPE_SPARE     16
 
 struct file {
diff --git a/lib/sys.c b/lib/sys.c
index 39f51980..90684335 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -343,11 +343,6 @@ int read(int fd, void *buf, size_t nbytes)
 	    }
 	    return ret * sizeof(union xenfb_in_event);
         }
-#endif
-#ifdef CONFIG_BLKFRONT
-        case FTYPE_BLK: {
-	    return blkfront_posix_read(fd, buf, nbytes);
-        }
 #endif
 	default:
 	    break;
@@ -392,10 +387,6 @@ int write(int fd, const void *buf, size_t nbytes)
 	case FTYPE_TAP:
 	    netfront_xmit(files[fd].dev, (void*) buf, nbytes);
 	    return nbytes;
-#endif
-#ifdef CONFIG_BLKFRONT
-	case FTYPE_BLK:
-	    return blkfront_posix_write(fd, buf, nbytes);
 #endif
 	default:
 	    break;
@@ -455,10 +446,6 @@ off_t lseek(int fd, off_t offset, int whence)
         return ops->lseek(file, offset, whence);
 
     switch(file->type) {
-#ifdef CONFIG_BLKFRONT
-       case FTYPE_BLK:
-          break;
-#endif
        case FTYPE_FILE:
           break;
        default:
@@ -505,11 +492,6 @@ int close(int fd)
 	    shutdown_netfront(files[fd].dev);
             break;
 #endif
-#ifdef CONFIG_BLKFRONT
-	case FTYPE_BLK:
-            shutdown_blkfront(files[fd].dev);
-            break;
-#endif
 #ifdef CONFIG_KBDFRONT
 	case FTYPE_KBD:
             shutdown_kbdfront(files[fd].dev);
@@ -591,10 +573,6 @@ int fstat(int fd, struct stat *buf)
 	    buf->st_ctime = time(NULL);
 	    return 0;
 	}
-#ifdef CONFIG_BLKFRONT
-	case FTYPE_BLK:
-	   return blkfront_posix_fstat(fd, buf);
-#endif
 	default:
 	    break;
     }
@@ -710,7 +688,6 @@ static const char *const file_types[] = {
     [FTYPE_CONSOLE] = "console",
     [FTYPE_SOCKET]  = "socket",
     [FTYPE_TAP]     = "net",
-    [FTYPE_BLK]     = "blk",
     [FTYPE_KBD]     = "kbd",
     [FTYPE_FB]      = "fb",
 };
@@ -896,7 +873,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 	    FD_CLR(i, exceptfds);
 	    break;
 	case FTYPE_TAP:
-	case FTYPE_BLK:
 	case FTYPE_KBD:
 	case FTYPE_FB:
 	    if (FD_ISSET(i, readfds)) {
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 08:33:41 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 08:33:41 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257830.443245 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yr-0001PE-FF; Sun, 16 Jan 2022 08:33:41 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257830.443245; Sun, 16 Jan 2022 08:33:41 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yq-0001Nw-PM; Sun, 16 Jan 2022 08:33:40 +0000
Received: by outflank-mailman (input) for mailman id 257830;
 Sun, 16 Jan 2022 08:33:38 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n90yn-0008IP-P5
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 08:33:37 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id fc7d0c98-76a6-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 09:33:31 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 575631F3B4;
 Sun, 16 Jan 2022 08:33:31 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2AF791346A;
 Sun, 16 Jan 2022 08:33:31 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 0Dc/CVvY42HyFQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 08:33:31 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fc7d0c98-76a6-11ec-a115-11989b9578b4
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642322011; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=z5ZEOSnl4Zm8BpIud/3/sxMgQuEGzQWgZcmgMQmThgA=;
	b=ta1KHt3mzpfTtqE/kK0s7Nq6GcCZ9DhxscohOKSJKKR4HZGpCUC5gtscn6x05/+MQfLiOr
	noUHikursRXc+lnUIl1rLfXai2fiBhdO82FHfX0VTD4MzDW3GF7tKvc1K4Ps5ZB0yn9oCb
	sGx7gjigrhbi4xQJEcIlnh3lr3PGzgY=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 04/12] use alloc_file_type() and get_file_from_fd() in tpm_tis
Date: Sun, 16 Jan 2022 09:33:20 +0100
Message-Id: <20220116083328.26524-5-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116083328.26524-1-jgross@suse.com>
References: <20220116083328.26524-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Allocate a file type dynamically via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Make some now local functions static and modify their prototypes to
match the file_ops requirements.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V3:
- switch to struct file * parameter for callbacks
- use __attribute__((constructor))
---
 include/lib.h     |   3 +-
 include/tpm_tis.h |   6 ---
 lib/sys.c         |  23 ---------
 tpm_tis.c         | 121 +++++++++++++++++++++++++++++-----------------
 4 files changed, 78 insertions(+), 75 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index c5e47786..9dfb4689 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -168,8 +168,7 @@ extern struct wait_queue_head event_queue;
 #define FTYPE_TAP        8
 #define FTYPE_BLK        9
 #define FTYPE_TPMFRONT  10
-#define FTYPE_TPM_TIS   11
-#define FTYPE_N         12
+#define FTYPE_N         11
 #define FTYPE_SPARE     16
 
 struct file {
diff --git a/include/tpm_tis.h b/include/tpm_tis.h
index 86e83f13..2af974db 100644
--- a/include/tpm_tis.h
+++ b/include/tpm_tis.h
@@ -37,14 +37,11 @@ struct tpm_chip;
 
 struct tpm_chip* init_tpm_tis(unsigned long baseaddr, int localities, unsigned int irq);
 struct tpm_chip* init_tpm2_tis(unsigned long baseaddr, int localities, unsigned int irq);
-void shutdown_tpm_tis(struct tpm_chip* tpm);
 
 int tpm_tis_request_locality(struct tpm_chip* tpm, int locality);
 int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** resp, size_t* resplen);
 
 #ifdef HAVE_LIBC
-#include <sys/stat.h>
-#include <fcntl.h>
 /* POSIX IO functions:
  * use tpm_tis_open() to get a file descriptor to the tpm device
  * use write() on the fd to send a command to the backend. You must
@@ -53,9 +50,6 @@ int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** res
  * fstat() to get the size of the response and lseek() to seek on it.
  */
 int tpm_tis_open(struct tpm_chip* tpm);
-int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count);
-int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count);
-int tpm_tis_posix_fstat(int fd, struct stat* buf);
 #endif
 
 #endif
diff --git a/lib/sys.c b/lib/sys.c
index 53870aa4..2fc81f20 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -29,7 +29,6 @@
 #include <blkfront.h>
 #include <fbfront.h>
 #include <tpmfront.h>
-#include <tpm_tis.h>
 #include <xenbus.h>
 #include <xenstore.h>
 #include <poll.h>
@@ -355,11 +354,6 @@ int read(int fd, void *buf, size_t nbytes)
         case FTYPE_TPMFRONT: {
 	    return tpmfront_posix_read(fd, buf, nbytes);
         }
-#endif
-#ifdef CONFIG_TPM_TIS
-        case FTYPE_TPM_TIS: {
-	    return tpm_tis_posix_read(fd, buf, nbytes);
-        }
 #endif
 	default:
 	    break;
@@ -412,10 +406,6 @@ int write(int fd, const void *buf, size_t nbytes)
 #ifdef CONFIG_TPMFRONT
 	case FTYPE_TPMFRONT:
 	    return tpmfront_posix_write(fd, buf, nbytes);
-#endif
-#ifdef CONFIG_TPM_TIS
-	case FTYPE_TPM_TIS:
-	    return tpm_tis_posix_write(fd, buf, nbytes);
 #endif
 	default:
 	    break;
@@ -482,10 +472,6 @@ off_t lseek(int fd, off_t offset, int whence)
 #ifdef CONFIG_TPMFRONT
        case FTYPE_TPMFRONT:
           break;
-#endif
-#ifdef CONFIG_TPM_TIS
-       case FTYPE_TPM_TIS:
-          break;
 #endif
        case FTYPE_FILE:
           break;
@@ -543,11 +529,6 @@ int close(int fd)
             shutdown_tpmfront(files[fd].dev);
             break;
 #endif
-#ifdef CONFIG_TPM_TIS
-	case FTYPE_TPM_TIS:
-            shutdown_tpm_tis(files[fd].dev);
-            break;
-#endif
 #ifdef CONFIG_KBDFRONT
 	case FTYPE_KBD:
             shutdown_kbdfront(files[fd].dev);
@@ -636,10 +617,6 @@ int fstat(int fd, struct stat *buf)
 #ifdef CONFIG_TPMFRONT
 	case FTYPE_TPMFRONT:
 	   return tpmfront_posix_fstat(fd, buf);
-#endif
-#ifdef CONFIG_TPM_TIS
-	case FTYPE_TPM_TIS:
-	   return tpm_tis_posix_fstat(fd, buf);
 #endif
 	default:
 	    break;
diff --git a/tpm_tis.c b/tpm_tis.c
index 477f5550..b88ec874 100644
--- a/tpm_tis.c
+++ b/tpm_tis.c
@@ -792,6 +792,9 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
    int status, burstcnt = 0;
    int count = 0;
    uint32_t ordinal;
+#ifdef HAVE_LIBC
+   struct file *file = get_file_from_fd(tpm->fd);
+#endif
 
    if(tpm_tis_request_locality(tpm, tpm->locality) < 0) {
       return -EBUSY;
@@ -844,9 +847,10 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
       }
    }
 #ifdef HAVE_LIBC
-   if(tpm->fd >= 0) {
-      files[tpm->fd].read = false;
-      files[tpm->fd].offset = 0;
+   if ( file )
+   {
+      file->read = false;
+      file->offset = 0;
    }
 #endif
    return len;
@@ -1093,6 +1097,26 @@ ssize_t tpm_getcap(struct tpm_chip *chip, uint32_t subcap_id, cap_t *cap,
         return rc;
 }
 
+static void shutdown_tpm_tis(struct tpm_chip *tpm)
+{
+    int i;
+
+    printk("Shutting down tpm_tis device\n");
+
+    iowrite32(TPM_INT_ENABLE(tpm, tpm->locality), ~TPM_GLOBAL_INT_ENABLE);
+
+    /* Unmap all of the mmio pages */
+    for ( i = 0; i < 5; ++i )
+    {
+        if ( tpm->pages[i] != NULL )
+        {
+            iounmap(tpm->pages[i], PAGE_SIZE);
+            tpm->pages[i] = NULL;
+        }
+    }
+    free(tpm);
+    return;
+}
 
 struct tpm_chip* init_tpm_tis(unsigned long baseaddr, int localities, unsigned int irq)
 {
@@ -1242,25 +1266,6 @@ abort_egress:
    return NULL;
 }
 
-void shutdown_tpm_tis(struct tpm_chip* tpm){
-   int i;
-
-   printk("Shutting down tpm_tis device\n");
-
-   iowrite32(TPM_INT_ENABLE(tpm, tpm->locality), ~TPM_GLOBAL_INT_ENABLE);
-
-   /*Unmap all of the mmio pages */
-   for(i = 0; i < 5; ++i) {
-      if(tpm->pages[i] != NULL) {
-	 iounmap(tpm->pages[i], PAGE_SIZE);
-	 tpm->pages[i] = NULL;
-      }
-   }
-   free(tpm);
-   return;
-}
-
-
 int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** resp, size_t* resplen)
 {
    if(tpm->locality < 0) {
@@ -1279,23 +1284,19 @@ int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** res
 }
 
 #ifdef HAVE_LIBC
-int tpm_tis_open(struct tpm_chip* tpm)
+#include <sys/stat.h>
+#include <fcntl.h>
+
+static int tpm_tis_close(struct file *file)
 {
-   /* Silently prevent multiple opens */
-   if(tpm->fd != -1) {
-      return tpm->fd;
-   }
+    shutdown_tpm_tis(file->dev);
 
-   tpm->fd = alloc_fd(FTYPE_TPM_TIS);
-   printk("tpm_tis_open() -> %d\n", tpm->fd);
-   files[tpm->fd].dev = tpm;
-   return tpm->fd;
+    return 0;
 }
 
-int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count)
+static int tpm_tis_posix_write(struct file *file, const void *buf, size_t count)
 {
-   struct tpm_chip* tpm;
-   tpm = files[fd].dev;
+   struct tpm_chip *tpm = file->dev;
 
    if(tpm->locality < 0) {
       printk("tpm_tis_posix_write() failed! locality not set!\n");
@@ -1319,11 +1320,10 @@ int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count)
    return count;
 }
 
-int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
+static int tpm_tis_posix_read(struct file *file, void *buf, size_t count)
 {
    int rc;
-   struct tpm_chip* tpm;
-   tpm = files[fd].dev;
+   struct tpm_chip *tpm = file->dev;
 
    if(count == 0) {
       return 0;
@@ -1337,20 +1337,21 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
 
 
    /* Handle EOF case */
-   if(files[fd].offset >= tpm->data_len) {
+   if ( file->offset >= tpm->data_len )
+   {
       rc = 0;
    } else {
-      rc = min(tpm->data_len - files[fd].offset, count);
-      memcpy(buf, tpm->data_buffer + files[fd].offset, rc);
+      rc = min(tpm->data_len - file->offset, count);
+      memcpy(buf, tpm->data_buffer + file->offset, rc);
    }
-   files[fd].offset += rc;
+   file->offset += rc;
    /* Reset the data pending flag */
    return rc;
 }
-int tpm_tis_posix_fstat(int fd, struct stat* buf)
+
+static int tpm_tis_posix_fstat(struct file *file, struct stat *buf)
 {
-   struct tpm_chip* tpm;
-   tpm = files[fd].dev;
+   struct tpm_chip *tpm = file->dev;
 
    buf->st_mode = O_RDWR;
    buf->st_uid = 0;
@@ -1360,6 +1361,38 @@ int tpm_tis_posix_fstat(int fd, struct stat* buf)
    return 0;
 }
 
+static const struct file_ops tpm_tis_ops = {
+    .name = "tpm_tis",
+    .read = tpm_tis_posix_read,
+    .write = tpm_tis_posix_write,
+    .lseek = lseek_default,
+    .close = tpm_tis_close,
+    .fstat = tpm_tis_posix_fstat,
+};
+
+static unsigned int ftype_tis;
+
+__attribute__((constructor))
+static void tpm_tis_initialize(void)
+{
+    ftype_tis = alloc_file_type(&tpm_tis_ops);
+}
+
+int tpm_tis_open(struct tpm_chip *tpm)
+{
+    struct file *file;
+
+    /* Silently prevent multiple opens */
+    if ( tpm->fd != -1 )
+        return tpm->fd;
+
+    tpm->fd = alloc_fd(ftype_tis);
+    printk("tpm_tis_open() -> %d\n", tpm->fd);
+    file = get_file_from_fd(tpm->fd);
+    file->dev = tpm;
+    return tpm->fd;
+}
+
 /* TPM 2.0 */
 
 /*TPM2.0 Selftest*/
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 08:33:41 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 08:33:41 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257831.443249 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yr-0001TK-M2; Sun, 16 Jan 2022 08:33:41 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257831.443249; Sun, 16 Jan 2022 08:33:41 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yq-0001QL-V5; Sun, 16 Jan 2022 08:33:40 +0000
Received: by outflank-mailman (input) for mailman id 257831;
 Sun, 16 Jan 2022 08:33:38 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n90yn-0008IQ-Uz
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 08:33:37 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id fd053218-76a6-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 09:33:32 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id B7067219C8;
 Sun, 16 Jan 2022 08:33:32 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8DEF31346A;
 Sun, 16 Jan 2022 08:33:32 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id oIN0IVzY42HyFQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 08:33:32 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fd053218-76a6-11ec-9bbc-9dff3e4ee8c5
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642322012; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=sE2ME2yl3H92H6CBanzgJAMhj6JgWCncjlIia2KP7ss=;
	b=sVHsnUB42fimeyRpdY0mC4n6za+sNhiKzqnZBmPUpban2shE3YrSiIanyFrFGlGvp/uomA
	PaodsxbHpsaWadBuoc4vldB73m98rAZLpc0HCIW4DYCYMBw+uwEQOh2WhQXYApaANnxCxH
	4R74J0fouMHpIQVY8p6V752MtpM3Vjw=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 11/12] add struct file_ops for FTYPE_FILE
Date: Sun, 16 Jan 2022 09:33:27 +0100
Message-Id: <20220116083328.26524-12-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116083328.26524-1-jgross@suse.com>
References: <20220116083328.26524-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

FTYPE_FILE is the last relevant file type without a struct file_ops.
Add it.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 lib/sys.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/lib/sys.c b/lib/sys.c
index 538d6e7b..7f3dc4e4 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -99,6 +99,11 @@ static const struct file_ops file_ops_none = {
     .name = "none",
 };
 
+static const struct file_ops file_file_ops = {
+    .name = "file",
+    .lseek = lseek_default,
+};
+
 #ifdef HAVE_LWIP
 static int socket_read(struct file *file, void *buf, size_t nbytes)
 {
@@ -157,6 +162,7 @@ static const struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
 #ifdef CONFIG_CONSFRONT
     [FTYPE_CONSOLE] = &console_ops,
 #endif
+    [FTYPE_FILE] = &file_file_ops,
 #ifdef HAVE_LWIP
     [FTYPE_SOCKET] = &socket_ops,
 #endif
@@ -415,16 +421,9 @@ off_t lseek(int fd, off_t offset, int whence)
     if ( ops->lseek )
         return ops->lseek(file, offset, whence);
 
-    switch(file->type) {
-       case FTYPE_FILE:
-          break;
-       default:
-          /* Not implemented for this filetype */
-          errno = ESPIPE;
-          return (off_t) -1;
-    }
-
-    return lseek_default(file, offset, whence);
+    /* Not implemented for this filetype */
+    errno = ESPIPE;
+    return (off_t) -1;
 }
 
 int fsync(int fd) {
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 08:33:45 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 08:33:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257836.443275 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yv-00027F-BC; Sun, 16 Jan 2022 08:33:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257836.443275; Sun, 16 Jan 2022 08:33:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yu-00022k-A6; Sun, 16 Jan 2022 08:33:44 +0000
Received: by outflank-mailman (input) for mailman id 257836;
 Sun, 16 Jan 2022 08:33:40 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n90yp-0008IQ-VO
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 08:33:39 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id fd22d509-76a6-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 09:33:32 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id E6C091F3B3;
 Sun, 16 Jan 2022 08:33:32 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BCFAB1346A;
 Sun, 16 Jan 2022 08:33:32 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id EPjeLFzY42HyFQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 08:33:32 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fd22d509-76a6-11ec-9bbc-9dff3e4ee8c5
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642322012; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=oOgPnC87mBVmQF7jR57eu5ZPcD/ugF9PvO1qiNK3tw0=;
	b=HdBkVf2IlC6eWGmvrIixjb+2K/YwN1MUNDEScGcmGfxlV4b5RnkNiXoNxsQ5AZohqT2jFe
	+feJmN4FboDawfwO5jShMtHnttg1SpDpZmcS68zURnwstJxl4Smf2F8Zlp2AhoO4zFJjPi
	rDf7PtjLkmYTgBg3u82uLB3XHJHEF/w=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 12/12] make files array private to sys.c
Date: Sun, 16 Jan 2022 09:33:28 +0100
Message-Id: <20220116083328.26524-13-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116083328.26524-1-jgross@suse.com>
References: <20220116083328.26524-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

There is no user of the files[] array outside of lib/sys.c left, so
it can be made static.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 include/lib.h | 2 --
 lib/sys.c     | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index e815e0a3..bec99646 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -175,8 +175,6 @@ struct file {
     };
 };
 
-extern struct file files[];
-
 struct file_ops {
     const char *name;
     int (*read)(struct file *file, void *buf, size_t nbytes);
diff --git a/lib/sys.c b/lib/sys.c
index 7f3dc4e4..8f8a3de2 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -89,7 +89,7 @@ extern void minios_evtchn_close_fd(int fd);
 extern void minios_gnttab_close_fd(int fd);
 
 pthread_mutex_t fd_lock = PTHREAD_MUTEX_INITIALIZER;
-struct file files[NOFILE] = {
+static struct file files[NOFILE] = {
     { .type = FTYPE_CONSOLE }, /* stdin */
     { .type = FTYPE_CONSOLE }, /* stdout */
     { .type = FTYPE_CONSOLE }, /* stderr */
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 08:33:46 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 08:33:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257837.443276 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yv-00029y-FV; Sun, 16 Jan 2022 08:33:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257837.443276; Sun, 16 Jan 2022 08:33:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n90yu-000278-Fv; Sun, 16 Jan 2022 08:33:44 +0000
Received: by outflank-mailman (input) for mailman id 257837;
 Sun, 16 Jan 2022 08:33:41 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n90yq-0008IP-PY
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 08:33:40 +0000
Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id fcddc162-76a6-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 09:33:32 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out2.suse.de (Postfix) with ESMTPS id 00A211F3B2;
 Sun, 16 Jan 2022 08:33:32 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C14431346A;
 Sun, 16 Jan 2022 08:33:31 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id SBf1LVvY42HyFQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 08:33:31 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fcddc162-76a6-11ec-a115-11989b9578b4
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642322012; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=V/vC7tx78nDm4GqTKex/CmQNpmhFP/CrwSTFfFKDiV0=;
	b=GNbSZjwy7POyyXYRYjJBwE0+AievuggavYIBPtCINlJ6RJj6rMv5rduHp2JCvUN/g40k/l
	msxIrrAuYJr2WFo75sNf6pGbDdMSyQgpvjV1YvM8k32Zl8rZ+P/7xJETUIZ8Dqe07LobjF
	C/1ZOSGWsyRMhepceTlQyAyubIgnM6s=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 07/12] use alloc_file_type() and get_file_from_fd() in netfront
Date: Sun, 16 Jan 2022 09:33:23 +0100
Message-Id: <20220116083328.26524-8-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116083328.26524-1-jgross@suse.com>
References: <20220116083328.26524-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Allocate the file type dynamically via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V3:
- switch to struct file * parameter for callbacks
- use __attribute__((constructor))
---
 include/lib.h      |  3 +--
 include/netfront.h |  3 ++-
 lib/sys.c          | 23 ----------------
 netfront.c         | 65 +++++++++++++++++++++++++++++++++++++++-------
 4 files changed, 59 insertions(+), 35 deletions(-)

diff --git a/include/lib.h b/include/lib.h
index 2f472b00..b0d08807 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -165,8 +165,7 @@ extern struct wait_queue_head event_queue;
 #define FTYPE_SAVEFILE   5
 #define FTYPE_FB         6
 #define FTYPE_KBD        7
-#define FTYPE_TAP        8
-#define FTYPE_N          9
+#define FTYPE_N          8
 #define FTYPE_SPARE     16
 
 struct file {
diff --git a/include/netfront.h b/include/netfront.h
index ec641c80..75080c26 100644
--- a/include/netfront.h
+++ b/include/netfront.h
@@ -10,7 +10,8 @@ struct netfront_dev *init_netfront(char *nodename,
                                    char **ip);
 char *netfront_get_netmask(struct netfront_dev *dev);
 char *netfront_get_gateway(struct netfront_dev *dev);
-void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len);
+void netfront_xmit(struct netfront_dev *dev, const unsigned char *data,
+                   int len);
 void shutdown_netfront(struct netfront_dev *dev);
 void suspend_netfront(void);
 void resume_netfront(void);
diff --git a/lib/sys.c b/lib/sys.c
index 90684335..44fe848c 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -309,17 +309,6 @@ int read(int fd, void *buf, size_t nbytes)
         case FTYPE_SOCKET:
 	    return lwip_read(files[fd].fd, buf, nbytes);
 #endif
-#ifdef CONFIG_NETFRONT
-	case FTYPE_TAP: {
-	    ssize_t ret;
-	    ret = netfront_receive(files[fd].dev, buf, nbytes);
-	    if (ret <= 0) {
-		errno = EAGAIN;
-		return -1;
-	    }
-	    return ret;
-	}
-#endif
 #ifdef CONFIG_KBDFRONT
         case FTYPE_KBD: {
             int ret, n;
@@ -382,11 +371,6 @@ int write(int fd, const void *buf, size_t nbytes)
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
 	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
-#endif
-#ifdef CONFIG_NETFRONT
-	case FTYPE_TAP:
-	    netfront_xmit(files[fd].dev, (void*) buf, nbytes);
-	    return nbytes;
 #endif
 	default:
 	    break;
@@ -487,11 +471,6 @@ int close(int fd)
             res = lwip_close(files[fd].fd);
             break;
 #endif
-#ifdef CONFIG_NETFRONT
-	case FTYPE_TAP:
-	    shutdown_netfront(files[fd].dev);
-            break;
-#endif
 #ifdef CONFIG_KBDFRONT
 	case FTYPE_KBD:
             shutdown_kbdfront(files[fd].dev);
@@ -687,7 +666,6 @@ static const char *const file_types[] = {
     [FTYPE_NONE]    = "none",
     [FTYPE_CONSOLE] = "console",
     [FTYPE_SOCKET]  = "socket",
-    [FTYPE_TAP]     = "net",
     [FTYPE_KBD]     = "kbd",
     [FTYPE_FB]      = "fb",
 };
@@ -872,7 +850,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
                 n++;
 	    FD_CLR(i, exceptfds);
 	    break;
-	case FTYPE_TAP:
 	case FTYPE_KBD:
 	case FTYPE_FB:
 	    if (FD_ISSET(i, readfds)) {
diff --git a/netfront.c b/netfront.c
index 76964514..164fdc66 100644
--- a/netfront.c
+++ b/netfront.c
@@ -248,14 +248,14 @@ void netfront_select_handler(evtchn_port_t port, struct pt_regs *regs, void *dat
 {
     int flags;
     struct netfront_dev *dev = data;
-    int fd = dev->fd;
+    struct file *file = get_file_from_fd(dev->fd);
 
     local_irq_save(flags);
     network_tx_buf_gc(dev);
     local_irq_restore(flags);
 
-    if (fd != -1)
-        files[fd].read = true;
+    if ( file )
+        file->read = true;
     wake_up(&netfront_queue);
 }
 #endif
@@ -565,8 +565,53 @@ error:
 }
 
 #ifdef HAVE_LIBC
+static int netfront_read(struct file *file, void *buf, size_t nbytes)
+{
+    ssize_t ret;
+
+    ret = netfront_receive(file->dev, buf, nbytes);
+    if ( ret <= 0 )
+    {
+        errno = EAGAIN;
+        return -1;
+    }
+
+    return ret;
+}
+
+static int netfront_write(struct file *file, const void *buf, size_t nbytes)
+{
+    netfront_xmit(file->dev, buf, nbytes);
+
+    return nbytes;
+}
+
+static int netfront_close_fd(struct file *file)
+{
+    shutdown_netfront(file->dev);
+
+    return 0;
+}
+
+static const struct file_ops netfront_ops = {
+    .name = "net",
+    .read = netfront_read,
+    .write = netfront_write,
+    .close = netfront_close_fd,
+    .select_rd = select_read_flag,
+};
+
+static unsigned int ftype_netfront;
+
+__attribute__((constructor))
+static void netfront_initialize(void)
+{
+    ftype_netfront = alloc_file_type(&netfront_ops);
+}
+
 int netfront_tap_open(char *nodename) {
     struct netfront_dev *dev;
+    struct file *file;
 
     dev = init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL);
     if (!dev) {
@@ -574,9 +619,10 @@ int netfront_tap_open(char *nodename) {
 	errno = EIO;
 	return -1;
     }
-    dev->fd = alloc_fd(FTYPE_TAP);
+    dev->fd = alloc_fd(ftype_netfront);
     printk("tap_open(%s) -> %d\n", nodename, dev->fd);
-    files[dev->fd].dev = dev;
+    file = get_file_from_fd(dev->fd);
+    file->dev = dev;
     return dev->fd;
 }
 #endif
@@ -720,7 +766,7 @@ void init_rx_buffers(struct netfront_dev *dev)
 }
 
 
-void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len)
+void netfront_xmit(struct netfront_dev *dev, const unsigned char *data, int len)
 {
     int flags;
     struct netif_tx_request *tx;
@@ -772,7 +818,8 @@ void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len)
 ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t len)
 {
     unsigned long flags;
-    int fd = dev->fd;
+    struct file *file = get_file_from_fd(dev->fd);
+
     ASSERT(current == main_thread);
 
     dev->rlen = 0;
@@ -781,9 +828,9 @@ ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t l
 
     local_irq_save(flags);
     network_rx(dev);
-    if (!dev->rlen && fd != -1)
+    if ( !dev->rlen && file )
         /* No data for us, make select stop returning */
-        files[fd].read = false;
+        file->read = false;
     /* Before re-enabling the interrupts, in case a packet just arrived in the
      * meanwhile. */
     local_irq_restore(flags);
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 08:36:58 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 08:36:58 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257840.443317 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9122-0006ZA-5P; Sun, 16 Jan 2022 08:36:58 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257840.443317; Sun, 16 Jan 2022 08:36:58 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9122-0006Z3-1r; Sun, 16 Jan 2022 08:36:58 +0000
Received: by outflank-mailman (input) for mailman id 257840;
 Sun, 16 Jan 2022 08:36:56 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n90yv-0008IP-QD
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 08:33:45 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id fd3aa52c-76a6-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 09:33:32 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 95034219C9;
 Sun, 16 Jan 2022 08:33:32 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5FFD213AB5;
 Sun, 16 Jan 2022 08:33:32 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 6JszFlzY42HyFQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 08:33:32 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fd3aa52c-76a6-11ec-a115-11989b9578b4
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642322012; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=eDN7dygQtWpp4PtzeecJTsg/5tatNDTI+Yj25CuIEDI=;
	b=mDts5epmvwpbSWm2VbNo8wTury2KLFycD4WQVRdkLIDFtaCyxTI/cfExusLRtx2GeKgMD3
	G2myLGJ94Try9iy8cDOmyw8R5WPkWGp0DikTQw6NSVIzhzKIEUgYvBNHXsI8G5oe5Zo+FZ
	JgndfXyroO35LPaTSHY1+L16C2JROu4=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 10/12] add struct file_ops for file type socket
Date: Sun, 16 Jan 2022 09:33:26 +0100
Message-Id: <20220116083328.26524-11-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116083328.26524-1-jgross@suse.com>
References: <20220116083328.26524-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Even with some special handling needed in select_poll(), add a struct
file_ops for FTYPE_SOCKET. Due to the need of the special handling it
isn't possible to use a dynamically allocated file type.

Most functions calling the file_ops methods can be simplified a lot now
that no file type specific handling is left. Same applies to the file
type name printing in debug/verbose mode.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V3:
- switch to struct file * parameter for callbacks
---
 lib/sys.c | 148 +++++++++++++++++++++++-------------------------------
 1 file changed, 64 insertions(+), 84 deletions(-)

diff --git a/lib/sys.c b/lib/sys.c
index 74c82b2a..538d6e7b 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -99,11 +99,67 @@ static const struct file_ops file_ops_none = {
     .name = "none",
 };
 
+#ifdef HAVE_LWIP
+static int socket_read(struct file *file, void *buf, size_t nbytes)
+{
+    return lwip_read(file->fd, buf, nbytes);
+}
+
+static int socket_write(struct file *file, const void *buf, size_t nbytes)
+{
+    return lwip_write(file->fd, buf, nbytes);
+}
+
+static int close_socket_fd(struct file *file)
+{
+    return lwip_close(file->fd);
+}
+
+static int socket_fstat(struct file *file, struct stat *buf)
+{
+    buf->st_mode = S_IFSOCK | S_IRUSR | S_IWUSR;
+    buf->st_atime = buf->st_mtime = buf->st_ctime = time(NULL);
+
+    return 0;
+}
+
+static int socket_fcntl(struct file *file, int cmd, va_list args)
+{
+    long arg;
+
+    arg = va_arg(args, long);
+
+    if ( cmd == F_SETFL && !(arg & ~O_NONBLOCK) )
+    {
+        /* Only flag supported: non-blocking mode */
+        uint32_t nblock = !!(arg & O_NONBLOCK);
+
+        return lwip_ioctl(file->fd, FIONBIO, &nblock);
+    }
+
+    printk("socket fcntl(fd, %d, %lx/%lo)\n", cmd, arg, arg);
+    errno = ENOSYS;
+    return -1;
+}
+
+static const struct file_ops socket_ops = {
+    .name = "socket",
+    .read = socket_read,
+    .write = socket_write,
+    .close = close_socket_fd,
+    .fstat = socket_fstat,
+    .fcntl = socket_fcntl,
+};
+#endif
+
 static const struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
     [FTYPE_NONE] = &file_ops_none,
 #ifdef CONFIG_CONSFRONT
     [FTYPE_CONSOLE] = &console_ops,
 #endif
+#ifdef HAVE_LWIP
+    [FTYPE_SOCKET] = &socket_ops,
+#endif
 };
 
 unsigned int alloc_file_type(const struct file_ops *ops)
@@ -288,15 +344,6 @@ int read(int fd, void *buf, size_t nbytes)
     if ( ops->read )
         return ops->read(file, buf, nbytes);
 
-    switch (file->type) {
-#ifdef HAVE_LWIP
-        case FTYPE_SOCKET:
-	    return lwip_read(files[fd].fd, buf, nbytes);
-#endif
-	default:
-	    break;
-    }
-
  error:
     printk("read(%d): Bad descriptor\n", fd);
     errno = EBADF;
@@ -315,15 +362,6 @@ int write(int fd, const void *buf, size_t nbytes)
     if ( ops->write )
         return ops->write(file, buf, nbytes);
 
-    switch (file->type) {
-#ifdef HAVE_LWIP
-	case FTYPE_SOCKET:
-	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
-#endif
-	default:
-	    break;
-    }
-
  error:
     printk("write(%d): Bad descriptor\n", fd);
     errno = EBADF;
@@ -406,24 +444,10 @@ int close(int fd)
     ops = get_file_ops(file->type);
     printk("close(%d)\n", fd);
     if ( ops->close )
-    {
         res = ops->close(file);
-        goto out;
-    }
-
-    switch (file->type) {
-        default:
-            break;
-#ifdef HAVE_LWIP
-	case FTYPE_SOCKET:
-            res = lwip_close(files[fd].fd);
-            break;
-#endif
-	case FTYPE_NONE:
-            goto error;
-    }
+    else if ( file->type == FTYPE_NONE )
+        goto error;
 
- out:
     memset(files + fd, 0, sizeof(struct file));
     BUILD_BUG_ON(FTYPE_NONE != 0);
 
@@ -466,21 +490,6 @@ int fstat(int fd, struct stat *buf)
     if ( ops->fstat )
         return ops->fstat(file, buf);
 
-    switch (file->type) {
-	case FTYPE_SOCKET: {
-            buf->st_mode = S_IFSOCK|S_IRUSR|S_IWUSR;
-	    buf->st_uid = 0;
-	    buf->st_gid = 0;
-	    buf->st_size = 0;
-	    buf->st_atime = 
-	    buf->st_mtime = 
-	    buf->st_ctime = time(NULL);
-	    return 0;
-	}
-	default:
-	    break;
-    }
-
  error:
     printk("statf(%d): Bad descriptor\n", fd);
     errno = EBADF;
@@ -538,21 +547,9 @@ int fcntl(int fd, int cmd, ...)
     arg = va_arg(ap, long);
     va_end(ap);
 
-    switch (cmd) {
-#ifdef HAVE_LWIP
-	case F_SETFL:
-	    if (files[fd].type == FTYPE_SOCKET && !(arg & ~O_NONBLOCK)) {
-		/* Only flag supported: non-blocking mode */
-		uint32_t nblock = !!(arg & O_NONBLOCK);
-		return lwip_ioctl(files[fd].fd, FIONBIO, &nblock);
-	    }
-	    /* Fallthrough */
-#endif
-	default:
-	    printk("fcntl(%d, %d, %lx/%lo)\n", fd, cmd, arg, arg);
-	    errno = ENOSYS;
-	    return -1;
-    }
+    printk("fcntl(%d, %d, %lx/%lo)\n", fd, cmd, arg, arg);
+    errno = ENOSYS;
+    return -1;
 }
 
 DIR *opendir(const char *name)
@@ -586,23 +583,6 @@ int closedir(DIR *dir)
 
 /* We assume that only the main thread calls select(). */
 
-#if defined(LIBC_DEBUG) || defined(LIBC_VERBOSE)
-static const char *const file_types[] = {
-    [FTYPE_NONE]    = "none",
-    [FTYPE_SOCKET]  = "socket",
-};
-
-static const char *get_type_name(unsigned int type)
-{
-    if ( type < ARRAY_SIZE(file_ops) && file_ops[type] )
-        return file_ops[type]->name;
-
-    if ( type < ARRAY_SIZE(file_types) && file_types[type] )
-        return file_types[type];
-
-    return "none";
-}
-#endif
 #ifdef LIBC_DEBUG
 static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
 {
@@ -613,7 +593,7 @@ static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *except
 	if (FD_ISSET(i, set)) { \
 	    if (comma) \
 		printk(", "); \
-            printk("%d(%s)", i, get_type_name(files[i].type)); \
+            printk("%d(%s)", i, get_file_ops(files[i].type)->name); \
 	    comma = 1; \
 	} \
     } \
@@ -647,7 +627,7 @@ static void dump_pollfds(struct pollfd *pfd, int nfds, int timeout)
         fd = pfd[i].fd;
         if (comma)
             printk(", ");
-        printk("%d(%s)/%02x", fd, get_type_name(files[fd].type),
+        printk("%d(%s)/%02x", fd, get_file_ops(files[fd].type)->name,
             pfd[i].events);
             comma = 1;
     }
@@ -809,7 +789,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 	printk("%d(%d): ", nb, sock_n);
 	for (i = 0; i < nfds; i++) {
 	    if (nbread[i] || nbwrite[i] || nbexcept[i])
-                printk(" %d(%c):", i, get_type_name(files[i].type));
+                printk(" %d(%c):", i, get_file_ops(files[i].type)->name);
 	    if (nbread[i])
 	    	printk(" %dR", nbread[i]);
 	    if (nbwrite[i])
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 08:37:31 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 08:37:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257845.443331 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n912Z-0007CC-G6; Sun, 16 Jan 2022 08:37:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257845.443331; Sun, 16 Jan 2022 08:37:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n912Z-0007C5-D6; Sun, 16 Jan 2022 08:37:31 +0000
Received: by outflank-mailman (input) for mailman id 257845;
 Sun, 16 Jan 2022 08:37:30 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n90yr-0008IP-PV
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 08:33:41 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id fcf64275-76a6-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 09:33:32 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 27B76219A8;
 Sun, 16 Jan 2022 08:33:32 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EFD8113AB5;
 Sun, 16 Jan 2022 08:33:31 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id 8IJYOVvY42HyFQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 08:33:31 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fcf64275-76a6-11ec-a115-11989b9578b4
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642322012; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=EyEnGVB5vj2rXALZOQkxMfap/9vtF59SnM7EBGmKPBU=;
	b=XTt8ZgVkevEntWYLIy95AiISyMPJcQd+OeXPsM85X6QLSBshhnH7Lk7XZHaeT0mJOsl+bo
	VZbvoXtK6Y2pb/4KCflxof1UPEAEFsACyvVP9Bl59o2J2FQHjpF5U2kD96+bBON7wabze6
	C5BGQKzQ1e+KX9SbXApJT2Q2RzCERNg=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 08/12] use alloc_file_type() and get_file_from_fd() in fbfront
Date: Sun, 16 Jan 2022 09:33:24 +0100
Message-Id: <20220116083328.26524-9-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116083328.26524-1-jgross@suse.com>
References: <20220116083328.26524-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Allocate file types dynamically via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V3:
- switch to struct file * parameter for callbacks
- use __attribute__((constructor))
---
 fbfront.c     | 127 ++++++++++++++++++++++++++++++++++++++++++--------
 include/lib.h |   4 +-
 lib/sys.c     |  47 -------------------
 3 files changed, 108 insertions(+), 70 deletions(-)

diff --git a/fbfront.c b/fbfront.c
index 1e055fb0..360a9cf6 100644
--- a/fbfront.c
+++ b/fbfront.c
@@ -14,6 +14,9 @@
 #include <mini-os/xmalloc.h>
 #include <mini-os/fbfront.h>
 #include <mini-os/lib.h>
+#ifdef HAVE_LIBC
+#include <errno.h>
+#endif
 
 DECLARE_WAIT_QUEUE_HEAD(kbdfront_queue);
 
@@ -42,10 +45,10 @@ void kbdfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
 {
 #ifdef HAVE_LIBC
     struct kbdfront_dev *dev = data;
-    int fd = dev->fd;
+    struct file *file = get_file_from_fd(dev->fd);
 
-    if (fd != -1)
-        files[fd].read = true;
+    if ( file )
+        file->read = true;
 #endif
     wake_up(&kbdfront_queue);
 }
@@ -204,10 +207,12 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
     struct xenkbd_page *page = dev->page;
     uint32_t prod, cons;
     int i;
-
 #ifdef HAVE_LIBC
-    if (dev->fd != -1) {
-        files[dev->fd].read = false;
+    struct file *file = get_file_from_fd(dev->fd);
+
+    if ( file )
+    {
+        file->read = false;
         mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
     }
 #endif
@@ -227,9 +232,9 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
     notify_remote_via_evtchn(dev->evtchn);
 
 #ifdef HAVE_LIBC
-    if (cons != prod && dev->fd != -1)
+    if ( cons != prod && file )
         /* still some events to read */
-        files[dev->fd].read = true;
+        file->read = true;
 #endif
 
     return i;
@@ -298,11 +303,51 @@ close_kbdfront:
 }
 
 #ifdef HAVE_LIBC
+static int kbd_read(struct file *file, void *buf, size_t nbytes)
+{
+    int ret, n;
+
+    n = nbytes / sizeof(union xenkbd_in_event);
+    ret = kbdfront_receive(file->dev, buf, n);
+    if ( ret <= 0 )
+    {
+        errno = EAGAIN;
+        return -1;
+    }
+
+    return ret * sizeof(union xenkbd_in_event);
+}
+
+static int kbd_close_fd(struct file *file)
+{
+    shutdown_kbdfront(file->dev);
+
+    return 0;
+}
+
+static struct file_ops kbd_ops = {
+    .name = "kbd",
+    .read = kbd_read,
+    .close = kbd_close_fd,
+    .select_rd = select_read_flag,
+};
+
+static unsigned int ftype_kbd;
+
+__attribute__((constructor))
+static void kbdfront_initialize(void)
+{
+    ftype_kbd = alloc_file_type(&kbd_ops);
+}
+
 int kbdfront_open(struct kbdfront_dev *dev)
 {
-    dev->fd = alloc_fd(FTYPE_KBD);
+    struct file *file;
+
+    dev->fd = alloc_fd(ftype_kbd);
     printk("kbd_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].dev = dev;
+    file = get_file_from_fd(dev->fd);
+    file->dev = dev;
     return dev->fd;
 }
 #endif
@@ -346,10 +391,10 @@ void fbfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
 {
 #ifdef HAVE_LIBC
     struct fbfront_dev *dev = data;
-    int fd = dev->fd;
+    struct file *file = get_file_from_fd(dev->fd);
 
-    if (fd != -1)
-        files[fd].read = true;
+    if ( file )
+        file->read = true;
 #endif
     wake_up(&fbfront_queue);
 }
@@ -373,10 +418,12 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
     struct xenfb_page *page = dev->page;
     uint32_t prod, cons;
     int i;
-
 #ifdef HAVE_LIBC
-    if (dev->fd != -1) {
-        files[dev->fd].read = false;
+    struct file *file = get_file_from_fd(dev->fd);
+
+    if ( file )
+    {
+        file->read = false;
         mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
     }
 #endif
@@ -396,9 +443,9 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
     notify_remote_via_evtchn(dev->evtchn);
 
 #ifdef HAVE_LIBC
-    if (cons != prod && dev->fd != -1)
+    if ( cons != prod && file )
         /* still some events to read */
-        files[dev->fd].read = true;
+        file->read = true;
 #endif
 
     return i;
@@ -699,11 +746,51 @@ close_fbfront:
 }
 
 #ifdef HAVE_LIBC
+static int fbfront_read(struct file *file, void *buf, size_t nbytes)
+{
+    int ret, n;
+
+    n = nbytes / sizeof(union xenfb_in_event);
+    ret = fbfront_receive(file->dev, buf, n);
+    if ( ret <= 0 )
+    {
+        errno = EAGAIN;
+        return -1;
+    }
+
+    return ret * sizeof(union xenfb_in_event);
+}
+
+static int fbfront_close_fd(struct file *file)
+{
+    shutdown_fbfront(file->dev);
+
+    return 0;
+}
+
+static const struct file_ops fb_ops = {
+    .name = "fb",
+    .read = fbfront_read,
+    .close = fbfront_close_fd,
+    .select_rd = select_read_flag,
+};
+
+static unsigned int ftype_fb;
+
+__attribute__((constructor))
+static void fbfront_initialize(void)
+{
+    ftype_fb = alloc_file_type(&fb_ops);
+}
+
 int fbfront_open(struct fbfront_dev *dev)
 {
-    dev->fd = alloc_fd(FTYPE_FB);
+    struct file *file;
+
+    dev->fd = alloc_fd(ftype_fb);
     printk("fb_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].dev = dev;
+    file = get_file_from_fd(dev->fd);
+    file->dev = dev;
     return dev->fd;
 }
 #endif
diff --git a/include/lib.h b/include/lib.h
index b0d08807..b1beeed3 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -163,9 +163,7 @@ extern struct wait_queue_head event_queue;
 #define FTYPE_SOCKET     3
 #define FTYPE_MEM        4
 #define FTYPE_SAVEFILE   5
-#define FTYPE_FB         6
-#define FTYPE_KBD        7
-#define FTYPE_N          8
+#define FTYPE_N          6
 #define FTYPE_SPARE     16
 
 struct file {
diff --git a/lib/sys.c b/lib/sys.c
index 44fe848c..db26fd2d 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -308,30 +308,6 @@ int read(int fd, void *buf, size_t nbytes)
 #ifdef HAVE_LWIP
         case FTYPE_SOCKET:
 	    return lwip_read(files[fd].fd, buf, nbytes);
-#endif
-#ifdef CONFIG_KBDFRONT
-        case FTYPE_KBD: {
-            int ret, n;
-            n = nbytes / sizeof(union xenkbd_in_event);
-            ret = kbdfront_receive(files[fd].dev, buf, n);
-	    if (ret <= 0) {
-		errno = EAGAIN;
-		return -1;
-	    }
-	    return ret * sizeof(union xenkbd_in_event);
-        }
-#endif
-#ifdef CONFIG_FBFRONT
-        case FTYPE_FB: {
-            int ret, n;
-            n = nbytes / sizeof(union xenfb_in_event);
-            ret = fbfront_receive(files[fd].dev, buf, n);
-	    if (ret <= 0) {
-		errno = EAGAIN;
-		return -1;
-	    }
-	    return ret * sizeof(union xenfb_in_event);
-        }
 #endif
 	default:
 	    break;
@@ -471,16 +447,6 @@ int close(int fd)
             res = lwip_close(files[fd].fd);
             break;
 #endif
-#ifdef CONFIG_KBDFRONT
-	case FTYPE_KBD:
-            shutdown_kbdfront(files[fd].dev);
-            break;
-#endif
-#ifdef CONFIG_FBFRONT
-	case FTYPE_FB:
-            shutdown_fbfront(files[fd].dev);
-            break;
-#endif
 #ifdef CONFIG_CONSFRONT
         case FTYPE_SAVEFILE:
         case FTYPE_CONSOLE:
@@ -666,8 +632,6 @@ static const char *const file_types[] = {
     [FTYPE_NONE]    = "none",
     [FTYPE_CONSOLE] = "console",
     [FTYPE_SOCKET]  = "socket",
-    [FTYPE_KBD]     = "kbd",
-    [FTYPE_FB]      = "fb",
 };
 
 static const char *get_type_name(unsigned int type)
@@ -850,17 +814,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
                 n++;
 	    FD_CLR(i, exceptfds);
 	    break;
-	case FTYPE_KBD:
-	case FTYPE_FB:
-	    if (FD_ISSET(i, readfds)) {
-		if (files[i].read)
-		    n++;
-		else
-		    FD_CLR(i, readfds);
-	    }
-	    FD_CLR(i, writefds);
-	    FD_CLR(i, exceptfds);
-	    break;
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
 	    if (FD_ISSET(i, readfds)) {
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 08:38:35 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 08:38:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257854.443357 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n913b-0008Di-7e; Sun, 16 Jan 2022 08:38:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257854.443357; Sun, 16 Jan 2022 08:38:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n913b-0008Db-4W; Sun, 16 Jan 2022 08:38:35 +0000
Received: by outflank-mailman (input) for mailman id 257854;
 Sun, 16 Jan 2022 08:38:33 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=APY9=SA=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n90yt-0008IP-Pz
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 08:33:44 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id fd1a925e-76a6-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 09:33:32 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 5A1D7219C7;
 Sun, 16 Jan 2022 08:33:32 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2E8D01346A;
 Sun, 16 Jan 2022 08:33:32 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id gPIjClzY42HyFQAAMHmgww
 (envelope-from <jgross@suse.com>); Sun, 16 Jan 2022 08:33:32 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fd1a925e-76a6-11ec-a115-11989b9578b4
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642322012; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references;
	bh=LVU0gEoX6rgZcZx+F07Qd6YUFiSDhtCjunERzqwuuYk=;
	b=kj5H3Kwbv0IQeztJ2dd0pWzgAEKjc2F6gZ1nJtUuQfy6YV6Cjl4u6ZTGGeKwgTo7EAVsDX
	ButBi2+MBU5DgfFtoLlRBAVhyGiq0dbQNegG0SPOxnAVadBQ5XZW+wBukIZ5YCu3/ECgWD
	ERv+eG/nVxiPO4IgDxOPcTj9GDOcYDo=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [MINIOS PATCH v3 09/12] use file_ops and get_file_from_fd() for console
Date: Sun, 16 Jan 2022 09:33:25 +0100
Message-Id: <20220116083328.26524-10-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20220116083328.26524-1-jgross@suse.com>
References: <20220116083328.26524-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Add struct file_ops for the console related file types (FTYPE_CONSOLE
and savefile). FTYPE_CONSOLE remains statically defined, as it is used
to statically init stdin, stdout and stderr.

Instead of directly accessing the files[] array use get_file_from_fd().

With CONSOLE now handled via file_ops the bogus file descriptor case in
select_poll() now needs to be handled more explicit instead of dropping
into console handling, assuming that this case was basically meant to
cover SAVEFILE.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V3:
- switch to struct file * parameter for callbacks
- use __attribute__((constructor))
- make console_print() take a const pointer (Andrew Cooper)
---
 console/console.c      |   2 +-
 console/xenbus.c       | 112 +++++++++++++++++++++++++++++++++++++++++
 console/xencons_ring.c |   6 +--
 include/console.h      |   7 ++-
 include/lib.h          |   3 +-
 lib/sys.c              |  87 ++++++++------------------------
 6 files changed, 144 insertions(+), 73 deletions(-)

diff --git a/console/console.c b/console/console.c
index af1a6dd3..68c8435e 100644
--- a/console/console.c
+++ b/console/console.c
@@ -76,7 +76,7 @@ void xencons_tx(void)
 #endif
 
 
-void console_print(struct consfront_dev *dev, char *data, int length)
+void console_print(struct consfront_dev *dev, const char *data, int length)
 {
     char *curr_char, saved_char;
     char copied_str[length+1];
diff --git a/console/xenbus.c b/console/xenbus.c
index 05fc31c0..d8950454 100644
--- a/console/xenbus.c
+++ b/console/xenbus.c
@@ -192,3 +192,115 @@ void fini_consfront(struct consfront_dev *dev)
 {
     if (dev) free_consfront(dev);
 }
+
+#ifdef HAVE_LIBC
+static int consfront_read(struct file *file, void *buf, size_t nbytes)
+{
+    int ret;
+    DEFINE_WAIT(w);
+
+    while ( 1 )
+    {
+        add_waiter(w, console_queue);
+        ret = xencons_ring_recv(file->dev, buf, nbytes);
+        if ( ret )
+            break;
+        schedule();
+    }
+
+    remove_waiter(w, console_queue);
+
+    return ret;
+}
+
+static int savefile_write(struct file *file, const void *buf, size_t nbytes)
+{
+    int ret = 0, tot = nbytes;
+
+    while ( nbytes > 0 )
+    {
+        ret = xencons_ring_send(file->dev, buf, nbytes);
+        nbytes -= ret;
+        buf = (char *)buf + ret;
+    }
+
+    return tot - nbytes;
+}
+
+static int console_write(struct file *file, const void *buf, size_t nbytes)
+{
+    console_print(file->dev, buf, nbytes);
+
+    return nbytes;
+}
+
+static int consfront_close_fd(struct file *file)
+{
+    fini_consfront(file->dev);
+
+    return 0;
+}
+
+static int consfront_fstat(struct file *file, struct stat *buf)
+{
+    buf->st_mode = S_IRUSR | S_IWUSR;
+    buf->st_mode |= (file->type == FTYPE_CONSOLE) ? S_IFCHR : S_IFREG;
+    buf->st_atime = buf->st_mtime = buf->st_ctime = time(NULL);
+
+    return 0;
+}
+
+static bool consfront_select_rd(struct file *file)
+{
+    return xencons_ring_avail(file->dev);
+}
+
+static const struct file_ops savefile_ops = {
+    .name = "savefile",
+    .read = consfront_read,
+    .write = savefile_write,
+    .close = consfront_close_fd,
+    .fstat = consfront_fstat,
+    .select_rd = consfront_select_rd,
+    .select_wr = select_yes,
+};
+
+const struct file_ops console_ops = {
+    .name = "console",
+    .read = consfront_read,
+    .write = console_write,
+    .close = consfront_close_fd,
+    .fstat = consfront_fstat,
+    .select_rd = consfront_select_rd,
+    .select_wr = select_yes,
+};
+
+static unsigned int ftype_savefile;
+
+__attribute__((constructor))
+static void consfront_initialize(void)
+{
+    ftype_savefile = alloc_file_type(&savefile_ops);
+}
+
+int open_consfront(char *nodename)
+{
+    struct consfront_dev *dev;
+    struct file *file;
+
+    dev = init_consfront(nodename);
+    if ( !dev )
+        return -1;
+
+    dev->fd = alloc_fd(nodename ? ftype_savefile : FTYPE_CONSOLE);
+    file = get_file_from_fd(dev->fd);
+    if ( !file )
+    {
+        fini_consfront(dev);
+        return -1;
+    }
+    file->dev = dev;
+
+    return dev->fd;
+}
+#endif
diff --git a/console/xencons_ring.c b/console/xencons_ring.c
index c348f3ce..efedf46b 100644
--- a/console/xencons_ring.c
+++ b/console/xencons_ring.c
@@ -99,10 +99,10 @@ void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data)
 {
 	struct consfront_dev *dev = (struct consfront_dev *) data;
 #ifdef HAVE_LIBC
-        int fd = dev ? dev->fd : -1;
+        struct file *file = dev ? get_file_from_fd(dev->fd) : NULL;
 
-        if (fd != -1)
-            files[fd].read = true;
+        if ( file )
+            file->read = true;
 
         wake_up(&console_queue);
 #else
diff --git a/include/console.h b/include/console.h
index 0d7bf077..e76e4234 100644
--- a/include/console.h
+++ b/include/console.h
@@ -39,6 +39,7 @@
 #include <mini-os/os.h>
 #include <mini-os/traps.h>
 #include <mini-os/types.h>
+#include <mini-os/lib.h>
 #include <xen/grant_table.h>
 #include <xenbus.h>
 #include <xen/io/console.h>
@@ -77,7 +78,7 @@ void xencons_tx(void);
 
 void get_console(void *p);
 void init_console(void);
-void console_print(struct consfront_dev *dev, char *data, int length);
+void console_print(struct consfront_dev *dev, const char *data, int length);
 void fini_consfront(struct consfront_dev *dev);
 void suspend_console(void);
 void resume_console(void);
@@ -93,5 +94,9 @@ int xencons_ring_send_no_notify(struct consfront_dev *dev, const char *data, uns
 int xencons_ring_avail(struct consfront_dev *dev);
 int xencons_ring_recv(struct consfront_dev *dev, char *data, unsigned len);
 void free_consfront(struct consfront_dev *dev);
+#ifdef HAVE_LIBC
+extern const struct file_ops console_ops;
+int open_consfront(char *nodename);
+#endif
 
 #endif /* _LIB_CONSOLE_H_ */
diff --git a/include/lib.h b/include/lib.h
index b1beeed3..e815e0a3 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -162,8 +162,7 @@ extern struct wait_queue_head event_queue;
 #define FTYPE_FILE       2
 #define FTYPE_SOCKET     3
 #define FTYPE_MEM        4
-#define FTYPE_SAVEFILE   5
-#define FTYPE_N          6
+#define FTYPE_N          5
 #define FTYPE_SPARE     16
 
 struct file {
diff --git a/lib/sys.c b/lib/sys.c
index db26fd2d..74c82b2a 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -101,6 +101,9 @@ static const struct file_ops file_ops_none = {
 
 static const struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
     [FTYPE_NONE] = &file_ops_none,
+#ifdef CONFIG_CONSFRONT
+    [FTYPE_CONSOLE] = &console_ops,
+#endif
 };
 
 unsigned int alloc_file_type(const struct file_ops *ops)
@@ -212,31 +215,26 @@ int mkdir(const char *pathname, mode_t mode)
 #ifdef CONFIG_CONSFRONT
 int posix_openpt(int flags)
 {
-    struct consfront_dev *dev;
+    int fd;
 
     /* Ignore flags */
+    fd = open_consfront(NULL);
+    printk("fd(%d) = posix_openpt\n", fd);
 
-    dev = init_consfront(NULL);
-    dev->fd = alloc_fd(FTYPE_CONSOLE);
-    files[dev->fd].dev = dev;
-
-    printk("fd(%d) = posix_openpt\n", dev->fd);
-    return(dev->fd);
+    return fd;
 }
 
 int open_savefile(const char *path, int save)
 {
-    struct consfront_dev *dev;
+    int fd;
     char nodename[64];
 
     snprintf(nodename, sizeof(nodename), "device/console/%d", save ? SAVE_CONSOLE : RESTORE_CONSOLE);
 
-    dev = init_consfront(nodename);
-    dev->fd = alloc_fd(FTYPE_SAVEFILE);
-    files[dev->fd].dev = dev;
+    fd = open_consfront(nodename);
+    printk("fd(%d) = open_savefile\n", fd);
 
-    printk("fd(%d) = open_savefile\n", dev->fd);
-    return(dev->fd);
+    return fd;
 }
 #else
 int posix_openpt(int flags)
@@ -291,20 +289,6 @@ int read(int fd, void *buf, size_t nbytes)
         return ops->read(file, buf, nbytes);
 
     switch (file->type) {
-        case FTYPE_SAVEFILE:
-	case FTYPE_CONSOLE: {
-	    int ret;
-            DEFINE_WAIT(w);
-            while(1) {
-                add_waiter(w, console_queue);
-                ret = xencons_ring_recv(files[fd].dev, buf, nbytes);
-                if (ret)
-                    break;
-                schedule();
-            }
-            remove_waiter(w, console_queue);
-            return ret;
-        }
 #ifdef HAVE_LWIP
         case FTYPE_SOCKET:
 	    return lwip_read(files[fd].fd, buf, nbytes);
@@ -332,18 +316,6 @@ int write(int fd, const void *buf, size_t nbytes)
         return ops->write(file, buf, nbytes);
 
     switch (file->type) {
-        case FTYPE_SAVEFILE: {
-                int ret = 0, tot = nbytes;
-                while (nbytes > 0) {
-                    ret = xencons_ring_send(files[fd].dev, (char *)buf, nbytes);
-                    nbytes -= ret;
-                    buf = (char *)buf + ret;
-                }
-                return tot - nbytes;
-            }
-	case FTYPE_CONSOLE:
-	    console_print(files[fd].dev, (char *)buf, nbytes);
-	    return nbytes;
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
 	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
@@ -446,12 +418,6 @@ int close(int fd)
 	case FTYPE_SOCKET:
             res = lwip_close(files[fd].fd);
             break;
-#endif
-#ifdef CONFIG_CONSFRONT
-        case FTYPE_SAVEFILE:
-        case FTYPE_CONSOLE:
-            fini_consfront(files[fd].dev);
-            break;
 #endif
 	case FTYPE_NONE:
             goto error;
@@ -501,15 +467,8 @@ int fstat(int fd, struct stat *buf)
         return ops->fstat(file, buf);
 
     switch (file->type) {
-	case FTYPE_SAVEFILE:
-	case FTYPE_CONSOLE:
 	case FTYPE_SOCKET: {
-            if (files[fd].type == FTYPE_CONSOLE)
-                buf->st_mode = S_IFCHR|S_IRUSR|S_IWUSR;
-            else if (files[fd].type == FTYPE_SOCKET)
-                buf->st_mode = S_IFSOCK|S_IRUSR|S_IWUSR;
-            else if (files[fd].type == FTYPE_SAVEFILE)
-                buf->st_mode = S_IFREG|S_IRUSR|S_IWUSR;
+            buf->st_mode = S_IFSOCK|S_IRUSR|S_IWUSR;
 	    buf->st_uid = 0;
 	    buf->st_gid = 0;
 	    buf->st_size = 0;
@@ -630,7 +589,6 @@ int closedir(DIR *dir)
 #if defined(LIBC_DEBUG) || defined(LIBC_VERBOSE)
 static const char *const file_types[] = {
     [FTYPE_NONE]    = "none",
-    [FTYPE_CONSOLE] = "console",
     [FTYPE_SOCKET]  = "socket",
 };
 
@@ -799,21 +757,18 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
             }
 
 	    if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
+            {
 		printk("bogus fd %d in select\n", i);
-	    /* Fallthrough.  */
-        }
-
-	case FTYPE_CONSOLE:
-	    if (FD_ISSET(i, readfds)) {
-                if (xencons_ring_avail(files[i].dev))
-		    n++;
-		else
-		    FD_CLR(i, readfds);
+                if ( FD_ISSET(i, readfds) )
+                    FD_CLR(i, readfds);
+                if ( FD_ISSET(i, writefds) )
+                    FD_CLR(i, writefds);
+                if ( FD_ISSET(i, exceptfds) )
+                    FD_CLR(i, exceptfds);
             }
-	    if (FD_ISSET(i, writefds))
-                n++;
-	    FD_CLR(i, exceptfds);
 	    break;
+        }
+
 #ifdef HAVE_LWIP
 	case FTYPE_SOCKET:
 	    if (FD_ISSET(i, readfds)) {
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:31 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256067.443465 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-00068C-II; Sun, 16 Jan 2022 16:40:30 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256067.443465; Sun, 16 Jan 2022 16:40:30 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zx-00066h-UZ; Sun, 16 Jan 2022 16:40:29 +0000
Received: by outflank-mailman (input) for mailman id 256067;
 Tue, 11 Jan 2022 20:10:55 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=hOY/=R3=aquilenet.fr=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n7NTr-0003ex-Qg
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:10:55 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 94eb3cd9-731a-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 21:10:54 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 09279678;
 Tue, 11 Jan 2022 21:10:54 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id evAtEMHPfxFY; Tue, 11 Jan 2022 21:10:53 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 48C8A261;
 Tue, 11 Jan 2022 21:10:53 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@aquilenet.fr>) id 1n7NTo-00FFQB-6e;
 Tue, 11 Jan 2022 21:10:52 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 94eb3cd9-731a-11ec-81c1-a30af7de8005
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Tue, 11 Jan 2022 21:10:52 +0100
From: Samuel Thibault <samuel.thibault@aquilenet.fr>
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
Subject: Re: [PATCH v2 17/18] mini-os: use function vectors instead of switch
 for file operations
Message-ID: <20220111201052.act2l5f5vt6gs4fn@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@aquilenet.fr>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220111200547.wb6mwl6zxtf3y54c@begin>
 <20220111145817.22170-18-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 09279678
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

On second thought:

Juergen Gross, le mar. 11 janv. 2022 15:58:16 +0100, a ecrit:
> +typedef int file_read_func(int fd, void *buf, size_t nbytes);
> +typedef int file_write_func(int fd, const void *buf, size_t nbytes);
> +typedef off_t file_lseek_func(int fd, off_t offset, int whence);
> +typedef int file_close_func(int fd);
> +typedef int file_fstat_func(int fd, struct stat *buf);
> +typedef int file_fcntl_func(int fd, int cmd, va_list args);
> +typedef bool file_select_func(int fd);

Is this really useful to pass to the functions the int fd, rather than
directly passing the file*?

Samuel


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:31 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255991.443444 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zx-00062r-Sl; Sun, 16 Jan 2022 16:40:29 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255991.443444; Sun, 16 Jan 2022 16:40:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zx-00061q-DD; Sun, 16 Jan 2022 16:40:29 +0000
Received: by outflank-mailman (input) for mailman id 255991;
 Tue, 11 Jan 2022 18:11:53 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=JwWh=R3=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7Lcf-00012C-4n
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 18:11:53 +0000
Received: from ppsw-42.csi.cam.ac.uk (ppsw-42.csi.cam.ac.uk [131.111.8.142])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id f37d81d2-7309-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 19:11:52 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:46994)
 by ppsw-42.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.138]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7Lcd-000ZEL-8F (Exim 4.95) (return-path <amc96@srcf.net>);
 Tue, 11 Jan 2022 18:11:51 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id 4DAA91FBFC;
 Tue, 11 Jan 2022 18:11:51 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: f37d81d2-7309-11ec-9ce5-af14b9085ebd
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <d70d8cb3-c34f-23f5-840c-c85a90547924@srcf.net>
Date: Tue, 11 Jan 2022 18:11:51 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Subject: Re: [PATCH v2 16/18] mini-os: reset file type in close() in one place
 only
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-17-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <20220111145817.22170-17-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

On 11/01/2022 14:58, Juergen Gross wrote:
> diff --git a/lib/sys.c b/lib/sys.c
> index 0e6fe5d..323a7cd 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -424,87 +424,82 @@ int fsync(int fd) {
>  
>  int close(int fd)
>  {
> +    int res = 0;
> +
>      printk("close(%d)\n", fd);
>      switch (files[fd].type) {
>          default:
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #ifdef CONFIG_XENBUS
>  	case FTYPE_XENBUS:
>              xs_daemon_close((void*)(intptr_t) fd);
> -            return 0;
> +            break;
>  #endif
>  #ifdef HAVE_LWIP
> -	case FTYPE_SOCKET: {
> -	    int res = lwip_close(files[fd].fd);
> -	    files[fd].type = FTYPE_NONE;
> -	    return res;
> -	}
> +	case FTYPE_SOCKET:
> +	    res = lwip_close(files[fd].fd);

Hard tabs.

> +            break;
>  #endif
>  #ifdef CONFIG_LIBXENCTRL
>  	case FTYPE_XC:
>  	    minios_interface_close_fd(fd);
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_LIBXENEVTCHN
>  	case FTYPE_EVTCHN:
>  	    minios_evtchn_close_fd(fd);
> -            return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_LIBXENGNTTAB
>  	case FTYPE_GNTMAP:
>  	    minios_gnttab_close_fd(fd);
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_NETFRONT
>  	case FTYPE_TAP:
>  	    shutdown_netfront(files[fd].dev);
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_BLKFRONT
>  	case FTYPE_BLK:
>              shutdown_blkfront(files[fd].dev);
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_TPMFRONT
>  	case FTYPE_TPMFRONT:
>              shutdown_tpmfront(files[fd].dev);
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_TPM_TIS
>  	case FTYPE_TPM_TIS:
>              shutdown_tpm_tis(files[fd].dev);
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_KBDFRONT
>  	case FTYPE_KBD:
>              shutdown_kbdfront(files[fd].dev);
> -            files[fd].type = FTYPE_NONE;
> -            return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_FBFRONT
>  	case FTYPE_FB:
>              shutdown_fbfront(files[fd].dev);
> -            files[fd].type = FTYPE_NONE;
> -            return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_CONSFRONT
>          case FTYPE_SAVEFILE:
>          case FTYPE_CONSOLE:
>              fini_consfront(files[fd].dev);
> -            files[fd].type = FTYPE_NONE;
> -            return 0;
> +            break;
>  #endif
>  	case FTYPE_NONE:
> -	    break;
> +            printk("close(%d): Bad descriptor\n", fd);
> +            errno = EBADF;
> +            return -1;
>      }
> -    printk("close(%d): Bad descriptor\n", fd);
> -    errno = EBADF;
> -    return -1;
> +
> +    memset(files + fd, 0, sizeof(struct file));
> +    files[fd].type = FTYPE_NONE;

BUILD_BUG_ON(FTYPE_NONE != 0);

Life's too short to deal with a theoretical (and short sighted) future
where someone might want to change FTYPE_NONE away from being 0.

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:31 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256533.443495 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zz-0006OT-OA; Sun, 16 Jan 2022 16:40:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256533.443495; Sun, 16 Jan 2022 16:40:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zz-0006MF-4l; Sun, 16 Jan 2022 16:40:31 +0000
Received: by outflank-mailman (input) for mailman id 256533;
 Wed, 12 Jan 2022 11:23:47 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=BEGY=R4=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7bjH-0007n0-5a
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 11:23:47 +0000
Received: from ppsw-32.csi.cam.ac.uk (ppsw-32.csi.cam.ac.uk [131.111.8.132])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 1ac61e07-739a-11ec-9c70-5536b2d1e4e1;
 Wed, 12 Jan 2022 12:23:45 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:48274)
 by ppsw-32.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.136]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7bjF-000d9t-08 (Exim 4.95) (return-path <amc96@srcf.net>);
 Wed, 12 Jan 2022 11:23:45 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id CE14A1FA84;
 Wed, 12 Jan 2022 11:23:44 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 1ac61e07-739a-11ec-9c70-5536b2d1e4e1
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <bfa154a6-88e3-8ce9-d959-7220ea7a7e64@srcf.net>
Date: Wed, 12 Jan 2022 11:23:44 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-10-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
Subject: Re: [PATCH v2 09/12] mini-os: use file_ops and get_file_from_fd() for
 console
In-Reply-To: <20220111151215.22955-10-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 11/01/2022 15:12, Juergen Gross wrote:
> +static int savefile_write(int fd, const void *buf, size_t nbytes)
> +{
> +    int ret = 0, tot = nbytes;
> +    struct file *file = get_file_from_fd(fd);
> +
> +    while ( nbytes > 0 )
> +    {
> +        ret = xencons_ring_send(file->dev, (char *)buf, nbytes);
> +        nbytes -= ret;
> +        buf = (char *)buf + ret;
> +    }
> +
> +    return tot - nbytes;
> +}
> +
> +static int console_write(int fd, const void *buf, size_t nbytes)
> +{
> +    struct file *file = get_file_from_fd(fd);
> +
> +    console_print(file->dev, (char *)buf, nbytes);

I've just noticed this while committing the previous series, and I know
it is a preexisting bug, but the casts here are utterly unsafe, because
they're casting away constness.

console_print() is easy to fix, and just requires a prototype
adjustment.  That said, it also desperately also needs to fix 'int
length' to size_t to avoid problems with negative length VLAs on the stack.

xencons_ring_send() already takes const char *, so I'm pretty sure you
can just drop the casts here.  It too ought to not truncate size_t bytes
to "unsigned".

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:31 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255297.443436 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zx-00061P-GR; Sun, 16 Jan 2022 16:40:29 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255297.443436; Sun, 16 Jan 2022 16:40:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zx-00061G-8S; Sun, 16 Jan 2022 16:40:29 +0000
Received: by outflank-mailman (input) for mailman id 255297;
 Mon, 10 Jan 2022 11:35:18 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=RiBW=R2=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n6sxK-00006K-74
 for minios-devel@lists.xenproject.org; Mon, 10 Jan 2022 11:35:18 +0000
Received: from ppsw-43.csi.cam.ac.uk (ppsw-43.csi.cam.ac.uk [131.111.8.143])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 6145abf4-7209-11ec-81c1-a30af7de8005;
 Mon, 10 Jan 2022 12:35:16 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:50276)
 by ppsw-43.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.139]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n6sxG-000Iau-pO (Exim 4.95) (return-path <amc96@srcf.net>);
 Mon, 10 Jan 2022 11:35:14 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id 80DD81FBEE;
 Mon, 10 Jan 2022 11:35:14 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 6145abf4-7209-11ec-81c1-a30af7de8005
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <25899482-4b0c-5fb4-5b02-226f75d1e5a6@srcf.net>
Date: Mon, 10 Jan 2022 11:35:14 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Subject: Re: [PATCH 0/2] mini-os: remove device specific struct file members
Content-Language: en-GB
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org, wl@xen.org
References: <20220107104706.9859-1-jgross@suse.com>
 <20220109011603.bymferaebanvvmud@begin>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <20220109011603.bymferaebanvvmud@begin>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

On 09/01/2022 01:16, Samuel Thibault wrote:
> Juergen Gross, le ven. 07 janv. 2022 11:47:04 +0100, a ecrit:
>> can only be applied after the Xen libraries have stopped using the
>> related union members.
> Ah, ok :) Was that submitted somewhere?

https://lore.kernel.org/xen-devel/20220107103544.9271-1-jgross@suse.com/T/#u

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:31 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256355.443484 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zz-0006IO-4P; Sun, 16 Jan 2022 16:40:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256355.443484; Sun, 16 Jan 2022 16:40:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-0006Fd-LE; Sun, 16 Jan 2022 16:40:30 +0000
Received: by outflank-mailman (input) for mailman id 256355;
 Wed, 12 Jan 2022 08:12:50 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=BEGY=R4=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7YkU-0007yg-LA
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 08:12:50 +0000
Received: from ppsw-32.csi.cam.ac.uk (ppsw-32.csi.cam.ac.uk [131.111.8.132])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 6d3635b0-737f-11ec-9ce5-af14b9085ebd;
 Wed, 12 Jan 2022 09:12:48 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:48186)
 by ppsw-32.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.136]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7YkQ-000zOW-2r (Exim 4.95) (return-path <amc96@srcf.net>);
 Wed, 12 Jan 2022 08:12:46 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id AB30E1FD4B;
 Wed, 12 Jan 2022 08:12:46 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 6d3635b0-737f-11ec-9ce5-af14b9085ebd
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <3124ed39-ba23-ccd1-a036-67032f36c0b7@srcf.net>
Date: Wed, 12 Jan 2022 08:12:46 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Subject: Re: [PATCH v2 03/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in xs
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-4-jgross@suse.com>
 <a41f6688-d14a-dad5-1625-1b98f793062e@srcf.net>
 <501262b0-510b-3add-35a6-2f2ad7452518@suse.com>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <501262b0-510b-3add-35a6-2f2ad7452518@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 12/01/2022 07:52, Juergen Gross wrote:
> On 11.01.22 21:21, Andrew Cooper wrote:
>> On 11/01/2022 15:12, Juergen Gross wrote:
>>>   void xs_daemon_close(struct xs_handle *h)
>>>   {
>>> -    int fd = _xs_fileno(h);
>>> -    struct xenbus_event *event, *next;
>>> -    for (event = files[fd].dev; event; event = next)
>>> -    {
>>> -        next = event->next;
>>> -        free(event);
>>> -    }
>>> +    close(_xs_fileno(h));
>>>   }
>>
>> You've deleted the sole caller of xs_daemon_close() from the main
>> close() function.
>>
>> That said, I'm very confused, because nothing in minios declares it.
>> The declaration appears to come from xenstore.h, which is clearly
>> included unconditionally (when it ought not to be), but libxenstore also
>> defines the function too...
> I already thought of restructuring this mess.
>
> lib/xs.c is the Mini-OS variant of libxenstore, and as such it shares
> quite some code with libxenstore.
>
> So the correct thing to do would be to split libxenstore into a common
> part and a posix/Mini-OS part, drop lib/xs.c, and use the library in
> Mini-OS instead.
>
> But this should be done in a separate series.

Sounds like a plan.

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:31 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255987.443438 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zx-00061t-Js; Sun, 16 Jan 2022 16:40:29 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255987.443438; Sun, 16 Jan 2022 16:40:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zx-00061U-AW; Sun, 16 Jan 2022 16:40:29 +0000
Received: by outflank-mailman (input) for mailman id 255987;
 Tue, 11 Jan 2022 18:08:32 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=JwWh=R3=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7LZP-00085x-Vt
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 18:08:32 +0000
Received: from ppsw-33.csi.cam.ac.uk (ppsw-33.csi.cam.ac.uk [131.111.8.133])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 7a427b31-7309-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 19:08:29 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:47534)
 by ppsw-33.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.137]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7LZM-000UMP-gA (Exim 4.95) (return-path <amc96@srcf.net>);
 Tue, 11 Jan 2022 18:08:28 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id C9966208DF;
 Tue, 11 Jan 2022 18:08:27 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7a427b31-7309-11ec-9ce5-af14b9085ebd
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <a2d4c905-c477-8553-85a7-90168d914b6e@srcf.net>
Date: Tue, 11 Jan 2022 18:08:27 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-18-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
Subject: Re: [PATCH v2 17/18] mini-os: use function vectors instead of switch
 for file operations
In-Reply-To: <20220111145817.22170-18-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 11/01/2022 14:58, Juergen Gross wrote:
> Introduce file type specific function vectors for all the needed file
> operations which are file type specific in order to prepare replacing
> the large switch statements in each generic file function.
>
> Add a function to allocate a new file type dynamically in order to
> prepare removing direct dependencies to external components in the
> future. For this reason switch the file type from an enum to an
> unsigned int. Prepare removal of some statically defines file types
> by putting them at the end of the defined list.
>
> Change the debug output for the file type from a single character to
> a string in order to support a future removal of the file_types[]
> array.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>

A few misc observations.

> diff --git a/include/lib.h b/include/lib.h
> index 7a0546b..b40e213 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -154,25 +155,51 @@ do {                                                           \
>  void sanity_check(void);
>  
>  #ifdef HAVE_LIBC
> -enum fd_type {
> -    FTYPE_NONE = 0,
> -    FTYPE_CONSOLE,
> -    FTYPE_FILE,
> -    FTYPE_XENBUS,
> -    FTYPE_XC,
> -    FTYPE_EVTCHN,
> -    FTYPE_GNTMAP,
> -    FTYPE_SOCKET,
> -    FTYPE_TAP,
> -    FTYPE_BLK,
> -    FTYPE_KBD,
> -    FTYPE_FB,
> -    FTYPE_MEM,
> -    FTYPE_SAVEFILE,
> -    FTYPE_TPMFRONT,
> -    FTYPE_TPM_TIS,
> +#define FTYPE_NONE       0
> +#define FTYPE_CONSOLE    1
> +#define FTYPE_FILE       2
> +#define FTYPE_SOCKET     3
> +#define FTYPE_MEM        4
> +#define FTYPE_SAVEFILE   5
> +#define FTYPE_FB         6
> +#define FTYPE_KBD        7
> +#define FTYPE_TAP        8
> +#define FTYPE_BLK        9
> +#define FTYPE_TPMFRONT  10
> +#define FTYPE_TPM_TIS   11
> +#define FTYPE_XENBUS    12
> +#define FTYPE_GNTMAP    13
> +#define FTYPE_EVTCHN    14
> +#define FTYPE_XC        15
> +#define FTYPE_N         16
> +#define FTYPE_SPARE     16
> +
> +typedef int file_read_func(int fd, void *buf, size_t nbytes);
> +typedef int file_write_func(int fd, const void *buf, size_t nbytes);
> +typedef off_t file_lseek_func(int fd, off_t offset, int whence);
> +typedef int file_close_func(int fd);
> +typedef int file_fstat_func(int fd, struct stat *buf);
> +typedef int file_fcntl_func(int fd, int cmd, va_list args);
> +typedef bool file_select_func(int fd);

Are these typedef's useful?  I don't see them used anywhere other than
the file_ops structure.

> +
> +struct file_ops {
> +    const char *name;
> +    file_read_func *read;
> +    file_write_func *write;
> +    file_lseek_func *lseek;
> +    file_close_func *close;
> +    file_fstat_func *fstat;
> +    file_fcntl_func *fcntl;
> +    file_select_func *select_rd;
> +    file_select_func *select_wr;
>  };
>  
> +unsigned int alloc_file_type(struct file_ops *ops);

const.

> +
> +off_t lseek_default(int fd, off_t offset, int whence);
> +bool select_yes(int fd);
> +bool select_read_flag(int fd);
> +
>  LIST_HEAD(evtchn_port_list, evtchn_port_info);
>  
>  struct evtchn_port_info {
> @@ -183,7 +210,7 @@ struct evtchn_port_info {
>  };
>  
>  struct file {
> -    enum fd_type type;
> +    unsigned int type;
>      bool read;	/* maybe available for read */
>      off_t offset;
>      union {
> @@ -199,7 +226,7 @@ struct file {
>  extern struct file files[];
>  
>  struct file *get_file_from_fd(int fd);
> -int alloc_fd(enum fd_type type);
> +int alloc_fd(unsigned int type);
>  void close_all_files(void);
>  extern struct thread *main_thread;
>  void sparse(unsigned long data, size_t size);
> diff --git a/lib/sys.c b/lib/sys.c
> index 323a7cd..c327247 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -98,6 +98,39 @@ struct file files[NOFILE] = {
>      { .type = FTYPE_CONSOLE }, /* stderr */
>  };
>  
> +static struct file_ops file_ops_none = {
> +    .name = "none",
> +};
> +
> +static struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
> +    [FTYPE_NONE] = &file_ops_none,
> +};

Both want to be const, because all file_ops ought to live in rodata.

> +
> +unsigned int alloc_file_type(struct file_ops *ops)
> +{
> +    unsigned int i;
> +
> +    pthread_mutex_lock(&fd_lock);
> +
> +    for ( i = FTYPE_N; i < ARRAY_SIZE(file_ops) && file_ops[i]; i++ );

No need for a for loop.  Given the mutex, you can safely do something
like this:

static unsigned int i = FTYPE_N;

BUG_ON(i == ARRAY_SIZE(file_ops));
file_ops[i++] = ops;

Alternatively, if you do want to keep the loop, we might want to confirm
that the same ops structure doesn't get registered twice.

> +    BUG_ON(i == ARRAY_SIZE(file_ops));
> +    file_ops[i] = ops;
> +
> +    pthread_mutex_unlock(&fd_lock);
> +
> +    printk("New file type \"%s\"(%u) allocated\n", ops->name, i);
> +
> +    return i;
> +}
> +
> +static struct file_ops *get_file_ops(unsigned int type)
> +{
> +    if ( type >= ARRAY_SIZE(file_ops) || !file_ops[type] )
> +        return &file_ops_none;
> +
> +    return file_ops[type];
> +}
> +
>  struct file *get_file_from_fd(int fd)
>  {
>      if ( fd < 0 || fd >= NOFILE )
> @@ -108,7 +141,7 @@ struct file *get_file_from_fd(int fd)
>  
>  DECLARE_WAIT_QUEUE_HEAD(event_queue);
>  
> -int alloc_fd(enum fd_type type)
> +int alloc_fd(unsigned int type)
>  {
>      int i;
>      pthread_mutex_lock(&fd_lock);
> @@ -249,6 +282,11 @@ int isatty(int fd)
>  
>  int read(int fd, void *buf, size_t nbytes)
>  {
> +    struct file_ops *ops = get_file_ops(files[fd].type);
> +
> +    if ( ops->read )
> +        return ops->read(fd, buf, nbytes);
> +
>      switch (files[fd].type) {
>          case FTYPE_SAVEFILE:
>  	case FTYPE_CONSOLE: {
> @@ -328,6 +366,11 @@ int read(int fd, void *buf, size_t nbytes)
>  
>  int write(int fd, const void *buf, size_t nbytes)
>  {
> +    struct file_ops *ops = get_file_ops(files[fd].type);
> +
> +    if ( ops->write )
> +        return ops->write(fd, buf, nbytes);
> +
>      switch (files[fd].type) {
>          case FTYPE_SAVEFILE: {
>                  int ret = 0, tot = nbytes;
> @@ -370,8 +413,45 @@ int write(int fd, const void *buf, size_t nbytes)
>      return -1;
>  }
>  
> +off_t lseek_default(int fd, off_t offset, int whence)
> +{
> +    switch ( whence )
> +    {
> +    case SEEK_SET:
> +        files[fd].offset = offset;
> +        break;
> +
> +    case SEEK_CUR:
> +        files[fd].offset += offset;
> +        break;
> +
> +    case SEEK_END:
> +    {
> +        struct stat st;
> +        int ret;
> +
> +        ret = fstat(fd, &st);
> +        if ( ret )
> +            return -1;
> +        files[fd].offset = st.st_size + offset;
> +        break;
> +    }
> +
> +    default:
> +        errno = EINVAL;
> +        return -1;
> +    }
> +
> +    return files[fd].offset;
> +}
> +
>  off_t lseek(int fd, off_t offset, int whence)
>  {
> +    struct file_ops *ops = get_file_ops(files[fd].type);
> +
> +    if ( ops->lseek )
> +        return ops->lseek(fd, offset, whence);
> +
>      switch(files[fd].type) {
>  #ifdef CONFIG_BLKFRONT
>         case FTYPE_BLK:
> @@ -393,28 +473,7 @@ off_t lseek(int fd, off_t offset, int whence)
>            return (off_t) -1;
>      }
>  
> -    switch (whence) {
> -       case SEEK_SET:
> -          files[fd].offset = offset;
> -          break;
> -       case SEEK_CUR:
> -          files[fd].offset += offset;
> -          break;
> -       case SEEK_END:
> -          {
> -             struct stat st;
> -             int ret;
> -             ret = fstat(fd, &st);
> -             if (ret)
> -                return -1;
> -             files[fd].offset = st.st_size + offset;
> -             break;
> -          }
> -       default:
> -          errno = EINVAL;
> -          return -1;
> -    }
> -    return files[fd].offset;
> +    return lseek_default(fd, offset, whence);
>  }
>  
>  int fsync(int fd) {
> @@ -425,8 +484,15 @@ int fsync(int fd) {
>  int close(int fd)
>  {
>      int res = 0;
> +    struct file_ops *ops = get_file_ops(files[fd].type);
>  
>      printk("close(%d)\n", fd);
> +    if ( ops->close )
> +    {
> +        res = ops->close(fd);
> +        goto out;
> +    }
> +
>      switch (files[fd].type) {
>          default:
>              break;
> @@ -497,6 +563,7 @@ int close(int fd)
>              return -1;
>      }
>  
> + out:
>      memset(files + fd, 0, sizeof(struct file));
>      files[fd].type = FTYPE_NONE;
>      return res;
> @@ -521,7 +588,13 @@ int stat(const char *path, struct stat *buf)
>  
>  int fstat(int fd, struct stat *buf)
>  {
> +    struct file_ops *ops = get_file_ops(files[fd].type);
> +
>      init_stat(buf);
> +
> +    if ( ops->fstat )
> +        return ops->fstat(fd, buf);
> +
>      switch (files[fd].type) {
>  	case FTYPE_SAVEFILE:
>  	case FTYPE_CONSOLE:
> @@ -587,6 +660,18 @@ int fcntl(int fd, int cmd, ...)
>  {
>      long arg;
>      va_list ap;
> +    int res;
> +    struct file_ops *ops = get_file_ops(files[fd].type);
> +
> +    if ( ops->fcntl )
> +    {
> +        va_start(ap, cmd);
> +        res = ops->fcntl(fd, cmd, ap);
> +        va_end(ap);
> +
> +        return res;
> +    }
> +
>      va_start(ap, cmd);
>      arg = va_arg(ap, long);
>      va_end(ap);
> @@ -640,18 +725,29 @@ int closedir(DIR *dir)
>  /* We assume that only the main thread calls select(). */
>  
>  #if defined(LIBC_DEBUG) || defined(LIBC_VERBOSE)
> -static const char file_types[] = {
> -    [FTYPE_NONE]	= 'N',
> -    [FTYPE_CONSOLE]	= 'C',
> -    [FTYPE_XENBUS]	= 'S',
> -    [FTYPE_XC]		= 'X',
> -    [FTYPE_EVTCHN]	= 'E',
> -    [FTYPE_SOCKET]	= 's',
> -    [FTYPE_TAP]		= 'T',
> -    [FTYPE_BLK]		= 'B',
> -    [FTYPE_KBD]		= 'K',
> -    [FTYPE_FB]		= 'G',
> +static const char *file_types[] = {

static const char *const file_types[]

> +    [FTYPE_NONE]    = "none",
> +    [FTYPE_CONSOLE] = "console",
> +    [FTYPE_XENBUS]  = "xenbus",
> +    [FTYPE_XC]      = "ctrl",
> +    [FTYPE_EVTCHN]  = "evtchn",
> +    [FTYPE_SOCKET]  = "socket",
> +    [FTYPE_TAP]     = "net",
> +    [FTYPE_BLK]     = "blk",
> +    [FTYPE_KBD]     = "kbd",
> +    [FTYPE_FB]      = "fb",
>  };
> +
> +static char *get_type_name(unsigned int type)

const.

> +{
> +    if ( type < ARRAY_SIZE(file_ops) && file_ops[type] )
> +        return file_ops[type]->name;
> +
> +    if ( type < ARRAY_SIZE(file_types) && file_types[type] )
> +        return file_types[type];
> +
> +    return "none";
> +}
>  #endif
>  #ifdef LIBC_DEBUG
>  static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
> @@ -663,7 +759,7 @@ static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *except
>  	if (FD_ISSET(i, set)) { \
>  	    if (comma) \
>  		printk(", "); \
> -	    printk("%d(%c)", i, file_types[files[i].type]); \
> +	    printk("%d(%s)", i, get_type_name(files[i].type)); \
>  	    comma = 1; \
>  	} \
>      } \
> @@ -697,7 +793,7 @@ static void dump_pollfds(struct pollfd *pfd, int nfds, int timeout)
>          fd = pfd[i].fd;
>          if (comma)
>              printk(", ");
> -        printk("%d(%c)/%02x", fd, file_types[files[fd].type],
> +        printk("%d(%s)/%02x", fd, get_type_name(files[fd].type),
>              pfd[i].events);
>              comma = 1;
>      }
> @@ -709,6 +805,18 @@ static void dump_pollfds(struct pollfd *pfd, int nfds, int timeout)
>  #define dump_pollfds(pfds, nfds, timeout)
>  #endif
>  
> +bool select_yes(int fd)
> +{
> +    return true;
> +}
> +
> +bool select_read_flag(int fd)
> +{
> +    struct file *file = get_file_from_fd(fd);
> +
> +    return file->read;
> +}

I don't see these getting used, even in a fallback case.

> +
>  /* Just poll without blocking */
>  static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
>  {
> @@ -762,9 +870,35 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>      for (i = 0; i < nfds; i++) {
>  	switch(files[i].type) {
>  	default:
> +        {
> +            struct file_ops *ops = file_ops[files[i].type];
> +
> +            if ( ops )
> +            {
> +                if ( FD_ISSET(i, readfds) )
> +                {
> +                    if ( ops->select_rd && ops->select_rd(i) )
> +                        n++;
> +                    else
> +                        FD_CLR(i, readfds);
> +                }
> +                if ( FD_ISSET(i, writefds) )
> +                {
> +                    if ( ops->select_wr && ops->select_wr(i) )
> +                        n++;
> +                    else
> +                        FD_CLR(i, writefds);
> +                }
> +	        FD_CLR(i, exceptfds);

Hard tab.

> +
> +                break;
> +            }
> +
>  	    if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
>  		printk("bogus fd %d in select\n", i);
>  	    /* Fallthrough.  */
> +        }

Is this fallthrough really appropriate, given the break in the ops case?

~Andrew

> +
>  	case FTYPE_CONSOLE:
>  	    if (FD_ISSET(i, readfds)) {
>                  if (xencons_ring_avail(files[i].dev))
> @@ -842,7 +976,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  	printk("%d(%d): ", nb, sock_n);
>  	for (i = 0; i < nfds; i++) {
>  	    if (nbread[i] || nbwrite[i] || nbexcept[i])
> -		printk(" %d(%c):", i, file_types[files[i].type]);
> +		printk(" %d(%c):", i, get_type_name(files[i].type));
>  	    if (nbread[i])
>  	    	printk(" %dR", nbread[i]);
>  	    if (nbwrite[i])



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:31 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256119.443482 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zz-0006G7-38; Sun, 16 Jan 2022 16:40:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256119.443482; Sun, 16 Jan 2022 16:40:30 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-0006E8-H6; Sun, 16 Jan 2022 16:40:30 +0000
Received: by outflank-mailman (input) for mailman id 256119;
 Tue, 11 Jan 2022 20:29:21 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=JwWh=R3=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7Nlh-0002eZ-PL
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:29:21 +0000
Received: from ppsw-43.csi.cam.ac.uk (ppsw-43.csi.cam.ac.uk [131.111.8.143])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 2700172c-731d-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 21:29:19 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:50744)
 by ppsw-43.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.139]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7Nld-0005BJ-pA (Exim 4.95) (return-path <amc96@srcf.net>);
 Tue, 11 Jan 2022 20:29:17 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id 8FF011FDB6;
 Tue, 11 Jan 2022 20:29:17 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 2700172c-731d-11ec-81c1-a30af7de8005
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <95614df8-c22d-3e1e-b976-84bbed1b30be@srcf.net>
Date: Tue, 11 Jan 2022 20:29:17 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org,
 Jason Andryuk <jandryuk@gmail.com>,
 Daniel Smith <dpsmith@apertussolutions.com>
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-5-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
Subject: Re: [PATCH v2 04/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in tpm_tis
In-Reply-To: <20220111151215.22955-5-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 11/01/2022 15:12, Juergen Gross wrote:
> diff --git a/tpm_tis.c b/tpm_tis.c
> index 477f555..abea7a1 100644
> --- a/tpm_tis.c
> +++ b/tpm_tis.c
> @@ -1093,6 +1097,23 @@ ssize_t tpm_getcap(struct tpm_chip *chip, uint32_t subcap_id, cap_t *cap,
>          return rc;
>  }
>  
> +static void shutdown_tpm_tis(struct tpm_chip* tpm){

Style, as you're moving it.  Also in the function.

> @@ -1360,6 +1369,35 @@ int tpm_tis_posix_fstat(int fd, struct stat* buf)
>     return 0;
>  }
>  
> +static struct file_ops tpm_tis_ops = {
> +    .name = "tpm_tis",
> +    .read = tpm_tis_posix_read,
> +    .write = tpm_tis_posix_write,
> +    .lseek = lseek_default,
> +    .close = tpm_tis_close,
> +    .fstat = tpm_tis_posix_fstat,
> +};
> +
> +int tpm_tis_open(struct tpm_chip* tpm)

Style.

> +{
> +   struct file *file;
> +   static unsigned int ftype_tis;
> +
> +   /* Silently prevent multiple opens */
> +   if(tpm->fd != -1) {
> +      return tpm->fd;
> +   }

Another WTF moment.  We silently swallow multiple open()s, but don't
refcout close()s ?

This cannot be correct, or sensible, behaviour.

Jason/Daniel - thoughts?

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:31 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256359.443489 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zz-0006JM-De; Sun, 16 Jan 2022 16:40:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256359.443489; Sun, 16 Jan 2022 16:40:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-0006Hn-Ps; Sun, 16 Jan 2022 16:40:30 +0000
Received: by outflank-mailman (input) for mailman id 256359;
 Wed, 12 Jan 2022 08:14:28 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=BEGY=R4=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7Ym4-000076-Js
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 08:14:28 +0000
Received: from ppsw-32.csi.cam.ac.uk (ppsw-32.csi.cam.ac.uk [131.111.8.132])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id a90ff6cb-737f-11ec-9ce5-af14b9085ebd;
 Wed, 12 Jan 2022 09:14:27 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:48188)
 by ppsw-32.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.136]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7Ym2-000zf0-2l (Exim 4.95) (return-path <amc96@srcf.net>);
 Wed, 12 Jan 2022 08:14:26 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id 9F3951FD4B;
 Wed, 12 Jan 2022 08:14:26 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: a90ff6cb-737f-11ec-9ce5-af14b9085ebd
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <3bcf4dff-4b8b-8ad2-c749-239ca68cce8b@srcf.net>
Date: Wed, 12 Jan 2022 08:14:26 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Subject: Re: [PATCH v2 04/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in tpm_tis
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org,
 Jason Andryuk <jandryuk@gmail.com>,
 Daniel Smith <dpsmith@apertussolutions.com>
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-5-jgross@suse.com>
 <95614df8-c22d-3e1e-b976-84bbed1b30be@srcf.net>
 <5dba49ab-e901-3ee2-daee-5758eccdd474@suse.com>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <5dba49ab-e901-3ee2-daee-5758eccdd474@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 12/01/2022 07:54, Juergen Gross wrote:
> On 11.01.22 21:29, Andrew Cooper wrote:
>> On 11/01/2022 15:12, Juergen Gross wrote:
>>> diff --git a/tpm_tis.c b/tpm_tis.c
>>> index 477f555..abea7a1 100644
>>> --- a/tpm_tis.c
>>> +++ b/tpm_tis.c
>>> @@ -1093,6 +1097,23 @@ ssize_t tpm_getcap(struct tpm_chip *chip,
>>> uint32_t subcap_id, cap_t *cap,
>>>           return rc;
>>>   }
>>>   +static void shutdown_tpm_tis(struct tpm_chip* tpm){
>>
>> Style, as you're moving it.  Also in the function.
>>
>>> @@ -1360,6 +1369,35 @@ int tpm_tis_posix_fstat(int fd, struct stat*
>>> buf)
>>>      return 0;
>>>   }
>>>   +static struct file_ops tpm_tis_ops = {
>>> +    .name = "tpm_tis",
>>> +    .read = tpm_tis_posix_read,
>>> +    .write = tpm_tis_posix_write,
>>> +    .lseek = lseek_default,
>>> +    .close = tpm_tis_close,
>>> +    .fstat = tpm_tis_posix_fstat,
>>> +};
>>> +
>>> +int tpm_tis_open(struct tpm_chip* tpm)
>>
>> Style.
>
> Ah, yes I should have corrected this while moving the function.
>
>>
>>> +{
>>> +   struct file *file;
>>> +   static unsigned int ftype_tis;
>>> +
>>> +   /* Silently prevent multiple opens */
>>> +   if(tpm->fd != -1) {
>>> +      return tpm->fd;
>>> +   }
>>
>> Another WTF moment.  We silently swallow multiple open()s, but don't
>> refcout close()s ?
>>
>> This cannot be correct, or sensible, behaviour.
>>
>> Jason/Daniel - thoughts?
>
> I just moved the function, but I can change this, of course.

It's a pattern elsewhere too.  Much as it's horrible logic, it probably
doesn't want reworking in a patch like this, and the series as a whole
is big enough so I'm not going to suggest you tackle it too.

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:31 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.255997.443447 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-00063J-0r; Sun, 16 Jan 2022 16:40:30 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 255997.443447; Sun, 16 Jan 2022 16:40:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zx-00062d-GN; Sun, 16 Jan 2022 16:40:29 +0000
Received: by outflank-mailman (input) for mailman id 255997;
 Tue, 11 Jan 2022 18:17:26 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=JwWh=R3=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7Li2-0001hA-50
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 18:17:26 +0000
Received: from ppsw-43.csi.cam.ac.uk (ppsw-43.csi.cam.ac.uk [131.111.8.143])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id b8ea3cf7-730a-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 19:17:24 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:50684)
 by ppsw-43.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.139]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7Lhy-000ltI-p7 (Exim 4.95) (return-path <amc96@srcf.net>);
 Tue, 11 Jan 2022 18:17:22 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id 9E1431FB3A;
 Tue, 11 Jan 2022 18:17:22 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: b8ea3cf7-730a-11ec-9ce5-af14b9085ebd
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <3bfba2a9-7951-3234-86c8-3be116c640b6@srcf.net>
Date: Tue, 11 Jan 2022 18:17:22 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Subject: Re: [PATCH v2 15/18] mini-os: introduce get_file_from_fd()
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-16-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <20220111145817.22170-16-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 11/01/2022 14:58, Juergen Gross wrote:
> diff --git a/lib/sys.c b/lib/sys.c
> index 6f2b026..0e6fe5d 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -98,6 +98,14 @@ struct file files[NOFILE] = {
>      { .type = FTYPE_CONSOLE }, /* stderr */
>  };
>  
> +struct file *get_file_from_fd(int fd)
> +{
> +    if ( fd < 0 || fd >= NOFILE )

fd >= ARRAY_SIZE(files)  ?

Generates slightly safer code in the event that `struct file
files[NOFILE]` gets refactored.

~Andrew

> +        return NULL;
> +
> +    return (files[fd].type == FTYPE_NONE) ? NULL : files + fd;
> +}
> +
>  DECLARE_WAIT_QUEUE_HEAD(event_queue);
>  
>  int alloc_fd(enum fd_type type)



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:31 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256540.443500 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zz-0006Pb-Qp; Sun, 16 Jan 2022 16:40:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256540.443500; Sun, 16 Jan 2022 16:40:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zz-0006Ny-7q; Sun, 16 Jan 2022 16:40:31 +0000
Received: by outflank-mailman (input) for mailman id 256540;
 Wed, 12 Jan 2022 11:25:32 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=BEGY=R4=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7bky-0008NS-CL
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 11:25:32 +0000
Received: from ppsw-32.csi.cam.ac.uk (ppsw-32.csi.cam.ac.uk [131.111.8.132])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 589fc3fb-739a-11ec-bd6f-bfb69f65cdc7;
 Wed, 12 Jan 2022 12:25:30 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:48276)
 by ppsw-32.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.136]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7bku-000dS9-3D (Exim 4.95) (return-path <amc96@srcf.net>);
 Wed, 12 Jan 2022 11:25:29 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id C266F1FD4D;
 Wed, 12 Jan 2022 11:25:28 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 589fc3fb-739a-11ec-bd6f-bfb69f65cdc7
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <37ade49f-e277-99a4-4dd7-e1e6cb327ffb@srcf.net>
Date: Wed, 12 Jan 2022 11:25:28 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Subject: Re: [PATCH v2 10/12] mini-os: add struct file_ops for file type
 socket
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-11-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <20220111151215.22955-11-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 11/01/2022 15:12, Juergen Gross wrote:
> +static int socket_write(int fd, const void *buf, size_t nbytes)
> +{
> +    return lwip_write(fd, (void *)buf, nbytes);

This void cast was bogus before, and can be dropped.  lwip_write()
already takes a const pointer.

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:32 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256546.443504 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zz-0006TE-UN; Sun, 16 Jan 2022 16:40:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256546.443504; Sun, 16 Jan 2022 16:40:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zz-0006Pl-CN; Sun, 16 Jan 2022 16:40:31 +0000
Received: by outflank-mailman (input) for mailman id 256546;
 Wed, 12 Jan 2022 11:28:36 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=BEGY=R4=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7bnw-0000cQ-Ms
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 11:28:36 +0000
Received: from ppsw-33.csi.cam.ac.uk (ppsw-33.csi.cam.ac.uk [131.111.8.133])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id c6955040-739a-11ec-9c70-5536b2d1e4e1;
 Wed, 12 Jan 2022 12:28:34 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:47746)
 by ppsw-33.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.137]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7bnt-000oaP-h6 (Exim 4.95) (return-path <amc96@srcf.net>);
 Wed, 12 Jan 2022 11:28:33 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id 003CF1FD4D;
 Wed, 12 Jan 2022 11:28:32 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: c6955040-739a-11ec-9c70-5536b2d1e4e1
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <659743cb-abc9-31b5-d6b2-0a21aa76bbb4@srcf.net>
Date: Wed, 12 Jan 2022 11:28:32 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Subject: Re: [PATCH v2 10/12] mini-os: add struct file_ops for file type
 socket
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-11-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <20220111151215.22955-11-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

On 11/01/2022 15:12, Juergen Gross wrote:
> diff --git a/lib/sys.c b/lib/sys.c
> index 3a8aa68..12deaed 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -99,11 +99,70 @@ static struct file_ops file_ops_none = {
>      .name = "none",
>  };
>  
> +#ifdef HAVE_LWIP
> +static int socket_read(int fd, void *buf, size_t nbytes)
> +{
> +    return lwip_read(fd, buf, nbytes);
> +}
> +
> +static int socket_write(int fd, const void *buf, size_t nbytes)
> +{
> +    return lwip_write(fd, (void *)buf, nbytes);
> +}
> +
> +static int close_socket_fd(int fd)
> +{
> +    struct file *file = get_file_from_fd(fd);
> +
> +    return lwip_close(file->fd);
> +}

Actually, on further thoughts...

> +static struct file_ops socket_ops = {
> +    .name = "socket",
> +    .read = socket_read,
> +    .write = socket_write,
> +    .close = close_socket_fd,
> +    .fstat = socket_fstat,
> +    .fcntl = socket_fcntl,
> +};

read, write and close should dispatch directly to lwip_* and not bounce
through a no-op local function.

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:32 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256579.443508 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98a0-0006Tz-3C; Sun, 16 Jan 2022 16:40:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256579.443508; Sun, 16 Jan 2022 16:40:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zz-0006Sw-HI; Sun, 16 Jan 2022 16:40:31 +0000
Received: by outflank-mailman (input) for mailman id 256579;
 Wed, 12 Jan 2022 11:33:34 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=BEGY=R4=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7bsk-0005Ah-0N
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 11:33:34 +0000
Received: from ppsw-42.csi.cam.ac.uk (ppsw-42.csi.cam.ac.uk [131.111.8.142])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 764bcac0-739b-11ec-9c70-5536b2d1e4e1;
 Wed, 12 Jan 2022 12:33:28 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:47212)
 by ppsw-42.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.138]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7bsd-000vfO-9a (Exim 4.95) (return-path <amc96@srcf.net>);
 Wed, 12 Jan 2022 11:33:27 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id CA57F1FD4B;
 Wed, 12 Jan 2022 11:33:27 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 764bcac0-739b-11ec-9c70-5536b2d1e4e1
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <0b8166db-7188-5620-15ed-02b7a0d5efa5@srcf.net>
Date: Wed, 12 Jan 2022 11:33:27 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Subject: Re: [PATCH v2 10/12] mini-os: add struct file_ops for file type
 socket
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-11-jgross@suse.com>
 <659743cb-abc9-31b5-d6b2-0a21aa76bbb4@srcf.net>
 <cf84e6f4-efcb-e206-5cc0-769fe6399de5@suse.com>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <cf84e6f4-efcb-e206-5cc0-769fe6399de5@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 12/01/2022 11:32, Juergen Gross wrote:
> On 12.01.22 12:28, Andrew Cooper wrote:
>> On 11/01/2022 15:12, Juergen Gross wrote:
>>> diff --git a/lib/sys.c b/lib/sys.c
>>> index 3a8aa68..12deaed 100644
>>> --- a/lib/sys.c
>>> +++ b/lib/sys.c
>>> @@ -99,11 +99,70 @@ static struct file_ops file_ops_none = {
>>>       .name = "none",
>>>   };
>>>   +#ifdef HAVE_LWIP
>>> +static int socket_read(int fd, void *buf, size_t nbytes)
>>> +{
>>> +    return lwip_read(fd, buf, nbytes);
>>> +}
>>> +
>>> +static int socket_write(int fd, const void *buf, size_t nbytes)
>>> +{
>>> +    return lwip_write(fd, (void *)buf, nbytes);
>>> +}
>>> +
>>> +static int close_socket_fd(int fd)
>>> +{
>>> +    struct file *file = get_file_from_fd(fd);
>>> +
>>> +    return lwip_close(file->fd);
>>> +}
>>
>> Actually, on further thoughts...
>>
>>> +static struct file_ops socket_ops = {
>>> +    .name = "socket",
>>> +    .read = socket_read,
>>> +    .write = socket_write,
>>> +    .close = close_socket_fd,
>>> +    .fstat = socket_fstat,
>>> +    .fcntl = socket_fcntl,
>>> +};
>>
>> read, write and close should dispatch directly to lwip_* and not bounce
>> through a no-op local function.
>
> Not with changing the first parameter to struct file *.

Oh, good point.

>
> BTW, this patch had a bug, as the calls need to use file->fd instead of
> fd.

Yay for multiple fd spaces.

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:32 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.254370.443430 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zx-00061B-Aw; Sun, 16 Jan 2022 16:40:29 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 254370.443430; Sun, 16 Jan 2022 16:40:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zx-000614-78; Sun, 16 Jan 2022 16:40:29 +0000
Received: by outflank-mailman (input) for mailman id 254370;
 Fri, 07 Jan 2022 11:30:53 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=VgWa=RX=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n5nSP-00020S-HR
 for minios-devel@lists.xenproject.org; Fri, 07 Jan 2022 11:30:53 +0000
Received: from ppsw-33.csi.cam.ac.uk (ppsw-33.csi.cam.ac.uk [131.111.8.133])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 441da359-6fad-11ec-9ce5-af14b9085ebd;
 Fri, 07 Jan 2022 12:30:51 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:46746)
 by ppsw-33.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.137]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n5nSM-000tnC-gP (Exim 4.95) (return-path <amc96@srcf.net>);
 Fri, 07 Jan 2022 11:30:50 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id DB11C1FA57;
 Fri,  7 Jan 2022 11:30:49 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 441da359-6fad-11ec-9ce5-af14b9085ebd
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <f1579294-4cc7-a685-0326-967444b69b86@srcf.net>
Date: Fri, 7 Jan 2022 11:30:49 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Subject: Re: [PATCH 0/2] mini-os: remove device specific struct file members
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220107104706.9859-1-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <20220107104706.9859-1-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 07/01/2022 10:47, Juergen Gross wrote:
> This small series is a followup to the series sent recently:
>
> https://lists.xen.org/archives/html/xen-devel/2022-01/threads.html#00110
>
> It contains the last cleanups related to struct file and can only be
> applied after the Xen libraries have stopped using the related union
> members.
>
> Juergen Gross (2):
>   mini-os: remove event channel specific struct file member
>   mini-os: remove gnttab specific member from struct file
>
>  include/lib.h | 13 -------------
>  1 file changed, 13 deletions(-)
>

This all looks fine.  Even if we don't want to hide struct file,
shouldn't we at least make the files[] array private to the MiniOS
core?  It's another implementation detail which external users mustn't
rely on.

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:32 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256099.443475 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-0006DX-RO; Sun, 16 Jan 2022 16:40:30 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256099.443475; Sun, 16 Jan 2022 16:40:30 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-0006Bk-BP; Sun, 16 Jan 2022 16:40:30 +0000
Received: by outflank-mailman (input) for mailman id 256099;
 Tue, 11 Jan 2022 20:21:38 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=JwWh=R3=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7NeE-0000ZM-CL
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:21:38 +0000
Received: from ppsw-42.csi.cam.ac.uk (ppsw-42.csi.cam.ac.uk [131.111.8.142])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 13cd31f8-731c-11ec-81c1-a30af7de8005;
 Tue, 11 Jan 2022 21:21:37 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:47054)
 by ppsw-42.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.138]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7NeC-000t3o-92 (Exim 4.95) (return-path <amc96@srcf.net>);
 Tue, 11 Jan 2022 20:21:36 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id 944EA1FBCC;
 Tue, 11 Jan 2022 20:21:36 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 13cd31f8-731c-11ec-81c1-a30af7de8005
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <a41f6688-d14a-dad5-1625-1b98f793062e@srcf.net>
Date: Tue, 11 Jan 2022 20:21:36 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-4-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
Subject: Re: [PATCH v2 03/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in xs
In-Reply-To: <20220111151215.22955-4-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 11/01/2022 15:12, Juergen Gross wrote:
>  void xs_daemon_close(struct xs_handle *h)
>  {
> -    int fd = _xs_fileno(h);
> -    struct xenbus_event *event, *next;
> -    for (event = files[fd].dev; event; event = next)
> -    {
> -        next = event->next;
> -        free(event);
> -    }
> +    close(_xs_fileno(h));
>  }

You've deleted the sole caller of xs_daemon_close() from the main
close() function.

That said, I'm very confused, because nothing in minios declares it. 
The declaration appears to come from xenstore.h, which is clearly
included unconditionally (when it ought not to be), but libxenstore also
defines the function too...

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:32 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256024.443454 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-00066b-5T; Sun, 16 Jan 2022 16:40:30 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256024.443454; Sun, 16 Jan 2022 16:40:30 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zx-00065I-Qt; Sun, 16 Jan 2022 16:40:29 +0000
Received: by outflank-mailman (input) for mailman id 256024;
 Tue, 11 Jan 2022 19:42:57 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=JwWh=R3=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7N2m-0004Ar-Ul
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 19:42:56 +0000
Received: from ppsw-42.csi.cam.ac.uk (ppsw-42.csi.cam.ac.uk [131.111.8.142])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ac4d0c9b-7316-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 20:42:56 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:47036)
 by ppsw-42.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.138]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7N2l-000n7l-8W (Exim 4.95) (return-path <amc96@srcf.net>);
 Tue, 11 Jan 2022 19:42:55 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id 7B7FD1FBCC;
 Tue, 11 Jan 2022 19:42:55 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ac4d0c9b-7316-11ec-9ce5-af14b9085ebd
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <da22a929-0226-c3e5-2c04-92b412613219@srcf.net>
Date: Tue, 11 Jan 2022 19:42:55 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Subject: Re: [PATCH v2 00/18] mini-os: remove struct file dependency on config
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <20220111145817.22170-1-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 11/01/2022 14:57, Juergen Gross wrote:
> Today the layout of struct file is depending on the Mini-OS
> configuration. This is especially bad as the layout is exported to
> external users like the Xen libraries built for Mini-OS, and those
> are being built only once for multiple stubdom configurations.
>
> Today there is no direct problem resulting from this, as the main
> difference between struct file layouts is a large union containing all
> the device specific data for the different file types. The largest
> union member is not configuration dependant, so the build is currently
> not broken.
>
> In order to avoid any future problems this patch series is eliminating
> the configuration dependency by replacing most of the device specific
> union members by a single pointer.
>
> The two union members used by Xen libraries can't be replaced yet, as
> those need to be switched to use the generic pointer first.
>
> In order to hide the Mini-OS internal implementation of the files
> array, patches 15-17 are introducing a common framework to access a
> struct file via its file descriptor, and to allocate new file types
> dynamically instead of having them all pre-defined. The file type
> specific operations are supplied via a function vector in order to
> remove the dependency of lib/sys.c on all the various file types.

Patches 1 thru 15 seem fine and ready to go.  Would it help to get those
committed now?

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:32 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256003.443449 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-00063v-1g; Sun, 16 Jan 2022 16:40:30 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256003.443449; Sun, 16 Jan 2022 16:40:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zx-00063B-Iz; Sun, 16 Jan 2022 16:40:29 +0000
Received: by outflank-mailman (input) for mailman id 256003;
 Tue, 11 Jan 2022 18:19:18 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=JwWh=R3=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7Ljq-0002J4-0k
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 18:19:18 +0000
Received: from ppsw-42.csi.cam.ac.uk (ppsw-42.csi.cam.ac.uk [131.111.8.142])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id fc5eb13d-730a-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 19:19:16 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:46998)
 by ppsw-42.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.138]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7Ljo-000aR3-6i (Exim 4.95) (return-path <amc96@srcf.net>);
 Tue, 11 Jan 2022 18:19:16 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id D8B9E1FB3A;
 Tue, 11 Jan 2022 18:19:15 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fc5eb13d-730a-11ec-9ce5-af14b9085ebd
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <b6526d7d-4086-30b3-181a-1a34c44137e3@srcf.net>
Date: Tue, 11 Jan 2022 18:19:15 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-19-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
Subject: Re: [PATCH v2 18/18] mini-os: remove file type FTYPE_XC
In-Reply-To: <20220111145817.22170-19-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 11/01/2022 14:58, Juergen Gross wrote:
> The only reason for the file type FTYPE_XC has been gone long time
> ago: it was needed for xc_map_foreign_bulk(), which has been switched
> to use libxenforeignmemory and doesn't need this special file any
> more.
>
> So remove everything related to FTYPE_XC.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>

You'd have less churn in the series if this came ahead of patch 17. 
There are at least 3 hunks below that you've already converted once, and
one of those hunks already needs a hard tabs fixup.

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:34 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256086.443474 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-0006CS-R2; Sun, 16 Jan 2022 16:40:30 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256086.443474; Sun, 16 Jan 2022 16:40:30 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-0006AJ-7v; Sun, 16 Jan 2022 16:40:30 +0000
Received: by outflank-mailman (input) for mailman id 256086;
 Tue, 11 Jan 2022 20:14:23 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=JwWh=R3=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7NXD-0006Es-2k
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:14:23 +0000
Received: from ppsw-33.csi.cam.ac.uk (ppsw-33.csi.cam.ac.uk [131.111.8.133])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 0fe8785f-731b-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 21:14:22 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:47592)
 by ppsw-33.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.137]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7NXA-000nKA-iW (Exim 4.95) (return-path <amc96@srcf.net>);
 Tue, 11 Jan 2022 20:14:20 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id 9404F1FBFC;
 Tue, 11 Jan 2022 20:14:20 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 0fe8785f-731b-11ec-9ce5-af14b9085ebd
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <9ff34b30-02ef-9a4f-13e0-d094c87b613f@srcf.net>
Date: Tue, 11 Jan 2022 20:14:20 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Subject: Re: [PATCH v2 03/12] mini-os: use alloc_file_type() and
 get_file_from_fd() in xs
Content-Language: en-GB
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-4-jgross@suse.com>
 <20220111200615.b5tpi4faz3cak2ft@begin>
 <20220111201136.yqp274wyqju5zshs@begin>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <20220111201136.yqp274wyqju5zshs@begin>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 11/01/2022 20:11, Samuel Thibault wrote:
> Samuel Thibault, le mar. 11 janv. 2022 21:06:15 +0100, a ecrit:
>> Juergen Gross, le mar. 11 janv. 2022 16:12:06 +0100, a ecrit:
>>> diff --git a/lib/xs.c b/lib/xs.c
>>> index 4af0f96..ac830d2 100644
>>> --- a/lib/xs.c
>>> +++ b/lib/xs.c
>>> @@ -18,23 +18,55 @@ static inline int _xs_fileno(struct xs_handle *h) {
>>>      return (intptr_t) h;
>>>  }
>>>  
>>> +static int xs_close_fd(int fd)
>>> +{
>>> +    struct xenbus_event *event, *next;
>>> +    struct file *file = get_file_from_fd(fd);
> This...
>
>>> +    for (event = file->dev; event; event = next)
>>> +    {
>>> +        next = event->next;
>>> +        free(event);
>>> +    }
>>> +
>>> +    return 0;
>>> +}
>>> +
>>> +static bool xs_can_read(int fd)
>>> +{
>>> +    struct file *file = get_file_from_fd(fd);
> ... and that would be simplified by directly getting the file* from the
> parameters.

I actually make exactly the same suggestion for close() in
libxenevtchn.  The callback hooks don't need the same API as the libc
functions.

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:34 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256366.443486 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zz-0006Ln-Cc; Sun, 16 Jan 2022 16:40:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256366.443486; Sun, 16 Jan 2022 16:40:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-0006Js-V1; Sun, 16 Jan 2022 16:40:30 +0000
Received: by outflank-mailman (input) for mailman id 256366;
 Wed, 12 Jan 2022 08:19:53 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=BEGY=R4=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7YrJ-0000pP-Fx
 for minios-devel@lists.xenproject.org; Wed, 12 Jan 2022 08:19:53 +0000
Received: from ppsw-32.csi.cam.ac.uk (ppsw-32.csi.cam.ac.uk [131.111.8.132])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 6aad2ea2-7380-11ec-9ce5-af14b9085ebd;
 Wed, 12 Jan 2022 09:19:52 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:48190)
 by ppsw-32.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.136]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7YrI-0010Q3-0w (Exim 4.95) (return-path <amc96@srcf.net>);
 Wed, 12 Jan 2022 08:19:52 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id 196A91FCF3;
 Wed, 12 Jan 2022 08:19:52 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 6aad2ea2-7380-11ec-9ce5-af14b9085ebd
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <559223b1-68c1-87fb-7b7b-190f8671b4c2@srcf.net>
Date: Wed, 12 Jan 2022 08:19:51 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Subject: Re: [PATCH v2 17/18] mini-os: use function vectors instead of switch
 for file operations
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-18-jgross@suse.com>
 <a2d4c905-c477-8553-85a7-90168d914b6e@srcf.net>
 <08672989-53be-1551-f001-0d2c0435b586@suse.com>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <08672989-53be-1551-f001-0d2c0435b586@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 12/01/2022 07:34, Juergen Gross wrote:
> On 11.01.22 19:08, Andrew Cooper wrote:
>> On 11/01/2022 14:58, Juergen Gross wrote:
>>> +
>>> +off_t lseek_default(int fd, off_t offset, int whence);
>>> +bool select_yes(int fd);
>>> +bool select_read_flag(int fd);
>>> +
>>>   LIST_HEAD(evtchn_port_list, evtchn_port_info);
>>>     struct evtchn_port_info {
>>> @@ -183,7 +210,7 @@ struct evtchn_port_info {
>>>   };
>>>     struct file {
>>> -    enum fd_type type;
>>> +    unsigned int type;
>>>       bool read;    /* maybe available for read */
>>>       off_t offset;
>>>       union {
>>> @@ -199,7 +226,7 @@ struct file {
>>>   extern struct file files[];
>>>     struct file *get_file_from_fd(int fd);
>>> -int alloc_fd(enum fd_type type);
>>> +int alloc_fd(unsigned int type);
>>>   void close_all_files(void);
>>>   extern struct thread *main_thread;
>>>   void sparse(unsigned long data, size_t size);
>>> diff --git a/lib/sys.c b/lib/sys.c
>>> index 323a7cd..c327247 100644
>>> --- a/lib/sys.c
>>> +++ b/lib/sys.c
>>> @@ -98,6 +98,39 @@ struct file files[NOFILE] = {
>>>       { .type = FTYPE_CONSOLE }, /* stderr */
>>>   };
>>>   +static struct file_ops file_ops_none = {
>>> +    .name = "none",
>>> +};
>>> +
>>> +static struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
>>> +    [FTYPE_NONE] = &file_ops_none,
>>> +};
>>
>> Both want to be const, because all file_ops ought to live in rodata.
>
> file_ops[] can't be const, it will just point to const data.

Oh, of course.

>>> @@ -709,6 +805,18 @@ static void dump_pollfds(struct pollfd *pfd,
>>> int nfds, int timeout)
>>>   #define dump_pollfds(pfds, nfds, timeout)
>>>   #endif
>>>   +bool select_yes(int fd)
>>> +{
>>> +    return true;
>>> +}
>>> +
>>> +bool select_read_flag(int fd)
>>> +{
>>> +    struct file *file = get_file_from_fd(fd);
>>> +
>>> +    return file->read;
>>> +}
>>
>> I don't see these getting used, even in a fallback case.
>
> They will be used in later patches.

Yeah - I found them in later patches.  It's probably worth a note in the
commit message saying "provide some functions useful for file_ops in
future patches", particularly as it's actually a later series which
takes them (due to the ordering constraints).

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:34 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256076.443468 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-0006AO-K8; Sun, 16 Jan 2022 16:40:30 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256076.443468; Sun, 16 Jan 2022 16:40:30 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-00067j-2u; Sun, 16 Jan 2022 16:40:30 +0000
Received: by outflank-mailman (input) for mailman id 256076;
 Tue, 11 Jan 2022 20:12:23 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=JwWh=R3=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7NVH-0004xQ-2q
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 20:12:23 +0000
Received: from ppsw-32.csi.cam.ac.uk (ppsw-32.csi.cam.ac.uk [131.111.8.132])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id c8488c3b-731a-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 21:12:21 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:48122)
 by ppsw-32.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.136]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7NVE-000X9h-2H (Exim 4.95) (return-path <amc96@srcf.net>);
 Tue, 11 Jan 2022 20:12:20 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id 7F7E41FBFC;
 Tue, 11 Jan 2022 20:12:20 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: c8488c3b-731a-11ec-9ce5-af14b9085ebd
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <d5ae3033-86c5-c2a4-73f8-6f5a4e1e8d26@srcf.net>
Date: Tue, 11 Jan 2022 20:12:20 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Subject: Re: [PATCH v2 02/12] mini-os: remove gnttab specific member from
 struct file
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111151215.22955-1-jgross@suse.com>
 <20220111151215.22955-3-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <20220111151215.22955-3-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

On 11/01/2022 15:12, Juergen Gross wrote:
> The event channel specific union member in struct file is no longer

Too much copy&paste from the previous patch?

The actual contents look fine.

~Andrew

> needed, so remove it.
>
> The gnttab file type and its associated handling can be removed, too,
> as libxengnttab is now supplying a struct file_ops via a call of
> alloc_file_type().
>
> This removes all contents of CONFIG_LIBXENGNTTAB guarded sections, so
> this config option can be removed.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>



From minios-devel-bounces@lists.xenproject.org Sun Jan 16 16:40:34 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 16:40:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.256014.443457 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zy-00065g-7N; Sun, 16 Jan 2022 16:40:30 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 256014.443457; Sun, 16 Jan 2022 16:40:30 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n98Zx-000645-Mq; Sun, 16 Jan 2022 16:40:29 +0000
Received: by outflank-mailman (input) for mailman id 256014;
 Tue, 11 Jan 2022 19:14:48 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=JwWh=R3=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n7MbY-0000K2-LB
 for minios-devel@lists.xenproject.org; Tue, 11 Jan 2022 19:14:48 +0000
Received: from ppsw-42.csi.cam.ac.uk (ppsw-42.csi.cam.ac.uk [131.111.8.142])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id bb1e9305-7312-11ec-9ce5-af14b9085ebd;
 Tue, 11 Jan 2022 20:14:44 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:47032)
 by ppsw-42.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.138]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n7MbS-000iqV-7q (Exim 4.95) (return-path <amc96@srcf.net>);
 Tue, 11 Jan 2022 19:14:42 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id 28A4B1FBFC;
 Tue, 11 Jan 2022 19:14:42 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: bb1e9305-7312-11ec-9ce5-af14b9085ebd
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <e4956df7-d7ca-cb5f-0f0e-7f3eba5d1a50@srcf.net>
Date: Tue, 11 Jan 2022 19:14:41 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220111145817.22170-1-jgross@suse.com>
 <20220111145817.22170-17-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
Subject: Re: [PATCH v2 16/18] mini-os: reset file type in close() in one place
 only
In-Reply-To: <20220111145817.22170-17-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

On 11/01/2022 14:58, Juergen Gross wrote:
> diff --git a/lib/sys.c b/lib/sys.c
> index 0e6fe5d..323a7cd 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -424,87 +424,82 @@ int fsync(int fd) {
>  
>  int close(int fd)
>  {
> +    int res = 0;
> +
>      printk("close(%d)\n", fd);
>      switch (files[fd].type) {

I know this bug is pre-existing, but the libc close() really ought to
sanity check fd before blindly indexing files[] with it.

I'd tentatively suggest that you want one extra goto from here, into
wherever the EBADF logic ends up, and it's probably worth including in
this patch.

~Andrew


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 20:33:39 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 20:33:39 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257925.443522 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CDV-0003D6-8D; Sun, 16 Jan 2022 20:33:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257925.443522; Sun, 16 Jan 2022 20:33:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CDV-0003Cz-5L; Sun, 16 Jan 2022 20:33:33 +0000
Received: by outflank-mailman (input) for mailman id 257925;
 Sun, 16 Jan 2022 20:33:31 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9CDT-0003Cl-OM
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 20:33:31 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 8eb639fd-770b-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 21:33:28 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id E95FB35D;
 Sun, 16 Jan 2022 21:33:25 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id hCMMYMqtZtvI; Sun, 16 Jan 2022 21:33:24 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 8AD889E;
 Sun, 16 Jan 2022 21:33:24 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9CDL-005uQa-HV;
 Sun, 16 Jan 2022 21:33:23 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 8eb639fd-770b-11ec-a115-11989b9578b4
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 21:33:23 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 2/5] reset file type in close() in one place
 only
Message-ID: <20220116203323.ebf75ksyfvy4qoim@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116064527.23519-1-jgross@suse.com>
 <20220116064527.23519-3-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220116064527.23519-3-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: E95FB35D
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 07:45:24 +0100, a ecrit:
> Today the file type in struct file is set to FTYPE_NONE for each
> file type individually. Do that at the end of close() handling for
> all types.
> 
> While at it wipe the complete struct file, too, in order to avoid
> old data creeping into a new allocated struct file.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
> V2:
> - new patch
> V3:
> - add error handling (Andrew Cooper)
> - use BUILD_BUG_ON() (Andrew Cooper)
> ---
>  lib/sys.c | 56 ++++++++++++++++++++++++++++---------------------------
>  lib/xs.c  |  1 -
>  2 files changed, 29 insertions(+), 28 deletions(-)
> 
> diff --git a/lib/sys.c b/lib/sys.c
> index 9a03875c..7df77cc6 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -265,7 +265,7 @@ int read(int fd, void *buf, size_t nbytes)
>              return ret;
>          }
>  #ifdef HAVE_LWIP
> -	case FTYPE_SOCKET:
> +        case FTYPE_SOCKET:
>  	    return lwip_read(files[fd].fd, buf, nbytes);
>  #endif
>  #ifdef CONFIG_NETFRONT
> @@ -424,84 +424,86 @@ int fsync(int fd) {
>  
>  int close(int fd)
>  {
> +    int res = 0;
> +
> +    if ( fd < 0 || fd >= ARRAY_SIZE(files) )
> +        goto error;
> +
>      printk("close(%d)\n", fd);
>      switch (files[fd].type) {
>          default:
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #ifdef CONFIG_XENBUS
>  	case FTYPE_XENBUS:
>              xs_daemon_close((void*)(intptr_t) fd);
> -            return 0;
> +            break;
>  #endif
>  #ifdef HAVE_LWIP
> -	case FTYPE_SOCKET: {
> -	    int res = lwip_close(files[fd].fd);
> -	    files[fd].type = FTYPE_NONE;
> -	    return res;
> -	}
> +	case FTYPE_SOCKET:
> +            res = lwip_close(files[fd].fd);
> +            break;
>  #endif
>  #ifdef CONFIG_LIBXENCTRL
>  	case FTYPE_XC:
>  	    minios_interface_close_fd(fd);
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_LIBXENEVTCHN
>  	case FTYPE_EVTCHN:
>  	    minios_evtchn_close_fd(fd);
> -            return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_LIBXENGNTTAB
>  	case FTYPE_GNTMAP:
>  	    minios_gnttab_close_fd(fd);
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_NETFRONT
>  	case FTYPE_TAP:
>  	    shutdown_netfront(files[fd].dev);
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_BLKFRONT
>  	case FTYPE_BLK:
>              shutdown_blkfront(files[fd].dev);
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_TPMFRONT
>  	case FTYPE_TPMFRONT:
>              shutdown_tpmfront(files[fd].dev);
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_TPM_TIS
>  	case FTYPE_TPM_TIS:
>              shutdown_tpm_tis(files[fd].dev);
> -	    files[fd].type = FTYPE_NONE;
> -	    return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_KBDFRONT
>  	case FTYPE_KBD:
>              shutdown_kbdfront(files[fd].dev);
> -            files[fd].type = FTYPE_NONE;
> -            return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_FBFRONT
>  	case FTYPE_FB:
>              shutdown_fbfront(files[fd].dev);
> -            files[fd].type = FTYPE_NONE;
> -            return 0;
> +            break;
>  #endif
>  #ifdef CONFIG_CONSFRONT
>          case FTYPE_SAVEFILE:
>          case FTYPE_CONSOLE:
>              fini_consfront(files[fd].dev);
> -            files[fd].type = FTYPE_NONE;
> -            return 0;
> +            break;
>  #endif
>  	case FTYPE_NONE:
> -	    break;
> +            goto error;
>      }
> +
> +    memset(files + fd, 0, sizeof(struct file));
> +    BUILD_BUG_ON(FTYPE_NONE != 0);
> +
> +    return res;
> +
> + error:
>      printk("close(%d): Bad descriptor\n", fd);
>      errno = EBADF;
>      return -1;
> diff --git a/lib/xs.c b/lib/xs.c
> index 0459f52f..4af0f960 100644
> --- a/lib/xs.c
> +++ b/lib/xs.c
> @@ -35,7 +35,6 @@ void xs_daemon_close(struct xs_handle *h)
>          next = event->next;
>          free(event);
>      }
> -    files[fd].type = FTYPE_NONE;
>  }
>  
>  int xs_fileno(struct xs_handle *h)
> -- 
> 2.26.2
> 

-- 
Samuel
/*
 * [...] Note that 120 sec is defined in the protocol as the maximum
 * possible RTT.  I guess we'll have to use something other than TCP
 * to talk to the University of Mars.
 * PAWS allows us longer timeouts and large windows, so once implemented
 * ftp to mars will work nicely.
 */
(from /usr/src/linux/net/inet/tcp.c, concerning RTT [retransmission timeout])


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 20:34:22 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 20:34:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257930.443547 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CEI-00042w-1a; Sun, 16 Jan 2022 20:34:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257930.443547; Sun, 16 Jan 2022 20:34:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CEH-00042p-UZ; Sun, 16 Jan 2022 20:34:21 +0000
Received: by outflank-mailman (input) for mailman id 257930;
 Sun, 16 Jan 2022 20:34:20 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9CEG-0003mQ-Jb
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 20:34:20 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id ad8dce45-770b-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 21:34:18 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 0858635D;
 Sun, 16 Jan 2022 21:34:18 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 4JUQfpPpOgIr; Sun, 16 Jan 2022 21:34:17 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 3E1178B;
 Sun, 16 Jan 2022 21:34:17 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9CEC-005uRN-Hh;
 Sun, 16 Jan 2022 21:34:16 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ad8dce45-770b-11ec-a115-11989b9578b4
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 21:34:16 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 3/5] remove file type FTYPE_XC
Message-ID: <20220116203416.qvna3buvtn52fjan@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116064527.23519-1-jgross@suse.com>
 <20220116064527.23519-4-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220116064527.23519-4-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 0858635D
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 07:45:25 +0100, a ecrit:
> The only reason for the file type FTYPE_XC has been gone long time
> ago: it was needed for xc_map_foreign_bulk(), which has been switched
> to use libxenforeignmemory and doesn't need this special file any
> more.
> 
> So remove everything related to FTYPE_XC.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
> V2:
> - new patch
> V3:
> - moved patch in series (Andrew Cooper)
> ---
>  Config.mk                     |  1 -
>  arch/x86/testbuild/all-no     |  1 -
>  arch/x86/testbuild/all-yes    |  1 -
>  arch/x86/testbuild/newxen-yes |  1 -
>  include/lib.h                 |  1 -
>  lib/sys.c                     | 13 -------------
>  6 files changed, 18 deletions(-)
> 
> diff --git a/Config.mk b/Config.mk
> index 5e660891..1e083881 100644
> --- a/Config.mk
> +++ b/Config.mk
> @@ -197,7 +197,6 @@ CONFIG-n += CONFIG_PARAVIRT
>  endif
>  # Support legacy CONFIG_XC value
>  CONFIG_XC ?= $(libc)
> -CONFIG-$(CONFIG_XC) += CONFIG_LIBXENCTRL
>  CONFIG-$(CONFIG_XC) += CONFIG_LIBXENEVTCHN
>  CONFIG-$(CONFIG_XC) += CONFIG_LIBXENGNTTAB
>  
> diff --git a/arch/x86/testbuild/all-no b/arch/x86/testbuild/all-no
> index 7972ecd5..d6fc2608 100644
> --- a/arch/x86/testbuild/all-no
> +++ b/arch/x86/testbuild/all-no
> @@ -13,7 +13,6 @@ CONFIG_FBFRONT = n
>  CONFIG_KBDFRONT = n
>  CONFIG_CONSFRONT = n
>  CONFIG_XENBUS = n
> -CONFIG_LIBXENCTRL = n
>  CONFIG_LIBXENEVTCHN = n
>  CONFIG_LIBXENGNTTAB = n
>  CONFIG_LWIP = n
> diff --git a/arch/x86/testbuild/all-yes b/arch/x86/testbuild/all-yes
> index bc8eea57..98bbfebf 100644
> --- a/arch/x86/testbuild/all-yes
> +++ b/arch/x86/testbuild/all-yes
> @@ -16,7 +16,6 @@ CONFIG_XENBUS = y
>  CONFIG_BALLOON = y
>  CONFIG_USE_XEN_CONSOLE = y
>  # The following are special: they need support from outside
> -CONFIG_LIBXENCTRL = n
>  CONFIG_LIBXENEVTCHN = n
>  CONFIG_LIBXENGNTTAB = n
>  CONFIG_LWIP = n
> diff --git a/arch/x86/testbuild/newxen-yes b/arch/x86/testbuild/newxen-yes
> index f72123b5..06032004 100644
> --- a/arch/x86/testbuild/newxen-yes
> +++ b/arch/x86/testbuild/newxen-yes
> @@ -17,7 +17,6 @@ CONFIG_BALLOON = y
>  CONFIG_USE_XEN_CONSOLE = y
>  XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
>  # The following are special: they need support from outside
> -CONFIG_LIBXENCTRL = n
>  CONFIG_LIBXENEVTCHN = n
>  CONFIG_LIBXENGNTTAB = n
>  CONFIG_LWIP = n
> diff --git a/include/lib.h b/include/lib.h
> index 7a0546bd..7ca90768 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -159,7 +159,6 @@ enum fd_type {
>      FTYPE_CONSOLE,
>      FTYPE_FILE,
>      FTYPE_XENBUS,
> -    FTYPE_XC,
>      FTYPE_EVTCHN,
>      FTYPE_GNTMAP,
>      FTYPE_SOCKET,
> diff --git a/lib/sys.c b/lib/sys.c
> index 7df77cc6..a24687b7 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -87,7 +87,6 @@
>      }
>  
>  #define NOFILE 32
> -extern void minios_interface_close_fd(int fd);
>  extern void minios_evtchn_close_fd(int fd);
>  extern void minios_gnttab_close_fd(int fd);
>  
> @@ -443,11 +442,6 @@ int close(int fd)
>              res = lwip_close(files[fd].fd);
>              break;
>  #endif
> -#ifdef CONFIG_LIBXENCTRL
> -	case FTYPE_XC:
> -	    minios_interface_close_fd(fd);
> -            break;
> -#endif
>  #ifdef CONFIG_LIBXENEVTCHN
>  	case FTYPE_EVTCHN:
>  	    minios_evtchn_close_fd(fd);
> @@ -651,7 +645,6 @@ static const char file_types[] = {
>      [FTYPE_NONE]	= 'N',
>      [FTYPE_CONSOLE]	= 'C',
>      [FTYPE_XENBUS]	= 'S',
> -    [FTYPE_XC]		= 'X',
>      [FTYPE_EVTCHN]	= 'E',
>      [FTYPE_SOCKET]	= 's',
>      [FTYPE_TAP]		= 'T',
> @@ -1383,12 +1376,6 @@ void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset
>  
>      if (fd == -1)
>          return map_zero(n, 1);
> -#ifdef CONFIG_LIBXENCTRL
> -    else if (files[fd].type == FTYPE_XC) {
> -        unsigned long zero = 0;
> -        return map_frames_ex(&zero, n, 0, 0, 1, DOMID_SELF, NULL, 0);
> -    }
> -#endif
>      else if (files[fd].type == FTYPE_MEM) {
>          unsigned long first_mfn = offset >> PAGE_SHIFT;
>          return map_frames_ex(&first_mfn, n, 0, 1, 1, DOMID_IO, NULL, _PAGE_PRESENT|_PAGE_RW);
> -- 
> 2.26.2
> 

-- 
Samuel
$ du temp.iso 
2,0T    temp.iso
$ ls temp.iso -l
-r-xr-xr-x    1 samy     thibault      16E 2003-03-22 14:44 temp.iso*
 -+- je vous dirai pas la marque de mon disque dur, na :p -+- 


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 20:39:15 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 20:39:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257932.443551 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CJ0-0004ew-Ci; Sun, 16 Jan 2022 20:39:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257932.443551; Sun, 16 Jan 2022 20:39:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CJ0-0004ep-9X; Sun, 16 Jan 2022 20:39:14 +0000
Received: by outflank-mailman (input) for mailman id 257932;
 Sun, 16 Jan 2022 20:39:13 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9CIz-0004ej-Ie
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 20:39:13 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 5c90f37c-770c-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 21:39:12 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 402A835D;
 Sun, 16 Jan 2022 21:39:11 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id XCzniMKdUBPS; Sun, 16 Jan 2022 21:39:10 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 794E89E;
 Sun, 16 Jan 2022 21:39:09 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9CIt-005uTB-JB;
 Sun, 16 Jan 2022 21:39:07 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 5c90f37c-770c-11ec-a115-11989b9578b4
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 21:39:07 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 4/5] use function vectors instead of switch for
 file operations
Message-ID: <20220116203907.7nr3f42rl6gnwi3k@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116064527.23519-1-jgross@suse.com>
 <20220116064527.23519-5-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220116064527.23519-5-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 402A835D
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 07:45:26 +0100, a ecrit:
> Introduce file type specific function vectors for all the needed file
> operations which are file type specific in order to prepare replacing
> the large switch statements in each generic file function.
> 
> Add a function to allocate a new file type dynamically in order to
> prepare removing direct dependencies to external components in the
> future. For this reason switch the file type from an enum to an
> unsigned int. Prepare removal of some statically defines file types
> by putting them at the end of the defined list.
> 
> Change the debug output for the file type from a single character to
> a string in order to support a future removal of the file_types[]
> array.
> 
> Provide some functions useful for file_ops in future patches.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
> V2:
> - new patch
> V3:
> - drop typedefs for callbacks (Andrew Cooper)
> - const (Andrew Cooper)
> - drop loop from alloc_file_type() (Andrew Cooper)
> - switch to struct file * as first parameter of callbacks (Andrew Cooper)
> ---
>  include/lib.h |  57 +++++++----
>  lib/sys.c     | 268 ++++++++++++++++++++++++++++++++++++++++++--------
>  2 files changed, 263 insertions(+), 62 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 7ca90768..44696806 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -66,6 +66,7 @@
>  
>  #ifdef HAVE_LIBC
>  #include <sys/queue.h>
> +#include <sys/stat.h>
>  #include <stdio.h>
>  #include <string.h>
>  #else
> @@ -154,23 +155,23 @@ do {                                                           \
>  void sanity_check(void);
>  
>  #ifdef HAVE_LIBC
> -enum fd_type {
> -    FTYPE_NONE = 0,
> -    FTYPE_CONSOLE,
> -    FTYPE_FILE,
> -    FTYPE_XENBUS,
> -    FTYPE_EVTCHN,
> -    FTYPE_GNTMAP,
> -    FTYPE_SOCKET,
> -    FTYPE_TAP,
> -    FTYPE_BLK,
> -    FTYPE_KBD,
> -    FTYPE_FB,
> -    FTYPE_MEM,
> -    FTYPE_SAVEFILE,
> -    FTYPE_TPMFRONT,
> -    FTYPE_TPM_TIS,
> -};
> +#define FTYPE_NONE       0
> +#define FTYPE_CONSOLE    1
> +#define FTYPE_FILE       2
> +#define FTYPE_SOCKET     3
> +#define FTYPE_MEM        4
> +#define FTYPE_SAVEFILE   5
> +#define FTYPE_FB         6
> +#define FTYPE_KBD        7
> +#define FTYPE_TAP        8
> +#define FTYPE_BLK        9
> +#define FTYPE_TPMFRONT  10
> +#define FTYPE_TPM_TIS   11
> +#define FTYPE_XENBUS    12
> +#define FTYPE_GNTMAP    13
> +#define FTYPE_EVTCHN    14
> +#define FTYPE_N         15
> +#define FTYPE_SPARE     16
>  
>  LIST_HEAD(evtchn_port_list, evtchn_port_info);
>  
> @@ -182,7 +183,7 @@ struct evtchn_port_info {
>  };
>  
>  struct file {
> -    enum fd_type type;
> +    unsigned int type;
>      bool read;	/* maybe available for read */
>      off_t offset;
>      union {
> @@ -197,8 +198,26 @@ struct file {
>  
>  extern struct file files[];
>  
> +struct file_ops {
> +    const char *name;
> +    int (*read)(struct file *file, void *buf, size_t nbytes);
> +    int (*write)(struct file *file, const void *buf, size_t nbytes);
> +    off_t (*lseek)(struct file *file, off_t offset, int whence);
> +    int (*close)(struct file *file);
> +    int (*fstat)(struct file *file, struct stat *buf);
> +    int (*fcntl)(struct file *file, int cmd, va_list args);
> +    bool (*select_rd)(struct file *file);
> +    bool (*select_wr)(struct file *file);
> +};
> +
> +unsigned int alloc_file_type(const struct file_ops *ops);
> +
> +off_t lseek_default(struct file *file, off_t offset, int whence);
> +bool select_yes(struct file *file);
> +bool select_read_flag(struct file *file);
> +
>  struct file *get_file_from_fd(int fd);
> -int alloc_fd(enum fd_type type);
> +int alloc_fd(unsigned int type);
>  void close_all_files(void);
>  extern struct thread *main_thread;
>  void sparse(unsigned long data, size_t size);
> diff --git a/lib/sys.c b/lib/sys.c
> index a24687b7..7be01fd3 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -97,6 +97,40 @@ struct file files[NOFILE] = {
>      { .type = FTYPE_CONSOLE }, /* stderr */
>  };
>  
> +static const struct file_ops file_ops_none = {
> +    .name = "none",
> +};
> +
> +static const struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
> +    [FTYPE_NONE] = &file_ops_none,
> +};
> +
> +unsigned int alloc_file_type(const struct file_ops *ops)
> +{
> +    static unsigned int i = FTYPE_N;
> +    unsigned int ret;
> +
> +    pthread_mutex_lock(&fd_lock);
> +
> +    BUG_ON(i == ARRAY_SIZE(file_ops));
> +    ret = i++;
> +    file_ops[ret] = ops;
> +
> +    pthread_mutex_unlock(&fd_lock);
> +
> +    printk("New file type \"%s\"(%u) allocated\n", ops->name, ret);
> +
> +    return ret;
> +}
> +
> +static const struct file_ops *get_file_ops(unsigned int type)
> +{
> +    if ( type >= ARRAY_SIZE(file_ops) || !file_ops[type] )
> +        return &file_ops_none;
> +
> +    return file_ops[type];
> +}
> +
>  struct file *get_file_from_fd(int fd)
>  {
>      if ( fd < 0 || fd >= ARRAY_SIZE(files) )
> @@ -107,7 +141,7 @@ struct file *get_file_from_fd(int fd)
>  
>  DECLARE_WAIT_QUEUE_HEAD(event_queue);
>  
> -int alloc_fd(enum fd_type type)
> +int alloc_fd(unsigned int type)
>  {
>      int i;
>      pthread_mutex_lock(&fd_lock);
> @@ -248,7 +282,17 @@ int isatty(int fd)
>  
>  int read(int fd, void *buf, size_t nbytes)
>  {
> -    switch (files[fd].type) {
> +    struct file *file = get_file_from_fd(fd);
> +    const struct file_ops *ops;
> +
> +    if ( !file )
> +        goto error;
> +
> +    ops = get_file_ops(file->type);
> +    if ( ops->read )
> +        return ops->read(file, buf, nbytes);
> +
> +    switch (file->type) {
>          case FTYPE_SAVEFILE:
>  	case FTYPE_CONSOLE: {
>  	    int ret;
> @@ -320,6 +364,8 @@ int read(int fd, void *buf, size_t nbytes)
>  	default:
>  	    break;
>      }
> +
> + error:
>      printk("read(%d): Bad descriptor\n", fd);
>      errno = EBADF;
>      return -1;
> @@ -327,7 +373,17 @@ int read(int fd, void *buf, size_t nbytes)
>  
>  int write(int fd, const void *buf, size_t nbytes)
>  {
> -    switch (files[fd].type) {
> +    struct file *file = get_file_from_fd(fd);
> +    const struct file_ops *ops;
> +
> +    if ( !file )
> +        goto error;
> +
> +    ops = get_file_ops(file->type);
> +    if ( ops->write )
> +        return ops->write(file, buf, nbytes);
> +
> +    switch (file->type) {
>          case FTYPE_SAVEFILE: {
>                  int ret = 0, tot = nbytes;
>                  while (nbytes > 0) {
> @@ -364,14 +420,61 @@ int write(int fd, const void *buf, size_t nbytes)
>  	default:
>  	    break;
>      }
> +
> + error:
>      printk("write(%d): Bad descriptor\n", fd);
>      errno = EBADF;
>      return -1;
>  }
>  
> +off_t lseek_default(struct file *file, off_t offset, int whence)
> +{
> +    switch ( whence )
> +    {
> +    case SEEK_SET:
> +        file->offset = offset;
> +        break;
> +
> +    case SEEK_CUR:
> +        file->offset += offset;
> +        break;
> +
> +    case SEEK_END:
> +    {
> +        struct stat st;
> +        int ret;
> +
> +        ret = fstat(file - files, &st);
> +        if ( ret )
> +            return -1;
> +        file->offset = st.st_size + offset;
> +        break;
> +    }
> +
> +    default:
> +        errno = EINVAL;
> +        return -1;
> +    }
> +
> +    return file->offset;
> +}
> +
>  off_t lseek(int fd, off_t offset, int whence)
>  {
> -    switch(files[fd].type) {
> +    struct file *file = get_file_from_fd(fd);
> +    const struct file_ops *ops;
> +
> +    if ( !file )
> +    {
> +        errno = EBADF;
> +        return (off_t)-1;
> +    }
> +
> +    ops = get_file_ops(file->type);
> +    if ( ops->lseek )
> +        return ops->lseek(file, offset, whence);
> +
> +    switch(file->type) {
>  #ifdef CONFIG_BLKFRONT
>         case FTYPE_BLK:
>            break;
> @@ -392,28 +495,7 @@ off_t lseek(int fd, off_t offset, int whence)
>            return (off_t) -1;
>      }
>  
> -    switch (whence) {
> -       case SEEK_SET:
> -          files[fd].offset = offset;
> -          break;
> -       case SEEK_CUR:
> -          files[fd].offset += offset;
> -          break;
> -       case SEEK_END:
> -          {
> -             struct stat st;
> -             int ret;
> -             ret = fstat(fd, &st);
> -             if (ret)
> -                return -1;
> -             files[fd].offset = st.st_size + offset;
> -             break;
> -          }
> -       default:
> -          errno = EINVAL;
> -          return -1;
> -    }
> -    return files[fd].offset;
> +    return lseek_default(file, offset, whence);
>  }
>  
>  int fsync(int fd) {
> @@ -424,12 +506,21 @@ int fsync(int fd) {
>  int close(int fd)
>  {
>      int res = 0;
> +    struct file *file = get_file_from_fd(fd);
> +    const struct file_ops *ops;
>  
> -    if ( fd < 0 || fd >= ARRAY_SIZE(files) )
> +    if ( !file )
>          goto error;
>  
> +    ops = get_file_ops(file->type);
>      printk("close(%d)\n", fd);
> -    switch (files[fd].type) {
> +    if ( ops->close )
> +    {
> +        res = ops->close(file);
> +        goto out;
> +    }
> +
> +    switch (file->type) {
>          default:
>              break;
>  #ifdef CONFIG_XENBUS
> @@ -492,6 +583,7 @@ int close(int fd)
>              goto error;
>      }
>  
> + out:
>      memset(files + fd, 0, sizeof(struct file));
>      BUILD_BUG_ON(FTYPE_NONE != 0);
>  
> @@ -522,8 +614,19 @@ int stat(const char *path, struct stat *buf)
>  
>  int fstat(int fd, struct stat *buf)
>  {
> +    struct file *file = get_file_from_fd(fd);
> +    const struct file_ops *ops;
> +
> +    if ( !file )
> +        goto error;
> +
>      init_stat(buf);
> -    switch (files[fd].type) {
> +
> +    ops = get_file_ops(file->type);
> +    if ( ops->fstat )
> +        return ops->fstat(file, buf);
> +
> +    switch (file->type) {
>  	case FTYPE_SAVEFILE:
>  	case FTYPE_CONSOLE:
>  	case FTYPE_SOCKET: {
> @@ -557,6 +660,7 @@ int fstat(int fd, struct stat *buf)
>  	    break;
>      }
>  
> + error:
>      printk("statf(%d): Bad descriptor\n", fd);
>      errno = EBADF;
>      return -1;
> @@ -588,6 +692,27 @@ int fcntl(int fd, int cmd, ...)
>  {
>      long arg;
>      va_list ap;
> +    int res;
> +    struct file *file = get_file_from_fd(fd);
> +    const struct file_ops *ops;
> +
> +    if ( !file )
> +    {
> +        errno = EBADF;
> +        return -1;
> +    }
> +
> +    ops = get_file_ops(files[fd].type);
> +
> +    if ( ops->fcntl )
> +    {
> +        va_start(ap, cmd);
> +        res = ops->fcntl(file, cmd, ap);
> +        va_end(ap);
> +
> +        return res;
> +    }
> +
>      va_start(ap, cmd);
>      arg = va_arg(ap, long);
>      va_end(ap);
> @@ -641,17 +766,28 @@ int closedir(DIR *dir)
>  /* We assume that only the main thread calls select(). */
>  
>  #if defined(LIBC_DEBUG) || defined(LIBC_VERBOSE)
> -static const char file_types[] = {
> -    [FTYPE_NONE]	= 'N',
> -    [FTYPE_CONSOLE]	= 'C',
> -    [FTYPE_XENBUS]	= 'S',
> -    [FTYPE_EVTCHN]	= 'E',
> -    [FTYPE_SOCKET]	= 's',
> -    [FTYPE_TAP]		= 'T',
> -    [FTYPE_BLK]		= 'B',
> -    [FTYPE_KBD]		= 'K',
> -    [FTYPE_FB]		= 'G',
> +static const char *const file_types[] = {
> +    [FTYPE_NONE]    = "none",
> +    [FTYPE_CONSOLE] = "console",
> +    [FTYPE_XENBUS]  = "xenbus",
> +    [FTYPE_EVTCHN]  = "evtchn",
> +    [FTYPE_SOCKET]  = "socket",
> +    [FTYPE_TAP]     = "net",
> +    [FTYPE_BLK]     = "blk",
> +    [FTYPE_KBD]     = "kbd",
> +    [FTYPE_FB]      = "fb",
>  };
> +
> +static const char *get_type_name(unsigned int type)
> +{
> +    if ( type < ARRAY_SIZE(file_ops) && file_ops[type] )
> +        return file_ops[type]->name;
> +
> +    if ( type < ARRAY_SIZE(file_types) && file_types[type] )
> +        return file_types[type];
> +
> +    return "none";
> +}
>  #endif
>  #ifdef LIBC_DEBUG
>  static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
> @@ -663,7 +799,7 @@ static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *except
>  	if (FD_ISSET(i, set)) { \
>  	    if (comma) \
>  		printk(", "); \
> -	    printk("%d(%c)", i, file_types[files[i].type]); \
> +            printk("%d(%s)", i, get_type_name(files[i].type)); \
>  	    comma = 1; \
>  	} \
>      } \
> @@ -697,7 +833,7 @@ static void dump_pollfds(struct pollfd *pfd, int nfds, int timeout)
>          fd = pfd[i].fd;
>          if (comma)
>              printk(", ");
> -        printk("%d(%c)/%02x", fd, file_types[files[fd].type],
> +        printk("%d(%s)/%02x", fd, get_type_name(files[fd].type),
>              pfd[i].events);
>              comma = 1;
>      }
> @@ -709,6 +845,16 @@ static void dump_pollfds(struct pollfd *pfd, int nfds, int timeout)
>  #define dump_pollfds(pfds, nfds, timeout)
>  #endif
>  
> +bool select_yes(struct file *file)
> +{
> +    return true;
> +}
> +
> +bool select_read_flag(struct file *file)
> +{
> +    return file->read;
> +}
> +
>  /* Just poll without blocking */
>  static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
>  {
> @@ -760,11 +906,47 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  
>      /* Then see others as well. */
>      for (i = 0; i < nfds; i++) {
> -	switch(files[i].type) {
> +        struct file *file = get_file_from_fd(i);
> +
> +        if ( !file )
> +        {
> +            FD_CLR(i, readfds);
> +            FD_CLR(i, writefds);
> +            FD_CLR(i, exceptfds);
> +            continue;
> +        }
> +
> +        switch(file->type) {
>  	default:
> +        {
> +            const struct file_ops *ops = file_ops[file->type];
> +
> +            if ( ops )
> +            {
> +                if ( FD_ISSET(i, readfds) )
> +                {
> +                    if ( ops->select_rd && ops->select_rd(file) )
> +                        n++;
> +                    else
> +                        FD_CLR(i, readfds);
> +                }
> +                if ( FD_ISSET(i, writefds) )
> +                {
> +                    if ( ops->select_wr && ops->select_wr(file) )
> +                        n++;
> +                    else
> +                        FD_CLR(i, writefds);
> +                }
> +                FD_CLR(i, exceptfds);
> +
> +                break;
> +            }
> +
>  	    if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
>  		printk("bogus fd %d in select\n", i);
>  	    /* Fallthrough.  */
> +        }
> +
>  	case FTYPE_CONSOLE:
>  	    if (FD_ISSET(i, readfds)) {
>                  if (xencons_ring_avail(files[i].dev))
> @@ -842,7 +1024,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  	printk("%d(%d): ", nb, sock_n);
>  	for (i = 0; i < nfds; i++) {
>  	    if (nbread[i] || nbwrite[i] || nbexcept[i])
> -		printk(" %d(%c):", i, file_types[files[i].type]);
> +                printk(" %d(%c):", i, get_type_name(files[i].type));
>  	    if (nbread[i])
>  	    	printk(" %dR", nbread[i]);
>  	    if (nbwrite[i])
> -- 
> 2.26.2
> 

-- 
Samuel
* D a decide de peter un cable dans son rapport de pfp
<c> et il a bien raison ;-)
<c> tu vas dire quoi ?
<D> j'ai mis les paroles de "le coq est mort" en en-tete
 -+- #ens-mim et la peufeupeu -+-


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 20:40:55 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 20:40:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257936.443578 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CKd-0006HN-2g; Sun, 16 Jan 2022 20:40:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257936.443578; Sun, 16 Jan 2022 20:40:55 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CKc-0006HI-VB; Sun, 16 Jan 2022 20:40:54 +0000
Received: by outflank-mailman (input) for mailman id 257936;
 Sun, 16 Jan 2022 20:40:53 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9CKa-00061S-UI
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 20:40:53 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 97629077-770c-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 21:40:51 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 4CFA235D;
 Sun, 16 Jan 2022 21:40:50 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 9PwE0IZnYp5n; Sun, 16 Jan 2022 21:40:49 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 192978B;
 Sun, 16 Jan 2022 21:40:49 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9CKW-005uTY-FK;
 Sun, 16 Jan 2022 21:40:48 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 97629077-770c-11ec-a115-11989b9578b4
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 21:40:48 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 5/5] add CONFIG_LIBXS item
Message-ID: <20220116204048.ameywemmjyy6dtkm@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116064527.23519-1-jgross@suse.com>
 <20220116064527.23519-6-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220116064527.23519-6-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 4CFA235D
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 07:45:27 +0100, a ecrit:
> Mini-OS contains a stripped down version of libxenstore in lib/xs.c.
> Today it is being built always if CONFIG_XENBUS is set and libc
> support is enabled.
> 
> In order to allow a Mini-OS specific build of libxenstore to be used
> instead add a new CONFIG_LIBXS item which per default will have the
> same setting as CONFIG_XENBUS. A user wanting to replace lib/xs.c
> with libxenstore would just need to set CONFIG_XENBUS=y and
> CONFIG_LIBXS=n.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
> V3:
> - new patch
> ---
>  Config.mk                     | 10 ++++++++--
>  Makefile                      |  2 +-
>  arch/x86/testbuild/all-no     |  1 +
>  arch/x86/testbuild/all-yes    |  1 +
>  arch/x86/testbuild/newxen-yes |  1 +
>  lib/sys.c                     |  4 ++--
>  6 files changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/Config.mk b/Config.mk
> index 1e083881..03023033 100644
> --- a/Config.mk
> +++ b/Config.mk
> @@ -171,7 +171,10 @@ endif
>  # arch/*/testbuild/*-yes and arch/*/testbuild/*-no should set ALL possible
>  # CONFIG_ variables.
>  
> -# Configuration defaults
> +# Configuration defaults:
> +# CONFIG-y contains all items defaulting to "y"
> +# CONFIG-n contains all items defaulting to "n"
> +# CONFIG-x contains all items being calculated if not set explicitly
>  CONFIG-y += CONFIG_START_NETWORK
>  CONFIG-y += CONFIG_SPARSE_BSS
>  CONFIG-y += CONFIG_BLKFRONT
> @@ -205,7 +208,10 @@ CONFIG-$(lwip) += CONFIG_LWIP
>  $(foreach i,$(CONFIG-y),$(eval $(i) ?= y))
>  $(foreach i,$(CONFIG-n),$(eval $(i) ?= n))
>  
> -CONFIG-all := $(CONFIG-y) $(CONFIG-n)
> +CONFIG-x += CONFIG_LIBXS
> +CONFIG_LIBXS ?= $(CONFIG_XENBUS)
> +
> +CONFIG-all := $(CONFIG-y) $(CONFIG-n) $(CONFIG-x)
>  
>  # Export config items as compiler directives
>  $(foreach i,$(CONFIG-all),$(eval DEFINES-$($(i)) += -D$(i)))
> diff --git a/Makefile b/Makefile
> index 06b60fc7..9f95d197 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -65,7 +65,7 @@ src-y += lib/stack_chk_fail.c
>  src-y += lib/string.c
>  src-y += lib/sys.c
>  src-y += lib/xmalloc.c
> -src-$(CONFIG_XENBUS) += lib/xs.c
> +src-$(CONFIG_LIBXS) += lib/xs.c
>  
>  src-$(CONFIG_XENBUS) += xenbus/xenbus.c
>  
> diff --git a/arch/x86/testbuild/all-no b/arch/x86/testbuild/all-no
> index d6fc2608..46f974de 100644
> --- a/arch/x86/testbuild/all-no
> +++ b/arch/x86/testbuild/all-no
> @@ -13,6 +13,7 @@ CONFIG_FBFRONT = n
>  CONFIG_KBDFRONT = n
>  CONFIG_CONSFRONT = n
>  CONFIG_XENBUS = n
> +CONFIG_LIBXS = n
>  CONFIG_LIBXENEVTCHN = n
>  CONFIG_LIBXENGNTTAB = n
>  CONFIG_LWIP = n
> diff --git a/arch/x86/testbuild/all-yes b/arch/x86/testbuild/all-yes
> index 98bbfebf..3ead12f1 100644
> --- a/arch/x86/testbuild/all-yes
> +++ b/arch/x86/testbuild/all-yes
> @@ -13,6 +13,7 @@ CONFIG_FBFRONT = y
>  CONFIG_KBDFRONT = y
>  CONFIG_CONSFRONT = y
>  CONFIG_XENBUS = y
> +CONFIG_LIBXS = y
>  CONFIG_BALLOON = y
>  CONFIG_USE_XEN_CONSOLE = y
>  # The following are special: they need support from outside
> diff --git a/arch/x86/testbuild/newxen-yes b/arch/x86/testbuild/newxen-yes
> index 06032004..5c0b3c80 100644
> --- a/arch/x86/testbuild/newxen-yes
> +++ b/arch/x86/testbuild/newxen-yes
> @@ -13,6 +13,7 @@ CONFIG_FBFRONT = y
>  CONFIG_KBDFRONT = y
>  CONFIG_CONSFRONT = y
>  CONFIG_XENBUS = y
> +CONFIG_LIBXS = y
>  CONFIG_BALLOON = y
>  CONFIG_USE_XEN_CONSOLE = y
>  XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
> diff --git a/lib/sys.c b/lib/sys.c
> index 7be01fd3..e0ac5099 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -523,7 +523,7 @@ int close(int fd)
>      switch (file->type) {
>          default:
>              break;
> -#ifdef CONFIG_XENBUS
> +#ifdef CONFIG_LIBXS
>  	case FTYPE_XENBUS:
>              xs_daemon_close((void*)(intptr_t) fd);
>              break;
> @@ -958,7 +958,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>                  n++;
>  	    FD_CLR(i, exceptfds);
>  	    break;
> -#ifdef CONFIG_XENBUS
> +#ifdef CONFIG_LIBXS
>  	case FTYPE_XENBUS:
>  	    if (FD_ISSET(i, readfds)) {
>                  if (files[i].dev)
> -- 
> 2.26.2
> 

-- 
Samuel
<s> bah, j'aime bien les feux d'artifices, mais j'ai peur de me prendre un boeing sur le coin de la gueule si je vais sur le pont de brooklyn
 -+- #ens-mim - 11 septembre forever -+-


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 20:41:09 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 20:41:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257940.443594 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CKr-0006p4-EG; Sun, 16 Jan 2022 20:41:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257940.443594; Sun, 16 Jan 2022 20:41:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CKr-0006op-AX; Sun, 16 Jan 2022 20:41:09 +0000
Received: by outflank-mailman (input) for mailman id 257940;
 Sun, 16 Jan 2022 20:41:08 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9CKq-00061S-Mk
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 20:41:08 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id a1a934a7-770c-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 21:41:08 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 87D6235D;
 Sun, 16 Jan 2022 21:41:07 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id wcgPmvj1aVF3; Sun, 16 Jan 2022 21:41:06 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id CEAEC9E;
 Sun, 16 Jan 2022 21:41:06 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9CKn-005uTn-2A;
 Sun, 16 Jan 2022 21:41:05 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: a1a934a7-770c-11ec-a115-11989b9578b4
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 21:41:05 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 0/5] mini-os: remove struct file dependency on
 config
Message-ID: <20220116204105.lf3uzw2u4hu3l2sx@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116064527.23519-1-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220116064527.23519-1-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 87D6235D
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 07:45:22 +0100, a ecrit:
> Today the layout of struct file is depending on the Mini-OS
> configuration. This is especially bad as the layout is exported to
> external users like the Xen libraries built for Mini-OS, and those
> are being built only once for multiple stubdom configurations.
> 
> Today there is no direct problem resulting from this, as the main
> difference between struct file layouts is a large union containing all
> the device specific data for the different file types. The largest
> union member is not configuration dependant, so the build is currently
> not broken.
> 
> In order to avoid any future problems this patch series is eliminating
> the configuration dependency by replacing most of the device specific
> union members by a single pointer.
> 
> The two union members used by Xen libraries can't be replaced yet, as
> those need to be switched to use the generic pointer first.
> 
> In order to hide the Mini-OS internal implementation of the files
> array, patches 1, 2, and  4 are introducing a common framework to
> access a struct file via its file descriptor, and to allocate new file
> types dynamically instead of having them all pre-defined. The file type
> specific operations are supplied via a function vector in order to
> remove the dependency of lib/sys.c on all the various file types.
> 
> Patch 5 is preparing a possible future support of libxenstore instead
> of using the Mini-OS internal variant located in lib/xs.c.

Thanks!

Samuel


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 20:53:08 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 20:53:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257959.443652 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CWR-0002pY-Pf; Sun, 16 Jan 2022 20:53:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257959.443652; Sun, 16 Jan 2022 20:53:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CWR-0002pR-MV; Sun, 16 Jan 2022 20:53:07 +0000
Received: by outflank-mailman (input) for mailman id 257959;
 Sun, 16 Jan 2022 20:53:06 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9CWQ-0002oK-GV
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 20:53:06 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 4d464ca7-770e-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 21:53:05 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id F2829427;
 Sun, 16 Jan 2022 21:53:04 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id FxKhzwWjZS1b; Sun, 16 Jan 2022 21:53:04 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id D766E18A;
 Sun, 16 Jan 2022 21:53:03 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9CWM-005udx-Qy;
 Sun, 16 Jan 2022 21:53:02 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 4d464ca7-770e-11ec-a115-11989b9578b4
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 21:53:02 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 01/12] remove event channel specific struct
 file definitions
Message-ID: <20220116205302.bp3j62v47rvo6zci@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-2-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220116083328.26524-2-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: F2829427
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 09:33:17 +0100, a ecrit:
> The event channel specific union member in struct file is no longer
> needed, so remove it together with the associated structure
> definitions.
> 
> The event channel file type and its associated handling can be removed,
> too, as libxenevtchn is now supplying a struct file_ops via a call of
> alloc_file_type().
> 
> This removes all contents of CONFIG_LIBXENEVTCHN guarded sections, so
> this config option can be removed.
> 
> Add an extern declaration for event_queue as it is used by
> libxenevtchn.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
> V3:
> - add extern declaration for event_queue (Andrew Cooper)
> ---
>  Config.mk                     |  1 -
>  arch/x86/testbuild/all-no     |  1 -
>  arch/x86/testbuild/all-yes    |  1 -
>  arch/x86/testbuild/newxen-yes |  1 -
>  include/lib.h                 | 17 +++--------------
>  lib/sys.c                     |  7 -------
>  6 files changed, 3 insertions(+), 25 deletions(-)
> 
> diff --git a/Config.mk b/Config.mk
> index 03023033..52eb26d8 100644
> --- a/Config.mk
> +++ b/Config.mk
> @@ -200,7 +200,6 @@ CONFIG-n += CONFIG_PARAVIRT
>  endif
>  # Support legacy CONFIG_XC value
>  CONFIG_XC ?= $(libc)
> -CONFIG-$(CONFIG_XC) += CONFIG_LIBXENEVTCHN
>  CONFIG-$(CONFIG_XC) += CONFIG_LIBXENGNTTAB
>  
>  CONFIG-$(lwip) += CONFIG_LWIP
> diff --git a/arch/x86/testbuild/all-no b/arch/x86/testbuild/all-no
> index 46f974de..15c954ff 100644
> --- a/arch/x86/testbuild/all-no
> +++ b/arch/x86/testbuild/all-no
> @@ -14,7 +14,6 @@ CONFIG_KBDFRONT = n
>  CONFIG_CONSFRONT = n
>  CONFIG_XENBUS = n
>  CONFIG_LIBXS = n
> -CONFIG_LIBXENEVTCHN = n
>  CONFIG_LIBXENGNTTAB = n
>  CONFIG_LWIP = n
>  CONFIG_BALLOON = n
> diff --git a/arch/x86/testbuild/all-yes b/arch/x86/testbuild/all-yes
> index 3ead12f1..9964d42f 100644
> --- a/arch/x86/testbuild/all-yes
> +++ b/arch/x86/testbuild/all-yes
> @@ -17,6 +17,5 @@ CONFIG_LIBXS = y
>  CONFIG_BALLOON = y
>  CONFIG_USE_XEN_CONSOLE = y
>  # The following are special: they need support from outside
> -CONFIG_LIBXENEVTCHN = n
>  CONFIG_LIBXENGNTTAB = n
>  CONFIG_LWIP = n
> diff --git a/arch/x86/testbuild/newxen-yes b/arch/x86/testbuild/newxen-yes
> index 5c0b3c80..c2519938 100644
> --- a/arch/x86/testbuild/newxen-yes
> +++ b/arch/x86/testbuild/newxen-yes
> @@ -18,6 +18,5 @@ CONFIG_BALLOON = y
>  CONFIG_USE_XEN_CONSOLE = y
>  XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
>  # The following are special: they need support from outside
> -CONFIG_LIBXENEVTCHN = n
>  CONFIG_LIBXENGNTTAB = n
>  CONFIG_LWIP = n
> diff --git a/include/lib.h b/include/lib.h
> index 44696806..5f24be5d 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -155,6 +155,8 @@ do {                                                           \
>  void sanity_check(void);
>  
>  #ifdef HAVE_LIBC
> +extern struct wait_queue_head event_queue;
> +
>  #define FTYPE_NONE       0
>  #define FTYPE_CONSOLE    1
>  #define FTYPE_FILE       2
> @@ -169,19 +171,9 @@ void sanity_check(void);
>  #define FTYPE_TPM_TIS   11
>  #define FTYPE_XENBUS    12
>  #define FTYPE_GNTMAP    13
> -#define FTYPE_EVTCHN    14
> -#define FTYPE_N         15
> +#define FTYPE_N         14
>  #define FTYPE_SPARE     16
>  
> -LIST_HEAD(evtchn_port_list, evtchn_port_info);
> -
> -struct evtchn_port_info {
> -        LIST_ENTRY(evtchn_port_info) list;
> -        evtchn_port_t port;
> -        unsigned long pending;
> -        int bound;
> -};
> -
>  struct file {
>      unsigned int type;
>      bool read;	/* maybe available for read */
> @@ -189,9 +181,6 @@ struct file {
>      union {
>          int fd; /* Any fd from an upper layer. */
>          void *dev;
> -	struct {
> -	    struct evtchn_port_list ports;
> -	} evtchn;
>  	struct gntmap gntmap;
>      };
>  };
> diff --git a/lib/sys.c b/lib/sys.c
> index e0ac5099..34f0193d 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -533,11 +533,6 @@ int close(int fd)
>              res = lwip_close(files[fd].fd);
>              break;
>  #endif
> -#ifdef CONFIG_LIBXENEVTCHN
> -	case FTYPE_EVTCHN:
> -	    minios_evtchn_close_fd(fd);
> -            break;
> -#endif
>  #ifdef CONFIG_LIBXENGNTTAB
>  	case FTYPE_GNTMAP:
>  	    minios_gnttab_close_fd(fd);
> @@ -770,7 +765,6 @@ static const char *const file_types[] = {
>      [FTYPE_NONE]    = "none",
>      [FTYPE_CONSOLE] = "console",
>      [FTYPE_XENBUS]  = "xenbus",
> -    [FTYPE_EVTCHN]  = "evtchn",
>      [FTYPE_SOCKET]  = "socket",
>      [FTYPE_TAP]     = "net",
>      [FTYPE_BLK]     = "blk",
> @@ -970,7 +964,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  	    FD_CLR(i, exceptfds);
>  	    break;
>  #endif
> -	case FTYPE_EVTCHN:
>  	case FTYPE_TAP:
>  	case FTYPE_BLK:
>  	case FTYPE_KBD:
> -- 
> 2.26.2
> 

-- 
Samuel
 tohi.cybercable.fr (212.198.0.3) si une personne se reconnait derriere
 cette adresse que ce soit un pirate ou une victime qu'il se manifeste,
 cette personne pourrait bien etre un petit malin
 -+- Fred in NPC : Mamaaaaan, y a le routeur qui veut me hacker -+-


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 20:54:36 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 20:54:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257962.443666 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CXr-0003V7-5Y; Sun, 16 Jan 2022 20:54:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257962.443666; Sun, 16 Jan 2022 20:54:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CXr-0003V0-2Y; Sun, 16 Jan 2022 20:54:35 +0000
Received: by outflank-mailman (input) for mailman id 257962;
 Sun, 16 Jan 2022 20:54:33 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9CXp-0003Up-Iq
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 20:54:33 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 812140a0-770e-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 21:54:32 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id BCA3018A;
 Sun, 16 Jan 2022 21:54:31 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id zJEEp-MXQuam; Sun, 16 Jan 2022 21:54:31 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id DC1F98B;
 Sun, 16 Jan 2022 21:54:30 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9CXm-005ueK-6L;
 Sun, 16 Jan 2022 21:54:30 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 812140a0-770e-11ec-9bbc-9dff3e4ee8c5
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 21:54:30 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 03/12] use alloc_file_type() and
 get_file_from_fd() in xs
Message-ID: <20220116205430.k6xc6migl4c5iwcy@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-4-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20220116083328.26524-4-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: BCA3018A
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 09:33:19 +0100, a ecrit:
> Allocate the needed file type via alloc_file_type().
> 
> Instead of directly accessing the files[] array use get_file_from_fd().
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
> V3:
> - switch to struct file * parameter for callbacks
> - use __attribute__((constructor))
> ---
>  include/lib.h   |  3 +--
>  lib/sys.c       | 18 --------------
>  lib/xs.c        | 65 +++++++++++++++++++++++++++++++++++++------------
>  xenbus/xenbus.c |  1 +
>  4 files changed, 52 insertions(+), 35 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 5838b0d4..c5e47786 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -169,8 +169,7 @@ extern struct wait_queue_head event_queue;
>  #define FTYPE_BLK        9
>  #define FTYPE_TPMFRONT  10
>  #define FTYPE_TPM_TIS   11
> -#define FTYPE_XENBUS    12
> -#define FTYPE_N         13
> +#define FTYPE_N         12
>  #define FTYPE_SPARE     16
>  
>  struct file {
> diff --git a/lib/sys.c b/lib/sys.c
> index 6ba26294..53870aa4 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -523,11 +523,6 @@ int close(int fd)
>      switch (file->type) {
>          default:
>              break;
> -#ifdef CONFIG_LIBXS
> -	case FTYPE_XENBUS:
> -            xs_daemon_close((void*)(intptr_t) fd);
> -            break;
> -#endif
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
>              res = lwip_close(files[fd].fd);
> @@ -759,7 +754,6 @@ int closedir(DIR *dir)
>  static const char *const file_types[] = {
>      [FTYPE_NONE]    = "none",
>      [FTYPE_CONSOLE] = "console",
> -    [FTYPE_XENBUS]  = "xenbus",
>      [FTYPE_SOCKET]  = "socket",
>      [FTYPE_TAP]     = "net",
>      [FTYPE_BLK]     = "blk",
> @@ -947,18 +941,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>                  n++;
>  	    FD_CLR(i, exceptfds);
>  	    break;
> -#ifdef CONFIG_LIBXS
> -	case FTYPE_XENBUS:
> -	    if (FD_ISSET(i, readfds)) {
> -                if (files[i].dev)
> -		    n++;
> -		else
> -		    FD_CLR(i, readfds);
> -	    }
> -	    FD_CLR(i, writefds);
> -	    FD_CLR(i, exceptfds);
> -	    break;
> -#endif
>  	case FTYPE_TAP:
>  	case FTYPE_BLK:
>  	case FTYPE_KBD:
> diff --git a/lib/xs.c b/lib/xs.c
> index 4af0f960..c12341aa 100644
> --- a/lib/xs.c
> +++ b/lib/xs.c
> @@ -18,23 +18,56 @@ static inline int _xs_fileno(struct xs_handle *h) {
>      return (intptr_t) h;
>  }
>  
> +static int xs_close_fd(struct file *file)
> +{
> +    struct xenbus_event *event, *next;
> +
> +    for (event = file->dev; event; event = next)
> +    {
> +        next = event->next;
> +        free(event);
> +    }
> +
> +    return 0;
> +}
> +
> +static bool xs_can_read(struct file *file)
> +{
> +    return file && file->dev;
> +}
> +
> +static const struct file_ops xenbus_ops = {
> +    .name = "xenbus",
> +    .close = xs_close_fd,
> +    .select_rd = xs_can_read,
> +};
> +
> +static unsigned int ftype_xenbus;
> +
> +__attribute__((constructor))
> +static void xs_initialize(void)
> +{
> +    ftype_xenbus = alloc_file_type(&xenbus_ops);
> +}
> +
>  struct xs_handle *xs_daemon_open()
>  {
> -    int fd = alloc_fd(FTYPE_XENBUS);
> -    files[fd].dev = NULL;
> -    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].dev);
> +    int fd;
> +    struct file *file;
> +
> +    fd = alloc_fd(ftype_xenbus);
> +    file = get_file_from_fd(fd);
> +    if ( !file )
> +        return NULL;
> +
> +    file->dev = NULL;
> +    printk("xs_daemon_open -> %d, %p\n", fd, &file->dev);
>      return (void*)(intptr_t) fd;
>  }
>  
>  void xs_daemon_close(struct xs_handle *h)
>  {
> -    int fd = _xs_fileno(h);
> -    struct xenbus_event *event, *next;
> -    for (event = files[fd].dev; event; event = next)
> -    {
> -        next = event->next;
> -        free(event);
> -    }
> +    close(_xs_fileno(h));
>  }
>  
>  int xs_fileno(struct xs_handle *h)
> @@ -169,18 +202,20 @@ char **xs_directory(struct xs_handle *h, xs_transaction_t t,
>  
>  bool xs_watch(struct xs_handle *h, const char *path, const char *token)
>  {
> -    int fd = _xs_fileno(h);
> +    struct file *file = get_file_from_fd(_xs_fileno(h));
> +
>      printk("xs_watch(%s, %s)\n", path, token);
>      return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token,
> -                   (xenbus_event_queue *)&files[fd].dev));
> +                   (xenbus_event_queue *)&file->dev));
>  }
>  
>  char **xs_read_watch(struct xs_handle *h, unsigned int *num)
>  {
> -    int fd = _xs_fileno(h);
>      struct xenbus_event *event;
> -    event = files[fd].dev;
> -    files[fd].dev = event->next;
> +    struct file *file = get_file_from_fd(_xs_fileno(h));
> +
> +    event = file->dev;
> +    file->dev = event->next;
>      printk("xs_read_watch() -> %s %s\n", event->path, event->token);
>      *num = 2;
>      return (char **) &event->path;
> diff --git a/xenbus/xenbus.c b/xenbus/xenbus.c
> index b687678f..785389fb 100644
> --- a/xenbus/xenbus.c
> +++ b/xenbus/xenbus.c
> @@ -393,6 +393,7 @@ static int allocate_xenbus_id(void)
>  void init_xenbus(void)
>  {
>      int err;
> +
>      DEBUG("init_xenbus called.\n");
>      create_thread("xenstore", xenbus_thread_func, NULL);
>      DEBUG("buf at %p.\n", xenstore_buf);
> -- 
> 2.26.2
> 

-- 
Samuel
 RR> Ce que je cherche à démontrer, c'est qu'il est injuste de faire
 RR> l'amalgame entre du bulk mail et du courrier non-solicité très ciblé
 un suppositoire non reclamé, meme tres bien ciblé, reste un suppositoire.
 -+-OS in : Guide du Neuneu d'Usenet - Plein le cul de la pub à neuneu -+-


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 20:56:09 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 20:56:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257966.443687 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CZN-0004HG-0J; Sun, 16 Jan 2022 20:56:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257966.443687; Sun, 16 Jan 2022 20:56:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CZM-0004FT-S7; Sun, 16 Jan 2022 20:56:08 +0000
Received: by outflank-mailman (input) for mailman id 257966;
 Sun, 16 Jan 2022 20:56:08 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9CZM-0004AK-1R
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 20:56:08 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id b8ef6927-770e-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 21:56:06 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 967C618A;
 Sun, 16 Jan 2022 21:56:05 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id mkK-BXapKSIo; Sun, 16 Jan 2022 21:56:04 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 6E41F8B;
 Sun, 16 Jan 2022 21:56:04 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9CZH-005uei-NW;
 Sun, 16 Jan 2022 21:56:03 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: b8ef6927-770e-11ec-9bbc-9dff3e4ee8c5
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 21:56:03 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 04/12] use alloc_file_type() and
 get_file_from_fd() in tpm_tis
Message-ID: <20220116205603.xscu3yb4wrjxubeu@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-5-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20220116083328.26524-5-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 967C618A
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 09:33:20 +0100, a ecrit:
> Allocate a file type dynamically via alloc_file_type().
> 
> Instead of directly accessing the files[] array use get_file_from_fd().
> 
> Make some now local functions static and modify their prototypes to
> match the file_ops requirements.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
> V3:
> - switch to struct file * parameter for callbacks
> - use __attribute__((constructor))
> ---
>  include/lib.h     |   3 +-
>  include/tpm_tis.h |   6 ---
>  lib/sys.c         |  23 ---------
>  tpm_tis.c         | 121 +++++++++++++++++++++++++++++-----------------
>  4 files changed, 78 insertions(+), 75 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index c5e47786..9dfb4689 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -168,8 +168,7 @@ extern struct wait_queue_head event_queue;
>  #define FTYPE_TAP        8
>  #define FTYPE_BLK        9
>  #define FTYPE_TPMFRONT  10
> -#define FTYPE_TPM_TIS   11
> -#define FTYPE_N         12
> +#define FTYPE_N         11
>  #define FTYPE_SPARE     16
>  
>  struct file {
> diff --git a/include/tpm_tis.h b/include/tpm_tis.h
> index 86e83f13..2af974db 100644
> --- a/include/tpm_tis.h
> +++ b/include/tpm_tis.h
> @@ -37,14 +37,11 @@ struct tpm_chip;
>  
>  struct tpm_chip* init_tpm_tis(unsigned long baseaddr, int localities, unsigned int irq);
>  struct tpm_chip* init_tpm2_tis(unsigned long baseaddr, int localities, unsigned int irq);
> -void shutdown_tpm_tis(struct tpm_chip* tpm);
>  
>  int tpm_tis_request_locality(struct tpm_chip* tpm, int locality);
>  int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** resp, size_t* resplen);
>  
>  #ifdef HAVE_LIBC
> -#include <sys/stat.h>
> -#include <fcntl.h>
>  /* POSIX IO functions:
>   * use tpm_tis_open() to get a file descriptor to the tpm device
>   * use write() on the fd to send a command to the backend. You must
> @@ -53,9 +50,6 @@ int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** res
>   * fstat() to get the size of the response and lseek() to seek on it.
>   */
>  int tpm_tis_open(struct tpm_chip* tpm);
> -int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count);
> -int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count);
> -int tpm_tis_posix_fstat(int fd, struct stat* buf);
>  #endif
>  
>  #endif
> diff --git a/lib/sys.c b/lib/sys.c
> index 53870aa4..2fc81f20 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -29,7 +29,6 @@
>  #include <blkfront.h>
>  #include <fbfront.h>
>  #include <tpmfront.h>
> -#include <tpm_tis.h>
>  #include <xenbus.h>
>  #include <xenstore.h>
>  #include <poll.h>
> @@ -355,11 +354,6 @@ int read(int fd, void *buf, size_t nbytes)
>          case FTYPE_TPMFRONT: {
>  	    return tpmfront_posix_read(fd, buf, nbytes);
>          }
> -#endif
> -#ifdef CONFIG_TPM_TIS
> -        case FTYPE_TPM_TIS: {
> -	    return tpm_tis_posix_read(fd, buf, nbytes);
> -        }
>  #endif
>  	default:
>  	    break;
> @@ -412,10 +406,6 @@ int write(int fd, const void *buf, size_t nbytes)
>  #ifdef CONFIG_TPMFRONT
>  	case FTYPE_TPMFRONT:
>  	    return tpmfront_posix_write(fd, buf, nbytes);
> -#endif
> -#ifdef CONFIG_TPM_TIS
> -	case FTYPE_TPM_TIS:
> -	    return tpm_tis_posix_write(fd, buf, nbytes);
>  #endif
>  	default:
>  	    break;
> @@ -482,10 +472,6 @@ off_t lseek(int fd, off_t offset, int whence)
>  #ifdef CONFIG_TPMFRONT
>         case FTYPE_TPMFRONT:
>            break;
> -#endif
> -#ifdef CONFIG_TPM_TIS
> -       case FTYPE_TPM_TIS:
> -          break;
>  #endif
>         case FTYPE_FILE:
>            break;
> @@ -543,11 +529,6 @@ int close(int fd)
>              shutdown_tpmfront(files[fd].dev);
>              break;
>  #endif
> -#ifdef CONFIG_TPM_TIS
> -	case FTYPE_TPM_TIS:
> -            shutdown_tpm_tis(files[fd].dev);
> -            break;
> -#endif
>  #ifdef CONFIG_KBDFRONT
>  	case FTYPE_KBD:
>              shutdown_kbdfront(files[fd].dev);
> @@ -636,10 +617,6 @@ int fstat(int fd, struct stat *buf)
>  #ifdef CONFIG_TPMFRONT
>  	case FTYPE_TPMFRONT:
>  	   return tpmfront_posix_fstat(fd, buf);
> -#endif
> -#ifdef CONFIG_TPM_TIS
> -	case FTYPE_TPM_TIS:
> -	   return tpm_tis_posix_fstat(fd, buf);
>  #endif
>  	default:
>  	    break;
> diff --git a/tpm_tis.c b/tpm_tis.c
> index 477f5550..b88ec874 100644
> --- a/tpm_tis.c
> +++ b/tpm_tis.c
> @@ -792,6 +792,9 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
>     int status, burstcnt = 0;
>     int count = 0;
>     uint32_t ordinal;
> +#ifdef HAVE_LIBC
> +   struct file *file = get_file_from_fd(tpm->fd);
> +#endif
>  
>     if(tpm_tis_request_locality(tpm, tpm->locality) < 0) {
>        return -EBUSY;
> @@ -844,9 +847,10 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
>        }
>     }
>  #ifdef HAVE_LIBC
> -   if(tpm->fd >= 0) {
> -      files[tpm->fd].read = false;
> -      files[tpm->fd].offset = 0;
> +   if ( file )
> +   {
> +      file->read = false;
> +      file->offset = 0;
>     }
>  #endif
>     return len;
> @@ -1093,6 +1097,26 @@ ssize_t tpm_getcap(struct tpm_chip *chip, uint32_t subcap_id, cap_t *cap,
>          return rc;
>  }
>  
> +static void shutdown_tpm_tis(struct tpm_chip *tpm)
> +{
> +    int i;
> +
> +    printk("Shutting down tpm_tis device\n");
> +
> +    iowrite32(TPM_INT_ENABLE(tpm, tpm->locality), ~TPM_GLOBAL_INT_ENABLE);
> +
> +    /* Unmap all of the mmio pages */
> +    for ( i = 0; i < 5; ++i )
> +    {
> +        if ( tpm->pages[i] != NULL )
> +        {
> +            iounmap(tpm->pages[i], PAGE_SIZE);
> +            tpm->pages[i] = NULL;
> +        }
> +    }
> +    free(tpm);
> +    return;
> +}
>  
>  struct tpm_chip* init_tpm_tis(unsigned long baseaddr, int localities, unsigned int irq)
>  {
> @@ -1242,25 +1266,6 @@ abort_egress:
>     return NULL;
>  }
>  
> -void shutdown_tpm_tis(struct tpm_chip* tpm){
> -   int i;
> -
> -   printk("Shutting down tpm_tis device\n");
> -
> -   iowrite32(TPM_INT_ENABLE(tpm, tpm->locality), ~TPM_GLOBAL_INT_ENABLE);
> -
> -   /*Unmap all of the mmio pages */
> -   for(i = 0; i < 5; ++i) {
> -      if(tpm->pages[i] != NULL) {
> -	 iounmap(tpm->pages[i], PAGE_SIZE);
> -	 tpm->pages[i] = NULL;
> -      }
> -   }
> -   free(tpm);
> -   return;
> -}
> -
> -
>  int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** resp, size_t* resplen)
>  {
>     if(tpm->locality < 0) {
> @@ -1279,23 +1284,19 @@ int tpm_tis_cmd(struct tpm_chip* tpm, uint8_t* req, size_t reqlen, uint8_t** res
>  }
>  
>  #ifdef HAVE_LIBC
> -int tpm_tis_open(struct tpm_chip* tpm)
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +
> +static int tpm_tis_close(struct file *file)
>  {
> -   /* Silently prevent multiple opens */
> -   if(tpm->fd != -1) {
> -      return tpm->fd;
> -   }
> +    shutdown_tpm_tis(file->dev);
>  
> -   tpm->fd = alloc_fd(FTYPE_TPM_TIS);
> -   printk("tpm_tis_open() -> %d\n", tpm->fd);
> -   files[tpm->fd].dev = tpm;
> -   return tpm->fd;
> +    return 0;
>  }
>  
> -int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count)
> +static int tpm_tis_posix_write(struct file *file, const void *buf, size_t count)
>  {
> -   struct tpm_chip* tpm;
> -   tpm = files[fd].dev;
> +   struct tpm_chip *tpm = file->dev;
>  
>     if(tpm->locality < 0) {
>        printk("tpm_tis_posix_write() failed! locality not set!\n");
> @@ -1319,11 +1320,10 @@ int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count)
>     return count;
>  }
>  
> -int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
> +static int tpm_tis_posix_read(struct file *file, void *buf, size_t count)
>  {
>     int rc;
> -   struct tpm_chip* tpm;
> -   tpm = files[fd].dev;
> +   struct tpm_chip *tpm = file->dev;
>  
>     if(count == 0) {
>        return 0;
> @@ -1337,20 +1337,21 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t count)
>  
>  
>     /* Handle EOF case */
> -   if(files[fd].offset >= tpm->data_len) {
> +   if ( file->offset >= tpm->data_len )
> +   {
>        rc = 0;
>     } else {
> -      rc = min(tpm->data_len - files[fd].offset, count);
> -      memcpy(buf, tpm->data_buffer + files[fd].offset, rc);
> +      rc = min(tpm->data_len - file->offset, count);
> +      memcpy(buf, tpm->data_buffer + file->offset, rc);
>     }
> -   files[fd].offset += rc;
> +   file->offset += rc;
>     /* Reset the data pending flag */
>     return rc;
>  }
> -int tpm_tis_posix_fstat(int fd, struct stat* buf)
> +
> +static int tpm_tis_posix_fstat(struct file *file, struct stat *buf)
>  {
> -   struct tpm_chip* tpm;
> -   tpm = files[fd].dev;
> +   struct tpm_chip *tpm = file->dev;
>  
>     buf->st_mode = O_RDWR;
>     buf->st_uid = 0;
> @@ -1360,6 +1361,38 @@ int tpm_tis_posix_fstat(int fd, struct stat* buf)
>     return 0;
>  }
>  
> +static const struct file_ops tpm_tis_ops = {
> +    .name = "tpm_tis",
> +    .read = tpm_tis_posix_read,
> +    .write = tpm_tis_posix_write,
> +    .lseek = lseek_default,
> +    .close = tpm_tis_close,
> +    .fstat = tpm_tis_posix_fstat,
> +};
> +
> +static unsigned int ftype_tis;
> +
> +__attribute__((constructor))
> +static void tpm_tis_initialize(void)
> +{
> +    ftype_tis = alloc_file_type(&tpm_tis_ops);
> +}
> +
> +int tpm_tis_open(struct tpm_chip *tpm)
> +{
> +    struct file *file;
> +
> +    /* Silently prevent multiple opens */
> +    if ( tpm->fd != -1 )
> +        return tpm->fd;
> +
> +    tpm->fd = alloc_fd(ftype_tis);
> +    printk("tpm_tis_open() -> %d\n", tpm->fd);
> +    file = get_file_from_fd(tpm->fd);
> +    file->dev = tpm;
> +    return tpm->fd;
> +}
> +
>  /* TPM 2.0 */
>  
>  /*TPM2.0 Selftest*/
> -- 
> 2.26.2
> 

-- 
Samuel
 > et sinon, quand on s'interesse a un media que l'on ne maitrise pas,
 > on essaye de le comprendre d'abord.
 (Suivi par l'intégralité du message initial de 45 lignes.)
 -+-BM in : GNU - La maîtrise est un long apprentissage petit scarabé -+-


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 20:57:24 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 20:57:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257969.443696 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CaZ-0004vd-4r; Sun, 16 Jan 2022 20:57:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257969.443696; Sun, 16 Jan 2022 20:57:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CaZ-0004vW-1m; Sun, 16 Jan 2022 20:57:23 +0000
Received: by outflank-mailman (input) for mailman id 257969;
 Sun, 16 Jan 2022 20:57:22 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9CaY-0004vO-AA
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 20:57:22 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id e5a9602d-770e-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 21:57:21 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 9F5D72BC;
 Sun, 16 Jan 2022 21:57:20 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id iukV3sVfvEPg; Sun, 16 Jan 2022 21:57:19 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 97A3A9E;
 Sun, 16 Jan 2022 21:57:19 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9CaU-005uf4-Tp;
 Sun, 16 Jan 2022 21:57:18 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e5a9602d-770e-11ec-9bbc-9dff3e4ee8c5
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 21:57:18 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 05/12] use alloc_file_type() and
 get_file_from_fd() in tpmfront
Message-ID: <20220116205718.cyraq5u5zfqkuev2@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-6-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220116083328.26524-6-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 9F5D72BC
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 09:33:21 +0100, a ecrit:
> Allocate a file type dynamically via alloc_file_type().
> 
> Instead of directly accessing the files[] array use get_file_from_fd().
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
> V3:
> - switch to struct file * parameter for callbacks
> - use __attribute__((constructor))
> ---
>  include/lib.h      |   3 +-
>  include/tpmfront.h |   5 ---
>  lib/sys.c          |  23 -----------
>  tpmfront.c         | 100 ++++++++++++++++++++++++++++++---------------
>  4 files changed, 69 insertions(+), 62 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 9dfb4689..9b7eaae7 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -167,8 +167,7 @@ extern struct wait_queue_head event_queue;
>  #define FTYPE_KBD        7
>  #define FTYPE_TAP        8
>  #define FTYPE_BLK        9
> -#define FTYPE_TPMFRONT  10
> -#define FTYPE_N         11
> +#define FTYPE_N         10
>  #define FTYPE_SPARE     16
>  
>  struct file {
> diff --git a/include/tpmfront.h b/include/tpmfront.h
> index b7da50e3..a527371b 100644
> --- a/include/tpmfront.h
> +++ b/include/tpmfront.h
> @@ -81,7 +81,6 @@ int tpmfront_cmd(struct tpmfront_dev* dev, uint8_t* req, size_t reqlen, uint8_t*
>  int tpmfront_set_locality(struct tpmfront_dev* dev, int locality);
>  
>  #ifdef HAVE_LIBC
> -#include <sys/stat.h>
>  /* POSIX IO functions:
>   * use tpmfront_open() to get a file descriptor to the tpm device
>   * use write() on the fd to send a command to the backend. You must
> @@ -90,10 +89,6 @@ int tpmfront_set_locality(struct tpmfront_dev* dev, int locality);
>   * fstat() to get the size of the response and lseek() to seek on it.
>   */
>  int tpmfront_open(struct tpmfront_dev* dev);
> -int tpmfront_posix_read(int fd, uint8_t* buf, size_t count);
> -int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count);
> -int tpmfront_posix_fstat(int fd, struct stat* buf);
>  #endif
>  
> -
>  #endif
> diff --git a/lib/sys.c b/lib/sys.c
> index 2fc81f20..39f51980 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -28,7 +28,6 @@
>  #include <netfront.h>
>  #include <blkfront.h>
>  #include <fbfront.h>
> -#include <tpmfront.h>
>  #include <xenbus.h>
>  #include <xenstore.h>
>  #include <poll.h>
> @@ -349,11 +348,6 @@ int read(int fd, void *buf, size_t nbytes)
>          case FTYPE_BLK: {
>  	    return blkfront_posix_read(fd, buf, nbytes);
>          }
> -#endif
> -#ifdef CONFIG_TPMFRONT
> -        case FTYPE_TPMFRONT: {
> -	    return tpmfront_posix_read(fd, buf, nbytes);
> -        }
>  #endif
>  	default:
>  	    break;
> @@ -402,10 +396,6 @@ int write(int fd, const void *buf, size_t nbytes)
>  #ifdef CONFIG_BLKFRONT
>  	case FTYPE_BLK:
>  	    return blkfront_posix_write(fd, buf, nbytes);
> -#endif
> -#ifdef CONFIG_TPMFRONT
> -	case FTYPE_TPMFRONT:
> -	    return tpmfront_posix_write(fd, buf, nbytes);
>  #endif
>  	default:
>  	    break;
> @@ -468,10 +458,6 @@ off_t lseek(int fd, off_t offset, int whence)
>  #ifdef CONFIG_BLKFRONT
>         case FTYPE_BLK:
>            break;
> -#endif
> -#ifdef CONFIG_TPMFRONT
> -       case FTYPE_TPMFRONT:
> -          break;
>  #endif
>         case FTYPE_FILE:
>            break;
> @@ -524,11 +510,6 @@ int close(int fd)
>              shutdown_blkfront(files[fd].dev);
>              break;
>  #endif
> -#ifdef CONFIG_TPMFRONT
> -	case FTYPE_TPMFRONT:
> -            shutdown_tpmfront(files[fd].dev);
> -            break;
> -#endif
>  #ifdef CONFIG_KBDFRONT
>  	case FTYPE_KBD:
>              shutdown_kbdfront(files[fd].dev);
> @@ -613,10 +594,6 @@ int fstat(int fd, struct stat *buf)
>  #ifdef CONFIG_BLKFRONT
>  	case FTYPE_BLK:
>  	   return blkfront_posix_fstat(fd, buf);
> -#endif
> -#ifdef CONFIG_TPMFRONT
> -	case FTYPE_TPMFRONT:
> -	   return tpmfront_posix_fstat(fd, buf);
>  #endif
>  	default:
>  	    break;
> diff --git a/tpmfront.c b/tpmfront.c
> index 0a2fefc5..13163ad6 100644
> --- a/tpmfront.c
> +++ b/tpmfront.c
> @@ -49,6 +49,10 @@
>  void tpmfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) {
>     struct tpmfront_dev* dev = (struct tpmfront_dev*) data;
>     tpmif_shared_page_t *shr = dev->page;
> +#ifdef HAVE_LIBC
> +    struct file *file = get_file_from_fd(dev->fd);
> +#endif
> +
>     /*If we get a response when we didnt make a request, just ignore it */
>     if(!dev->waiting) {
>        return;
> @@ -65,8 +69,9 @@ void tpmfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) {
>  
>     dev->waiting = 0;
>  #ifdef HAVE_LIBC
> -   if(dev->fd >= 0) {
> -      files[dev->fd].read = true;
> +   if ( file )
> +   {
> +      file->read = true;
>     }
>  #endif
>     wake_up(&dev->waitq);
> @@ -405,6 +410,10 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
>  #ifdef TPMFRONT_PRINT_DEBUG
>     int i;
>  #endif
> +#ifdef HAVE_LIBC
> +    struct file *file = dev ? get_file_from_fd(dev->fd) : NULL;
> +#endif
> +
>     /* Error Checking */
>     if(dev == NULL || dev->state != XenbusStateConnected) {
>        TPMFRONT_ERR("Tried to send message through disconnected frontend\n");
> @@ -437,9 +446,10 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
>     dev->waiting = 1;
>     dev->resplen = 0;
>  #ifdef HAVE_LIBC
> -   if(dev->fd >= 0) {
> -      files[dev->fd].read = false;
> -      files[dev->fd].offset = 0;
> +   if ( file )
> +   {
> +      file->read = false;
> +      file->offset = 0;
>        dev->respgot = false;
>     }
>  #endif
> @@ -529,25 +539,11 @@ int tpmfront_set_locality(struct tpmfront_dev* dev, int locality)
>  
>  #ifdef HAVE_LIBC
>  #include <errno.h>
> -int tpmfront_open(struct tpmfront_dev* dev)
> -{
> -   /* Silently prevent multiple opens */
> -   if(dev->fd != -1) {
> -      return dev->fd;
> -   }
>  
> -   dev->fd = alloc_fd(FTYPE_TPMFRONT);
> -   printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
> -   files[dev->fd].dev = dev;
> -   dev->respgot = false;
> -   return dev->fd;
> -}
> -
> -int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count)
> +static int tpmfront_posix_write(struct file *file, const void *buf, size_t count)
>  {
>     int rc;
> -   struct tpmfront_dev* dev;
> -   dev = files[fd].dev;
> +   struct tpmfront_dev *dev = file->dev;
>  
>     if(count == 0) {
>        return 0;
> @@ -566,14 +562,12 @@ int tpmfront_posix_write(int fd, const uint8_t* buf, size_t count)
>     return count;
>  }
>  
> -int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
> +static int tpmfront_posix_read(struct file *file, void *buf, size_t count)
>  {
>     int rc;
>     uint8_t* dummybuf;
>     size_t dummysz;
> -   struct tpmfront_dev* dev;
> -
> -   dev = files[fd].dev;
> +   struct tpmfront_dev *dev = file->dev;
>  
>     if(count == 0) {
>        return 0;
> @@ -588,29 +582,32 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
>     }
>  
>     /* handle EOF case */
> -   if(files[dev->fd].offset >= dev->resplen) {
> +   if ( file->offset >= dev->resplen )
> +   {
>        return 0;
>     }
>  
>     /* Compute the number of bytes and do the copy operation */
> -   if((rc = min(count, dev->resplen - files[dev->fd].offset)) != 0) {
> -      memcpy(buf, dev->respbuf + files[dev->fd].offset, rc);
> -      files[dev->fd].offset += rc;
> +   if ( (rc = min(count, dev->resplen - file->offset)) != 0 )
> +   {
> +      memcpy(buf, dev->respbuf + file->offset, rc);
> +      file->offset += rc;
>     }
>  
>     return rc;
>  }
>  
> -int tpmfront_posix_fstat(int fd, struct stat* buf)
> +static int tpmfront_posix_fstat(struct file *file, struct stat *buf)
>  {
>     uint8_t* dummybuf;
>     size_t dummysz;
>     int rc;
> -   struct tpmfront_dev* dev = files[fd].dev;
> +   struct tpmfront_dev *dev = file->dev;
>  
>     /* If we have a response waiting, then read it now from the backend
>      * so we can get its length*/
> -   if(dev->waiting || (files[dev->fd].read && !dev->respgot)) {
> +   if ( dev->waiting || (file->read && !dev->respgot) )
> +   {
>        if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
>  	 errno = EIO;
>  	 return -1;
> @@ -626,5 +623,44 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
>     return 0;
>  }
>  
> +static int tpmfront_close_fd(struct file *file)
> +{
> +    shutdown_tpmfront(file->dev);
> +
> +    return 0;
> +}
> +
> +static const struct file_ops tpmfront_ops = {
> +    .name = "tpmfront",
> +    .read = tpmfront_posix_read,
> +    .write = tpmfront_posix_write,
> +    .lseek = lseek_default,
> +    .close = tpmfront_close_fd,
> +    .fstat = tpmfront_posix_fstat,
> +};
> +
> +static unsigned int ftype_tpmfront;
> +
> +__attribute__((constructor))
> +static void tpmfront_initialize(void)
> +{
> +    ftype_tpmfront = alloc_file_type(&tpmfront_ops);
> +}
> +
> +int tpmfront_open(struct tpmfront_dev *dev)
> +{
> +    struct file *file;
> +
> +    /* Silently prevent multiple opens */
> +    if ( dev->fd != -1 )
> +        return dev->fd;
> +
> +    dev->fd = alloc_fd(ftype_tpmfront);
> +    printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
> +    file = get_file_from_fd(dev->fd);
> +    file->dev = dev;
> +    dev->respgot = false;
> +    return dev->fd;
> +}
>  
>  #endif
> -- 
> 2.26.2
> 

-- 
Samuel
requests.</FONT></SPAN></TD></TR></TBODY></TABLE></DIV></BODY></HTML>agnjo
gj a po  mi
shnthdrdcvallus hsx mvgduwolgfwtq
uzuy
s
p
h
 -+- spams forever ... -+- 


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 20:58:41 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 20:58:41 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257972.443711 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9Cbo-0005au-Gn; Sun, 16 Jan 2022 20:58:40 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257972.443711; Sun, 16 Jan 2022 20:58:40 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9Cbo-0005an-Dy; Sun, 16 Jan 2022 20:58:40 +0000
Received: by outflank-mailman (input) for mailman id 257972;
 Sun, 16 Jan 2022 20:58:39 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9Cbm-0005aY-V3
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 20:58:38 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 13627af0-770f-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 21:58:37 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 530F72BC;
 Sun, 16 Jan 2022 21:58:37 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id ESx-dx9ZXdhJ; Sun, 16 Jan 2022 21:58:36 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 9CCDA18A;
 Sun, 16 Jan 2022 21:58:35 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9Cbi-005ufR-UQ;
 Sun, 16 Jan 2022 21:58:34 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 13627af0-770f-11ec-a115-11989b9578b4
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 21:58:34 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 06/12] use alloc_file_type() and
 get_file_from_fd() in blkfront
Message-ID: <20220116205834.n5duepw7txpitf4x@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-7-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220116083328.26524-7-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 530F72BC
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 09:33:22 +0100, a ecrit:
> Allocate the file type dynamically via alloc_file_type().
> 
> Instead of directly accessing the files[] array use get_file_from_fd().
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
> V3:
> - switch to struct file * parameter for callbacks
> - use __attribute__((constructor))
> ---
>  blkfront.c         | 92 ++++++++++++++++++++++++++++++++++------------
>  include/blkfront.h |  5 ---
>  include/lib.h      |  3 +-
>  lib/sys.c          | 24 ------------
>  4 files changed, 69 insertions(+), 55 deletions(-)
> 
> diff --git a/blkfront.c b/blkfront.c
> index e3f42bef..ed902702 100644
> --- a/blkfront.c
> +++ b/blkfront.c
> @@ -59,10 +59,10 @@ void blkfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
>  {
>  #ifdef HAVE_LIBC
>      struct blkfront_dev *dev = data;
> -    int fd = dev->fd;
> +    struct file *file = get_file_from_fd(dev->fd);
>  
> -    if (fd != -1)
> -        files[fd].read = true;
> +    if ( file )
> +        file->read = true;
>  #endif
>      wake_up(&blkfront_queue);
>  }
> @@ -483,9 +483,13 @@ int blkfront_aio_poll(struct blkfront_dev *dev)
>  
>  moretodo:
>  #ifdef HAVE_LIBC
> -    if (dev->fd != -1) {
> -        files[dev->fd].read = false;
> -        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
> +    {
> +        struct file *file = get_file_from_fd(dev->fd);
> +
> +        if ( file ) {
> +            file->read = false;
> +            mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
> +        }
>      }
>  #endif
>  
> @@ -554,22 +558,11 @@ moretodo:
>  }
>  
>  #ifdef HAVE_LIBC
> -int blkfront_open(struct blkfront_dev *dev)
> +static int blkfront_posix_rwop(struct file *file, uint8_t *buf, size_t count,
> +                               bool write)
>  {
> -    /* Silently prevent multiple opens */
> -    if(dev->fd != -1) {
> -       return dev->fd;
> -    }
> -    dev->fd = alloc_fd(FTYPE_BLK);
> -    printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
> -    files[dev->fd].dev = dev;
> -    return dev->fd;
> -}
> -
> -int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
> -{
> -   struct blkfront_dev* dev = files[fd].dev;
> -   off_t offset = files[fd].offset;
> +   struct blkfront_dev *dev = file->dev;
> +   off_t offset = file->offset;
>     struct blkfront_aiocb aiocb;
>     unsigned long long disksize = dev->info.sectors * dev->info.sector_size;
>     unsigned int blocksize = dev->info.sector_size;
> @@ -711,14 +704,24 @@ int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write)
>     }
>  
>     free(copybuf);
> -   files[fd].offset += rc;
> +   file->offset += rc;
>     return rc;
>  
>  }
>  
> -int blkfront_posix_fstat(int fd, struct stat* buf)
> +static int blkfront_posix_read(struct file *file, void *buf, size_t nbytes)
>  {
> -   struct blkfront_dev* dev = files[fd].dev;
> +    return blkfront_posix_rwop(file, buf, nbytes, false);
> +}
> +
> +static int blkfront_posix_write(struct file *file, const void *buf, size_t nbytes)
> +{
> +    return blkfront_posix_rwop(file, (void *)buf, nbytes, true);
> +}
> +
> +static int blkfront_posix_fstat(struct file *file, struct stat *buf)
> +{
> +   struct blkfront_dev *dev = file->dev;
>  
>     buf->st_mode = dev->info.mode;
>     buf->st_uid = 0;
> @@ -728,4 +731,45 @@ int blkfront_posix_fstat(int fd, struct stat* buf)
>  
>     return 0;
>  }
> +
> +static int blkfront_close_fd(struct file *file)
> +{
> +    shutdown_blkfront(file->dev);
> +
> +    return 0;
> +}
> +
> +static const struct file_ops blk_ops = {
> +    .name = "blk",
> +    .read = blkfront_posix_read,
> +    .write = blkfront_posix_write,
> +    .lseek = lseek_default,
> +    .close = blkfront_close_fd,
> +    .fstat = blkfront_posix_fstat,
> +    .select_rd = select_read_flag,
> +};
> +
> +static unsigned int ftype_blk;
> +
> +__attribute__((constructor))
> +static void blkfron_initialize(void)
> +{
> +    ftype_blk = alloc_file_type(&blk_ops);
> +}
> +
> +int blkfront_open(struct blkfront_dev *dev)
> +{
> +    struct file *file;
> +
> +    /* Silently prevent multiple opens */
> +    if ( dev->fd != -1 )
> +        return dev->fd;
> +
> +    dev->fd = alloc_fd(ftype_blk);
> +    printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
> +    file = get_file_from_fd(dev->fd);
> +    file->dev = dev;
> +
> +    return dev->fd;
> +}
>  #endif
> diff --git a/include/blkfront.h b/include/blkfront.h
> index 3528af9d..7f84a0a2 100644
> --- a/include/blkfront.h
> +++ b/include/blkfront.h
> @@ -28,17 +28,12 @@ struct blkfront_info
>  };
>  struct blkfront_dev *init_blkfront(char *nodename, struct blkfront_info *info);
>  #ifdef HAVE_LIBC
> -#include <sys/stat.h>
>  /* POSIX IO functions:
>   * use blkfront_open() to get a file descriptor to the block device
>   * Don't use the other blkfront posix functions here directly, instead use
>   * read(), write(), lseek() and fstat() on the file descriptor
>   */
>  int blkfront_open(struct blkfront_dev *dev);
> -int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write);
> -#define blkfront_posix_write(fd, buf, count) blkfront_posix_rwop(fd, (uint8_t*)buf, count, 1)
> -#define blkfront_posix_read(fd, buf, count) blkfront_posix_rwop(fd, (uint8_t*)buf, count, 0)
> -int blkfront_posix_fstat(int fd, struct stat* buf);
>  #endif
>  void blkfront_aio(struct blkfront_aiocb *aiocbp, int write);
>  #define blkfront_aio_read(aiocbp) blkfront_aio(aiocbp, 0)
> diff --git a/include/lib.h b/include/lib.h
> index 9b7eaae7..2f472b00 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -166,8 +166,7 @@ extern struct wait_queue_head event_queue;
>  #define FTYPE_FB         6
>  #define FTYPE_KBD        7
>  #define FTYPE_TAP        8
> -#define FTYPE_BLK        9
> -#define FTYPE_N         10
> +#define FTYPE_N          9
>  #define FTYPE_SPARE     16
>  
>  struct file {
> diff --git a/lib/sys.c b/lib/sys.c
> index 39f51980..90684335 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -343,11 +343,6 @@ int read(int fd, void *buf, size_t nbytes)
>  	    }
>  	    return ret * sizeof(union xenfb_in_event);
>          }
> -#endif
> -#ifdef CONFIG_BLKFRONT
> -        case FTYPE_BLK: {
> -	    return blkfront_posix_read(fd, buf, nbytes);
> -        }
>  #endif
>  	default:
>  	    break;
> @@ -392,10 +387,6 @@ int write(int fd, const void *buf, size_t nbytes)
>  	case FTYPE_TAP:
>  	    netfront_xmit(files[fd].dev, (void*) buf, nbytes);
>  	    return nbytes;
> -#endif
> -#ifdef CONFIG_BLKFRONT
> -	case FTYPE_BLK:
> -	    return blkfront_posix_write(fd, buf, nbytes);
>  #endif
>  	default:
>  	    break;
> @@ -455,10 +446,6 @@ off_t lseek(int fd, off_t offset, int whence)
>          return ops->lseek(file, offset, whence);
>  
>      switch(file->type) {
> -#ifdef CONFIG_BLKFRONT
> -       case FTYPE_BLK:
> -          break;
> -#endif
>         case FTYPE_FILE:
>            break;
>         default:
> @@ -505,11 +492,6 @@ int close(int fd)
>  	    shutdown_netfront(files[fd].dev);
>              break;
>  #endif
> -#ifdef CONFIG_BLKFRONT
> -	case FTYPE_BLK:
> -            shutdown_blkfront(files[fd].dev);
> -            break;
> -#endif
>  #ifdef CONFIG_KBDFRONT
>  	case FTYPE_KBD:
>              shutdown_kbdfront(files[fd].dev);
> @@ -591,10 +573,6 @@ int fstat(int fd, struct stat *buf)
>  	    buf->st_ctime = time(NULL);
>  	    return 0;
>  	}
> -#ifdef CONFIG_BLKFRONT
> -	case FTYPE_BLK:
> -	   return blkfront_posix_fstat(fd, buf);
> -#endif
>  	default:
>  	    break;
>      }
> @@ -710,7 +688,6 @@ static const char *const file_types[] = {
>      [FTYPE_CONSOLE] = "console",
>      [FTYPE_SOCKET]  = "socket",
>      [FTYPE_TAP]     = "net",
> -    [FTYPE_BLK]     = "blk",
>      [FTYPE_KBD]     = "kbd",
>      [FTYPE_FB]      = "fb",
>  };
> @@ -896,7 +873,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  	    FD_CLR(i, exceptfds);
>  	    break;
>  	case FTYPE_TAP:
> -	case FTYPE_BLK:
>  	case FTYPE_KBD:
>  	case FTYPE_FB:
>  	    if (FD_ISSET(i, readfds)) {
> -- 
> 2.26.2
> 

-- 
Samuel
After watching my newly-retired dad spend two weeks learning how to make a new
folder, it became obvious that "intuitive" mostly means "what the writer or
speaker of intuitive likes".
(Bruce Ediger, bediger@teal.csn.org, in comp.os.linux.misc, on X the
intuitiveness of a Mac interface.)


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 20:59:32 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 20:59:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257975.443727 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9Cce-0006Df-SN; Sun, 16 Jan 2022 20:59:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257975.443727; Sun, 16 Jan 2022 20:59:32 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9Cce-0006DY-OM; Sun, 16 Jan 2022 20:59:32 +0000
Received: by outflank-mailman (input) for mailman id 257975;
 Sun, 16 Jan 2022 20:59:31 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9Ccd-00069b-4T
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 20:59:31 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 329fc830-770f-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 21:59:30 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id B83F02BC;
 Sun, 16 Jan 2022 21:59:29 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 1ey5ZPJk3wMJ; Sun, 16 Jan 2022 21:59:28 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 826AB9E;
 Sun, 16 Jan 2022 21:59:28 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9CcZ-005ufi-Qv;
 Sun, 16 Jan 2022 21:59:27 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 329fc830-770f-11ec-9bbc-9dff3e4ee8c5
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 21:59:27 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 07/12] use alloc_file_type() and
 get_file_from_fd() in netfront
Message-ID: <20220116205927.6rmacurejuvr6jdk@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-8-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20220116083328.26524-8-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: B83F02BC
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 09:33:23 +0100, a ecrit:
> Allocate the file type dynamically via alloc_file_type().
> 
> Instead of directly accessing the files[] array use get_file_from_fd().
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
> V3:
> - switch to struct file * parameter for callbacks
> - use __attribute__((constructor))
> ---
>  include/lib.h      |  3 +--
>  include/netfront.h |  3 ++-
>  lib/sys.c          | 23 ----------------
>  netfront.c         | 65 +++++++++++++++++++++++++++++++++++++++-------
>  4 files changed, 59 insertions(+), 35 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 2f472b00..b0d08807 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -165,8 +165,7 @@ extern struct wait_queue_head event_queue;
>  #define FTYPE_SAVEFILE   5
>  #define FTYPE_FB         6
>  #define FTYPE_KBD        7
> -#define FTYPE_TAP        8
> -#define FTYPE_N          9
> +#define FTYPE_N          8
>  #define FTYPE_SPARE     16
>  
>  struct file {
> diff --git a/include/netfront.h b/include/netfront.h
> index ec641c80..75080c26 100644
> --- a/include/netfront.h
> +++ b/include/netfront.h
> @@ -10,7 +10,8 @@ struct netfront_dev *init_netfront(char *nodename,
>                                     char **ip);
>  char *netfront_get_netmask(struct netfront_dev *dev);
>  char *netfront_get_gateway(struct netfront_dev *dev);
> -void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len);
> +void netfront_xmit(struct netfront_dev *dev, const unsigned char *data,
> +                   int len);
>  void shutdown_netfront(struct netfront_dev *dev);
>  void suspend_netfront(void);
>  void resume_netfront(void);
> diff --git a/lib/sys.c b/lib/sys.c
> index 90684335..44fe848c 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -309,17 +309,6 @@ int read(int fd, void *buf, size_t nbytes)
>          case FTYPE_SOCKET:
>  	    return lwip_read(files[fd].fd, buf, nbytes);
>  #endif
> -#ifdef CONFIG_NETFRONT
> -	case FTYPE_TAP: {
> -	    ssize_t ret;
> -	    ret = netfront_receive(files[fd].dev, buf, nbytes);
> -	    if (ret <= 0) {
> -		errno = EAGAIN;
> -		return -1;
> -	    }
> -	    return ret;
> -	}
> -#endif
>  #ifdef CONFIG_KBDFRONT
>          case FTYPE_KBD: {
>              int ret, n;
> @@ -382,11 +371,6 @@ int write(int fd, const void *buf, size_t nbytes)
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
>  	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
> -#endif
> -#ifdef CONFIG_NETFRONT
> -	case FTYPE_TAP:
> -	    netfront_xmit(files[fd].dev, (void*) buf, nbytes);
> -	    return nbytes;
>  #endif
>  	default:
>  	    break;
> @@ -487,11 +471,6 @@ int close(int fd)
>              res = lwip_close(files[fd].fd);
>              break;
>  #endif
> -#ifdef CONFIG_NETFRONT
> -	case FTYPE_TAP:
> -	    shutdown_netfront(files[fd].dev);
> -            break;
> -#endif
>  #ifdef CONFIG_KBDFRONT
>  	case FTYPE_KBD:
>              shutdown_kbdfront(files[fd].dev);
> @@ -687,7 +666,6 @@ static const char *const file_types[] = {
>      [FTYPE_NONE]    = "none",
>      [FTYPE_CONSOLE] = "console",
>      [FTYPE_SOCKET]  = "socket",
> -    [FTYPE_TAP]     = "net",
>      [FTYPE_KBD]     = "kbd",
>      [FTYPE_FB]      = "fb",
>  };
> @@ -872,7 +850,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>                  n++;
>  	    FD_CLR(i, exceptfds);
>  	    break;
> -	case FTYPE_TAP:
>  	case FTYPE_KBD:
>  	case FTYPE_FB:
>  	    if (FD_ISSET(i, readfds)) {
> diff --git a/netfront.c b/netfront.c
> index 76964514..164fdc66 100644
> --- a/netfront.c
> +++ b/netfront.c
> @@ -248,14 +248,14 @@ void netfront_select_handler(evtchn_port_t port, struct pt_regs *regs, void *dat
>  {
>      int flags;
>      struct netfront_dev *dev = data;
> -    int fd = dev->fd;
> +    struct file *file = get_file_from_fd(dev->fd);
>  
>      local_irq_save(flags);
>      network_tx_buf_gc(dev);
>      local_irq_restore(flags);
>  
> -    if (fd != -1)
> -        files[fd].read = true;
> +    if ( file )
> +        file->read = true;
>      wake_up(&netfront_queue);
>  }
>  #endif
> @@ -565,8 +565,53 @@ error:
>  }
>  
>  #ifdef HAVE_LIBC
> +static int netfront_read(struct file *file, void *buf, size_t nbytes)
> +{
> +    ssize_t ret;
> +
> +    ret = netfront_receive(file->dev, buf, nbytes);
> +    if ( ret <= 0 )
> +    {
> +        errno = EAGAIN;
> +        return -1;
> +    }
> +
> +    return ret;
> +}
> +
> +static int netfront_write(struct file *file, const void *buf, size_t nbytes)
> +{
> +    netfront_xmit(file->dev, buf, nbytes);
> +
> +    return nbytes;
> +}
> +
> +static int netfront_close_fd(struct file *file)
> +{
> +    shutdown_netfront(file->dev);
> +
> +    return 0;
> +}
> +
> +static const struct file_ops netfront_ops = {
> +    .name = "net",
> +    .read = netfront_read,
> +    .write = netfront_write,
> +    .close = netfront_close_fd,
> +    .select_rd = select_read_flag,
> +};
> +
> +static unsigned int ftype_netfront;
> +
> +__attribute__((constructor))
> +static void netfront_initialize(void)
> +{
> +    ftype_netfront = alloc_file_type(&netfront_ops);
> +}
> +
>  int netfront_tap_open(char *nodename) {
>      struct netfront_dev *dev;
> +    struct file *file;
>  
>      dev = init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL);
>      if (!dev) {
> @@ -574,9 +619,10 @@ int netfront_tap_open(char *nodename) {
>  	errno = EIO;
>  	return -1;
>      }
> -    dev->fd = alloc_fd(FTYPE_TAP);
> +    dev->fd = alloc_fd(ftype_netfront);
>      printk("tap_open(%s) -> %d\n", nodename, dev->fd);
> -    files[dev->fd].dev = dev;
> +    file = get_file_from_fd(dev->fd);
> +    file->dev = dev;
>      return dev->fd;
>  }
>  #endif
> @@ -720,7 +766,7 @@ void init_rx_buffers(struct netfront_dev *dev)
>  }
>  
>  
> -void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len)
> +void netfront_xmit(struct netfront_dev *dev, const unsigned char *data, int len)
>  {
>      int flags;
>      struct netif_tx_request *tx;
> @@ -772,7 +818,8 @@ void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len)
>  ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t len)
>  {
>      unsigned long flags;
> -    int fd = dev->fd;
> +    struct file *file = get_file_from_fd(dev->fd);
> +
>      ASSERT(current == main_thread);
>  
>      dev->rlen = 0;
> @@ -781,9 +828,9 @@ ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t l
>  
>      local_irq_save(flags);
>      network_rx(dev);
> -    if (!dev->rlen && fd != -1)
> +    if ( !dev->rlen && file )
>          /* No data for us, make select stop returning */
> -        files[fd].read = false;
> +        file->read = false;
>      /* Before re-enabling the interrupts, in case a packet just arrived in the
>       * meanwhile. */
>      local_irq_restore(flags);
> -- 
> 2.26.2
> 

-- 
Samuel
<O> Ça peut être une madeleine à sous munitions (avec des composants,
par exemple)
 -+- #runtime -+-


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 21:00:46 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 21:00:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257979.443741 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9Cdp-0007is-CX; Sun, 16 Jan 2022 21:00:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257979.443741; Sun, 16 Jan 2022 21:00:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9Cdp-0007il-9B; Sun, 16 Jan 2022 21:00:45 +0000
Received: by outflank-mailman (input) for mailman id 257979;
 Sun, 16 Jan 2022 21:00:44 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9Cdn-0007iW-UW
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 21:00:43 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 5de12094-770f-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 22:00:42 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 3335F2BC;
 Sun, 16 Jan 2022 22:00:42 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id PQzj961g6pcr; Sun, 16 Jan 2022 22:00:40 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 3DE1D18A;
 Sun, 16 Jan 2022 22:00:40 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9Cdj-005ug7-Ga;
 Sun, 16 Jan 2022 22:00:39 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 5de12094-770f-11ec-a115-11989b9578b4
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 22:00:39 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 08/12] use alloc_file_type() and
 get_file_from_fd() in fbfront
Message-ID: <20220116210039.nv735nymrji4fbyg@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-9-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20220116083328.26524-9-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 3335F2BC
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 09:33:24 +0100, a ecrit:
> Allocate file types dynamically via alloc_file_type().
> 
> Instead of directly accessing the files[] array use get_file_from_fd().
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
> V3:
> - switch to struct file * parameter for callbacks
> - use __attribute__((constructor))
> ---
>  fbfront.c     | 127 ++++++++++++++++++++++++++++++++++++++++++--------
>  include/lib.h |   4 +-
>  lib/sys.c     |  47 -------------------
>  3 files changed, 108 insertions(+), 70 deletions(-)
> 
> diff --git a/fbfront.c b/fbfront.c
> index 1e055fb0..360a9cf6 100644
> --- a/fbfront.c
> +++ b/fbfront.c
> @@ -14,6 +14,9 @@
>  #include <mini-os/xmalloc.h>
>  #include <mini-os/fbfront.h>
>  #include <mini-os/lib.h>
> +#ifdef HAVE_LIBC
> +#include <errno.h>
> +#endif
>  
>  DECLARE_WAIT_QUEUE_HEAD(kbdfront_queue);
>  
> @@ -42,10 +45,10 @@ void kbdfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
>  {
>  #ifdef HAVE_LIBC
>      struct kbdfront_dev *dev = data;
> -    int fd = dev->fd;
> +    struct file *file = get_file_from_fd(dev->fd);
>  
> -    if (fd != -1)
> -        files[fd].read = true;
> +    if ( file )
> +        file->read = true;
>  #endif
>      wake_up(&kbdfront_queue);
>  }
> @@ -204,10 +207,12 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
>      struct xenkbd_page *page = dev->page;
>      uint32_t prod, cons;
>      int i;
> -
>  #ifdef HAVE_LIBC
> -    if (dev->fd != -1) {
> -        files[dev->fd].read = false;
> +    struct file *file = get_file_from_fd(dev->fd);
> +
> +    if ( file )
> +    {
> +        file->read = false;
>          mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
>      }
>  #endif
> @@ -227,9 +232,9 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
>      notify_remote_via_evtchn(dev->evtchn);
>  
>  #ifdef HAVE_LIBC
> -    if (cons != prod && dev->fd != -1)
> +    if ( cons != prod && file )
>          /* still some events to read */
> -        files[dev->fd].read = true;
> +        file->read = true;
>  #endif
>  
>      return i;
> @@ -298,11 +303,51 @@ close_kbdfront:
>  }
>  
>  #ifdef HAVE_LIBC
> +static int kbd_read(struct file *file, void *buf, size_t nbytes)
> +{
> +    int ret, n;
> +
> +    n = nbytes / sizeof(union xenkbd_in_event);
> +    ret = kbdfront_receive(file->dev, buf, n);
> +    if ( ret <= 0 )
> +    {
> +        errno = EAGAIN;
> +        return -1;
> +    }
> +
> +    return ret * sizeof(union xenkbd_in_event);
> +}
> +
> +static int kbd_close_fd(struct file *file)
> +{
> +    shutdown_kbdfront(file->dev);
> +
> +    return 0;
> +}
> +
> +static struct file_ops kbd_ops = {
> +    .name = "kbd",
> +    .read = kbd_read,
> +    .close = kbd_close_fd,
> +    .select_rd = select_read_flag,
> +};
> +
> +static unsigned int ftype_kbd;
> +
> +__attribute__((constructor))
> +static void kbdfront_initialize(void)
> +{
> +    ftype_kbd = alloc_file_type(&kbd_ops);
> +}
> +
>  int kbdfront_open(struct kbdfront_dev *dev)
>  {
> -    dev->fd = alloc_fd(FTYPE_KBD);
> +    struct file *file;
> +
> +    dev->fd = alloc_fd(ftype_kbd);
>      printk("kbd_open(%s) -> %d\n", dev->nodename, dev->fd);
> -    files[dev->fd].dev = dev;
> +    file = get_file_from_fd(dev->fd);
> +    file->dev = dev;
>      return dev->fd;
>  }
>  #endif
> @@ -346,10 +391,10 @@ void fbfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
>  {
>  #ifdef HAVE_LIBC
>      struct fbfront_dev *dev = data;
> -    int fd = dev->fd;
> +    struct file *file = get_file_from_fd(dev->fd);
>  
> -    if (fd != -1)
> -        files[fd].read = true;
> +    if ( file )
> +        file->read = true;
>  #endif
>      wake_up(&fbfront_queue);
>  }
> @@ -373,10 +418,12 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
>      struct xenfb_page *page = dev->page;
>      uint32_t prod, cons;
>      int i;
> -
>  #ifdef HAVE_LIBC
> -    if (dev->fd != -1) {
> -        files[dev->fd].read = false;
> +    struct file *file = get_file_from_fd(dev->fd);
> +
> +    if ( file )
> +    {
> +        file->read = false;
>          mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
>      }
>  #endif
> @@ -396,9 +443,9 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
>      notify_remote_via_evtchn(dev->evtchn);
>  
>  #ifdef HAVE_LIBC
> -    if (cons != prod && dev->fd != -1)
> +    if ( cons != prod && file )
>          /* still some events to read */
> -        files[dev->fd].read = true;
> +        file->read = true;
>  #endif
>  
>      return i;
> @@ -699,11 +746,51 @@ close_fbfront:
>  }
>  
>  #ifdef HAVE_LIBC
> +static int fbfront_read(struct file *file, void *buf, size_t nbytes)
> +{
> +    int ret, n;
> +
> +    n = nbytes / sizeof(union xenfb_in_event);
> +    ret = fbfront_receive(file->dev, buf, n);
> +    if ( ret <= 0 )
> +    {
> +        errno = EAGAIN;
> +        return -1;
> +    }
> +
> +    return ret * sizeof(union xenfb_in_event);
> +}
> +
> +static int fbfront_close_fd(struct file *file)
> +{
> +    shutdown_fbfront(file->dev);
> +
> +    return 0;
> +}
> +
> +static const struct file_ops fb_ops = {
> +    .name = "fb",
> +    .read = fbfront_read,
> +    .close = fbfront_close_fd,
> +    .select_rd = select_read_flag,
> +};
> +
> +static unsigned int ftype_fb;
> +
> +__attribute__((constructor))
> +static void fbfront_initialize(void)
> +{
> +    ftype_fb = alloc_file_type(&fb_ops);
> +}
> +
>  int fbfront_open(struct fbfront_dev *dev)
>  {
> -    dev->fd = alloc_fd(FTYPE_FB);
> +    struct file *file;
> +
> +    dev->fd = alloc_fd(ftype_fb);
>      printk("fb_open(%s) -> %d\n", dev->nodename, dev->fd);
> -    files[dev->fd].dev = dev;
> +    file = get_file_from_fd(dev->fd);
> +    file->dev = dev;
>      return dev->fd;
>  }
>  #endif
> diff --git a/include/lib.h b/include/lib.h
> index b0d08807..b1beeed3 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -163,9 +163,7 @@ extern struct wait_queue_head event_queue;
>  #define FTYPE_SOCKET     3
>  #define FTYPE_MEM        4
>  #define FTYPE_SAVEFILE   5
> -#define FTYPE_FB         6
> -#define FTYPE_KBD        7
> -#define FTYPE_N          8
> +#define FTYPE_N          6
>  #define FTYPE_SPARE     16
>  
>  struct file {
> diff --git a/lib/sys.c b/lib/sys.c
> index 44fe848c..db26fd2d 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -308,30 +308,6 @@ int read(int fd, void *buf, size_t nbytes)
>  #ifdef HAVE_LWIP
>          case FTYPE_SOCKET:
>  	    return lwip_read(files[fd].fd, buf, nbytes);
> -#endif
> -#ifdef CONFIG_KBDFRONT
> -        case FTYPE_KBD: {
> -            int ret, n;
> -            n = nbytes / sizeof(union xenkbd_in_event);
> -            ret = kbdfront_receive(files[fd].dev, buf, n);
> -	    if (ret <= 0) {
> -		errno = EAGAIN;
> -		return -1;
> -	    }
> -	    return ret * sizeof(union xenkbd_in_event);
> -        }
> -#endif
> -#ifdef CONFIG_FBFRONT
> -        case FTYPE_FB: {
> -            int ret, n;
> -            n = nbytes / sizeof(union xenfb_in_event);
> -            ret = fbfront_receive(files[fd].dev, buf, n);
> -	    if (ret <= 0) {
> -		errno = EAGAIN;
> -		return -1;
> -	    }
> -	    return ret * sizeof(union xenfb_in_event);
> -        }
>  #endif
>  	default:
>  	    break;
> @@ -471,16 +447,6 @@ int close(int fd)
>              res = lwip_close(files[fd].fd);
>              break;
>  #endif
> -#ifdef CONFIG_KBDFRONT
> -	case FTYPE_KBD:
> -            shutdown_kbdfront(files[fd].dev);
> -            break;
> -#endif
> -#ifdef CONFIG_FBFRONT
> -	case FTYPE_FB:
> -            shutdown_fbfront(files[fd].dev);
> -            break;
> -#endif
>  #ifdef CONFIG_CONSFRONT
>          case FTYPE_SAVEFILE:
>          case FTYPE_CONSOLE:
> @@ -666,8 +632,6 @@ static const char *const file_types[] = {
>      [FTYPE_NONE]    = "none",
>      [FTYPE_CONSOLE] = "console",
>      [FTYPE_SOCKET]  = "socket",
> -    [FTYPE_KBD]     = "kbd",
> -    [FTYPE_FB]      = "fb",
>  };
>  
>  static const char *get_type_name(unsigned int type)
> @@ -850,17 +814,6 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>                  n++;
>  	    FD_CLR(i, exceptfds);
>  	    break;
> -	case FTYPE_KBD:
> -	case FTYPE_FB:
> -	    if (FD_ISSET(i, readfds)) {
> -		if (files[i].read)
> -		    n++;
> -		else
> -		    FD_CLR(i, readfds);
> -	    }
> -	    FD_CLR(i, writefds);
> -	    FD_CLR(i, exceptfds);
> -	    break;
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
>  	    if (FD_ISSET(i, readfds)) {
> -- 
> 2.26.2
> 

-- 
Samuel
<B> l'alim je sais où elle est, elle est juste à côté de la dame qui dort
<g> B: clairement faut revoir les priorités dans la vie
<g> B: une dame ça se retrouve, un uptime...


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 21:02:01 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 21:02:01 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257982.443757 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9Cf2-0008O3-QI; Sun, 16 Jan 2022 21:02:00 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257982.443757; Sun, 16 Jan 2022 21:02:00 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9Cf2-0008Nw-NT; Sun, 16 Jan 2022 21:02:00 +0000
Received: by outflank-mailman (input) for mailman id 257982;
 Sun, 16 Jan 2022 21:01:59 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9Cf1-0008Ne-BX
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 21:01:59 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 8ab2e3c8-770f-11ec-a115-11989b9578b4;
 Sun, 16 Jan 2022 22:01:58 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 7EE9D2BC;
 Sun, 16 Jan 2022 22:01:57 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 63LiGb4pADcA; Sun, 16 Jan 2022 22:01:56 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id A804818A;
 Sun, 16 Jan 2022 22:01:55 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9Cew-005ugU-VA;
 Sun, 16 Jan 2022 22:01:54 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 8ab2e3c8-770f-11ec-a115-11989b9578b4
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 22:01:54 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 09/12] use file_ops and get_file_from_fd() for
 console
Message-ID: <20220116210154.atobr2ikhljyiaah@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-10-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20220116083328.26524-10-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 7EE9D2BC
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 09:33:25 +0100, a ecrit:
> Add struct file_ops for the console related file types (FTYPE_CONSOLE
> and savefile). FTYPE_CONSOLE remains statically defined, as it is used
> to statically init stdin, stdout and stderr.
> 
> Instead of directly accessing the files[] array use get_file_from_fd().
> 
> With CONSOLE now handled via file_ops the bogus file descriptor case in
> select_poll() now needs to be handled more explicit instead of dropping
> into console handling, assuming that this case was basically meant to
> cover SAVEFILE.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
> V3:
> - switch to struct file * parameter for callbacks
> - use __attribute__((constructor))
> - make console_print() take a const pointer (Andrew Cooper)
> ---
>  console/console.c      |   2 +-
>  console/xenbus.c       | 112 +++++++++++++++++++++++++++++++++++++++++
>  console/xencons_ring.c |   6 +--
>  include/console.h      |   7 ++-
>  include/lib.h          |   3 +-
>  lib/sys.c              |  87 ++++++++------------------------
>  6 files changed, 144 insertions(+), 73 deletions(-)
> 
> diff --git a/console/console.c b/console/console.c
> index af1a6dd3..68c8435e 100644
> --- a/console/console.c
> +++ b/console/console.c
> @@ -76,7 +76,7 @@ void xencons_tx(void)
>  #endif
>  
>  
> -void console_print(struct consfront_dev *dev, char *data, int length)
> +void console_print(struct consfront_dev *dev, const char *data, int length)
>  {
>      char *curr_char, saved_char;
>      char copied_str[length+1];
> diff --git a/console/xenbus.c b/console/xenbus.c
> index 05fc31c0..d8950454 100644
> --- a/console/xenbus.c
> +++ b/console/xenbus.c
> @@ -192,3 +192,115 @@ void fini_consfront(struct consfront_dev *dev)
>  {
>      if (dev) free_consfront(dev);
>  }
> +
> +#ifdef HAVE_LIBC
> +static int consfront_read(struct file *file, void *buf, size_t nbytes)
> +{
> +    int ret;
> +    DEFINE_WAIT(w);
> +
> +    while ( 1 )
> +    {
> +        add_waiter(w, console_queue);
> +        ret = xencons_ring_recv(file->dev, buf, nbytes);
> +        if ( ret )
> +            break;
> +        schedule();
> +    }
> +
> +    remove_waiter(w, console_queue);
> +
> +    return ret;
> +}
> +
> +static int savefile_write(struct file *file, const void *buf, size_t nbytes)
> +{
> +    int ret = 0, tot = nbytes;
> +
> +    while ( nbytes > 0 )
> +    {
> +        ret = xencons_ring_send(file->dev, buf, nbytes);
> +        nbytes -= ret;
> +        buf = (char *)buf + ret;
> +    }
> +
> +    return tot - nbytes;
> +}
> +
> +static int console_write(struct file *file, const void *buf, size_t nbytes)
> +{
> +    console_print(file->dev, buf, nbytes);
> +
> +    return nbytes;
> +}
> +
> +static int consfront_close_fd(struct file *file)
> +{
> +    fini_consfront(file->dev);
> +
> +    return 0;
> +}
> +
> +static int consfront_fstat(struct file *file, struct stat *buf)
> +{
> +    buf->st_mode = S_IRUSR | S_IWUSR;
> +    buf->st_mode |= (file->type == FTYPE_CONSOLE) ? S_IFCHR : S_IFREG;
> +    buf->st_atime = buf->st_mtime = buf->st_ctime = time(NULL);
> +
> +    return 0;
> +}
> +
> +static bool consfront_select_rd(struct file *file)
> +{
> +    return xencons_ring_avail(file->dev);
> +}
> +
> +static const struct file_ops savefile_ops = {
> +    .name = "savefile",
> +    .read = consfront_read,
> +    .write = savefile_write,
> +    .close = consfront_close_fd,
> +    .fstat = consfront_fstat,
> +    .select_rd = consfront_select_rd,
> +    .select_wr = select_yes,
> +};
> +
> +const struct file_ops console_ops = {
> +    .name = "console",
> +    .read = consfront_read,
> +    .write = console_write,
> +    .close = consfront_close_fd,
> +    .fstat = consfront_fstat,
> +    .select_rd = consfront_select_rd,
> +    .select_wr = select_yes,
> +};
> +
> +static unsigned int ftype_savefile;
> +
> +__attribute__((constructor))
> +static void consfront_initialize(void)
> +{
> +    ftype_savefile = alloc_file_type(&savefile_ops);
> +}
> +
> +int open_consfront(char *nodename)
> +{
> +    struct consfront_dev *dev;
> +    struct file *file;
> +
> +    dev = init_consfront(nodename);
> +    if ( !dev )
> +        return -1;
> +
> +    dev->fd = alloc_fd(nodename ? ftype_savefile : FTYPE_CONSOLE);
> +    file = get_file_from_fd(dev->fd);
> +    if ( !file )
> +    {
> +        fini_consfront(dev);
> +        return -1;
> +    }
> +    file->dev = dev;
> +
> +    return dev->fd;
> +}
> +#endif
> diff --git a/console/xencons_ring.c b/console/xencons_ring.c
> index c348f3ce..efedf46b 100644
> --- a/console/xencons_ring.c
> +++ b/console/xencons_ring.c
> @@ -99,10 +99,10 @@ void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data)
>  {
>  	struct consfront_dev *dev = (struct consfront_dev *) data;
>  #ifdef HAVE_LIBC
> -        int fd = dev ? dev->fd : -1;
> +        struct file *file = dev ? get_file_from_fd(dev->fd) : NULL;
>  
> -        if (fd != -1)
> -            files[fd].read = true;
> +        if ( file )
> +            file->read = true;
>  
>          wake_up(&console_queue);
>  #else
> diff --git a/include/console.h b/include/console.h
> index 0d7bf077..e76e4234 100644
> --- a/include/console.h
> +++ b/include/console.h
> @@ -39,6 +39,7 @@
>  #include <mini-os/os.h>
>  #include <mini-os/traps.h>
>  #include <mini-os/types.h>
> +#include <mini-os/lib.h>
>  #include <xen/grant_table.h>
>  #include <xenbus.h>
>  #include <xen/io/console.h>
> @@ -77,7 +78,7 @@ void xencons_tx(void);
>  
>  void get_console(void *p);
>  void init_console(void);
> -void console_print(struct consfront_dev *dev, char *data, int length);
> +void console_print(struct consfront_dev *dev, const char *data, int length);
>  void fini_consfront(struct consfront_dev *dev);
>  void suspend_console(void);
>  void resume_console(void);
> @@ -93,5 +94,9 @@ int xencons_ring_send_no_notify(struct consfront_dev *dev, const char *data, uns
>  int xencons_ring_avail(struct consfront_dev *dev);
>  int xencons_ring_recv(struct consfront_dev *dev, char *data, unsigned len);
>  void free_consfront(struct consfront_dev *dev);
> +#ifdef HAVE_LIBC
> +extern const struct file_ops console_ops;
> +int open_consfront(char *nodename);
> +#endif
>  
>  #endif /* _LIB_CONSOLE_H_ */
> diff --git a/include/lib.h b/include/lib.h
> index b1beeed3..e815e0a3 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -162,8 +162,7 @@ extern struct wait_queue_head event_queue;
>  #define FTYPE_FILE       2
>  #define FTYPE_SOCKET     3
>  #define FTYPE_MEM        4
> -#define FTYPE_SAVEFILE   5
> -#define FTYPE_N          6
> +#define FTYPE_N          5
>  #define FTYPE_SPARE     16
>  
>  struct file {
> diff --git a/lib/sys.c b/lib/sys.c
> index db26fd2d..74c82b2a 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -101,6 +101,9 @@ static const struct file_ops file_ops_none = {
>  
>  static const struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
>      [FTYPE_NONE] = &file_ops_none,
> +#ifdef CONFIG_CONSFRONT
> +    [FTYPE_CONSOLE] = &console_ops,
> +#endif
>  };
>  
>  unsigned int alloc_file_type(const struct file_ops *ops)
> @@ -212,31 +215,26 @@ int mkdir(const char *pathname, mode_t mode)
>  #ifdef CONFIG_CONSFRONT
>  int posix_openpt(int flags)
>  {
> -    struct consfront_dev *dev;
> +    int fd;
>  
>      /* Ignore flags */
> +    fd = open_consfront(NULL);
> +    printk("fd(%d) = posix_openpt\n", fd);
>  
> -    dev = init_consfront(NULL);
> -    dev->fd = alloc_fd(FTYPE_CONSOLE);
> -    files[dev->fd].dev = dev;
> -
> -    printk("fd(%d) = posix_openpt\n", dev->fd);
> -    return(dev->fd);
> +    return fd;
>  }
>  
>  int open_savefile(const char *path, int save)
>  {
> -    struct consfront_dev *dev;
> +    int fd;
>      char nodename[64];
>  
>      snprintf(nodename, sizeof(nodename), "device/console/%d", save ? SAVE_CONSOLE : RESTORE_CONSOLE);
>  
> -    dev = init_consfront(nodename);
> -    dev->fd = alloc_fd(FTYPE_SAVEFILE);
> -    files[dev->fd].dev = dev;
> +    fd = open_consfront(nodename);
> +    printk("fd(%d) = open_savefile\n", fd);
>  
> -    printk("fd(%d) = open_savefile\n", dev->fd);
> -    return(dev->fd);
> +    return fd;
>  }
>  #else
>  int posix_openpt(int flags)
> @@ -291,20 +289,6 @@ int read(int fd, void *buf, size_t nbytes)
>          return ops->read(file, buf, nbytes);
>  
>      switch (file->type) {
> -        case FTYPE_SAVEFILE:
> -	case FTYPE_CONSOLE: {
> -	    int ret;
> -            DEFINE_WAIT(w);
> -            while(1) {
> -                add_waiter(w, console_queue);
> -                ret = xencons_ring_recv(files[fd].dev, buf, nbytes);
> -                if (ret)
> -                    break;
> -                schedule();
> -            }
> -            remove_waiter(w, console_queue);
> -            return ret;
> -        }
>  #ifdef HAVE_LWIP
>          case FTYPE_SOCKET:
>  	    return lwip_read(files[fd].fd, buf, nbytes);
> @@ -332,18 +316,6 @@ int write(int fd, const void *buf, size_t nbytes)
>          return ops->write(file, buf, nbytes);
>  
>      switch (file->type) {
> -        case FTYPE_SAVEFILE: {
> -                int ret = 0, tot = nbytes;
> -                while (nbytes > 0) {
> -                    ret = xencons_ring_send(files[fd].dev, (char *)buf, nbytes);
> -                    nbytes -= ret;
> -                    buf = (char *)buf + ret;
> -                }
> -                return tot - nbytes;
> -            }
> -	case FTYPE_CONSOLE:
> -	    console_print(files[fd].dev, (char *)buf, nbytes);
> -	    return nbytes;
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
>  	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
> @@ -446,12 +418,6 @@ int close(int fd)
>  	case FTYPE_SOCKET:
>              res = lwip_close(files[fd].fd);
>              break;
> -#endif
> -#ifdef CONFIG_CONSFRONT
> -        case FTYPE_SAVEFILE:
> -        case FTYPE_CONSOLE:
> -            fini_consfront(files[fd].dev);
> -            break;
>  #endif
>  	case FTYPE_NONE:
>              goto error;
> @@ -501,15 +467,8 @@ int fstat(int fd, struct stat *buf)
>          return ops->fstat(file, buf);
>  
>      switch (file->type) {
> -	case FTYPE_SAVEFILE:
> -	case FTYPE_CONSOLE:
>  	case FTYPE_SOCKET: {
> -            if (files[fd].type == FTYPE_CONSOLE)
> -                buf->st_mode = S_IFCHR|S_IRUSR|S_IWUSR;
> -            else if (files[fd].type == FTYPE_SOCKET)
> -                buf->st_mode = S_IFSOCK|S_IRUSR|S_IWUSR;
> -            else if (files[fd].type == FTYPE_SAVEFILE)
> -                buf->st_mode = S_IFREG|S_IRUSR|S_IWUSR;
> +            buf->st_mode = S_IFSOCK|S_IRUSR|S_IWUSR;
>  	    buf->st_uid = 0;
>  	    buf->st_gid = 0;
>  	    buf->st_size = 0;
> @@ -630,7 +589,6 @@ int closedir(DIR *dir)
>  #if defined(LIBC_DEBUG) || defined(LIBC_VERBOSE)
>  static const char *const file_types[] = {
>      [FTYPE_NONE]    = "none",
> -    [FTYPE_CONSOLE] = "console",
>      [FTYPE_SOCKET]  = "socket",
>  };
>  
> @@ -799,21 +757,18 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>              }
>  
>  	    if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
> +            {
>  		printk("bogus fd %d in select\n", i);
> -	    /* Fallthrough.  */
> -        }
> -
> -	case FTYPE_CONSOLE:
> -	    if (FD_ISSET(i, readfds)) {
> -                if (xencons_ring_avail(files[i].dev))
> -		    n++;
> -		else
> -		    FD_CLR(i, readfds);
> +                if ( FD_ISSET(i, readfds) )
> +                    FD_CLR(i, readfds);
> +                if ( FD_ISSET(i, writefds) )
> +                    FD_CLR(i, writefds);
> +                if ( FD_ISSET(i, exceptfds) )
> +                    FD_CLR(i, exceptfds);
>              }
> -	    if (FD_ISSET(i, writefds))
> -                n++;
> -	    FD_CLR(i, exceptfds);
>  	    break;
> +        }
> +
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
>  	    if (FD_ISSET(i, readfds)) {
> -- 
> 2.26.2
> 

-- 
Samuel
<N> (* If you have a precise idea of the intended use of the following code, please
<N>    write to Eduardo.Gimenez@inria.fr and ask for the prize :-)
<N>    -- Eduardo (11/8/97) *)
 -+- N sur #ens-mim - et c'était un des développeurs -+-


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 21:03:01 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 21:03:01 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257985.443771 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9Cg1-0000c3-6n; Sun, 16 Jan 2022 21:03:01 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257985.443771; Sun, 16 Jan 2022 21:03:01 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9Cg1-0000bw-3U; Sun, 16 Jan 2022 21:03:01 +0000
Received: by outflank-mailman (input) for mailman id 257985;
 Sun, 16 Jan 2022 21:02:59 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9Cfz-0000bW-Eo
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 21:02:59 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [2a0c:e300::1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ad62e8af-770f-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 22:02:58 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 9B3499E;
 Sun, 16 Jan 2022 22:02:55 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id kWsA_aW_kQ2u; Sun, 16 Jan 2022 22:02:54 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 562A818A;
 Sun, 16 Jan 2022 22:02:54 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9Cft-005ugm-Mo;
 Sun, 16 Jan 2022 22:02:53 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ad62e8af-770f-11ec-9bbc-9dff3e4ee8c5
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 22:02:53 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 10/12] add struct file_ops for file type socket
Message-ID: <20220116210253.7yze4z7uqma4pk33@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-11-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220116083328.26524-11-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 9B3499E
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 09:33:26 +0100, a ecrit:
> Even with some special handling needed in select_poll(), add a struct
> file_ops for FTYPE_SOCKET. Due to the need of the special handling it
> isn't possible to use a dynamically allocated file type.
> 
> Most functions calling the file_ops methods can be simplified a lot now
> that no file type specific handling is left. Same applies to the file
> type name printing in debug/verbose mode.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
> V3:
> - switch to struct file * parameter for callbacks
> ---
>  lib/sys.c | 148 +++++++++++++++++++++++-------------------------------
>  1 file changed, 64 insertions(+), 84 deletions(-)
> 
> diff --git a/lib/sys.c b/lib/sys.c
> index 74c82b2a..538d6e7b 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -99,11 +99,67 @@ static const struct file_ops file_ops_none = {
>      .name = "none",
>  };
>  
> +#ifdef HAVE_LWIP
> +static int socket_read(struct file *file, void *buf, size_t nbytes)
> +{
> +    return lwip_read(file->fd, buf, nbytes);
> +}
> +
> +static int socket_write(struct file *file, const void *buf, size_t nbytes)
> +{
> +    return lwip_write(file->fd, buf, nbytes);
> +}
> +
> +static int close_socket_fd(struct file *file)
> +{
> +    return lwip_close(file->fd);
> +}
> +
> +static int socket_fstat(struct file *file, struct stat *buf)
> +{
> +    buf->st_mode = S_IFSOCK | S_IRUSR | S_IWUSR;
> +    buf->st_atime = buf->st_mtime = buf->st_ctime = time(NULL);
> +
> +    return 0;
> +}
> +
> +static int socket_fcntl(struct file *file, int cmd, va_list args)
> +{
> +    long arg;
> +
> +    arg = va_arg(args, long);
> +
> +    if ( cmd == F_SETFL && !(arg & ~O_NONBLOCK) )
> +    {
> +        /* Only flag supported: non-blocking mode */
> +        uint32_t nblock = !!(arg & O_NONBLOCK);
> +
> +        return lwip_ioctl(file->fd, FIONBIO, &nblock);
> +    }
> +
> +    printk("socket fcntl(fd, %d, %lx/%lo)\n", cmd, arg, arg);
> +    errno = ENOSYS;
> +    return -1;
> +}
> +
> +static const struct file_ops socket_ops = {
> +    .name = "socket",
> +    .read = socket_read,
> +    .write = socket_write,
> +    .close = close_socket_fd,
> +    .fstat = socket_fstat,
> +    .fcntl = socket_fcntl,
> +};
> +#endif
> +
>  static const struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = {
>      [FTYPE_NONE] = &file_ops_none,
>  #ifdef CONFIG_CONSFRONT
>      [FTYPE_CONSOLE] = &console_ops,
>  #endif
> +#ifdef HAVE_LWIP
> +    [FTYPE_SOCKET] = &socket_ops,
> +#endif
>  };
>  
>  unsigned int alloc_file_type(const struct file_ops *ops)
> @@ -288,15 +344,6 @@ int read(int fd, void *buf, size_t nbytes)
>      if ( ops->read )
>          return ops->read(file, buf, nbytes);
>  
> -    switch (file->type) {
> -#ifdef HAVE_LWIP
> -        case FTYPE_SOCKET:
> -	    return lwip_read(files[fd].fd, buf, nbytes);
> -#endif
> -	default:
> -	    break;
> -    }
> -
>   error:
>      printk("read(%d): Bad descriptor\n", fd);
>      errno = EBADF;
> @@ -315,15 +362,6 @@ int write(int fd, const void *buf, size_t nbytes)
>      if ( ops->write )
>          return ops->write(file, buf, nbytes);
>  
> -    switch (file->type) {
> -#ifdef HAVE_LWIP
> -	case FTYPE_SOCKET:
> -	    return lwip_write(files[fd].fd, (void*) buf, nbytes);
> -#endif
> -	default:
> -	    break;
> -    }
> -
>   error:
>      printk("write(%d): Bad descriptor\n", fd);
>      errno = EBADF;
> @@ -406,24 +444,10 @@ int close(int fd)
>      ops = get_file_ops(file->type);
>      printk("close(%d)\n", fd);
>      if ( ops->close )
> -    {
>          res = ops->close(file);
> -        goto out;
> -    }
> -
> -    switch (file->type) {
> -        default:
> -            break;
> -#ifdef HAVE_LWIP
> -	case FTYPE_SOCKET:
> -            res = lwip_close(files[fd].fd);
> -            break;
> -#endif
> -	case FTYPE_NONE:
> -            goto error;
> -    }
> +    else if ( file->type == FTYPE_NONE )
> +        goto error;
>  
> - out:
>      memset(files + fd, 0, sizeof(struct file));
>      BUILD_BUG_ON(FTYPE_NONE != 0);
>  
> @@ -466,21 +490,6 @@ int fstat(int fd, struct stat *buf)
>      if ( ops->fstat )
>          return ops->fstat(file, buf);
>  
> -    switch (file->type) {
> -	case FTYPE_SOCKET: {
> -            buf->st_mode = S_IFSOCK|S_IRUSR|S_IWUSR;
> -	    buf->st_uid = 0;
> -	    buf->st_gid = 0;
> -	    buf->st_size = 0;
> -	    buf->st_atime = 
> -	    buf->st_mtime = 
> -	    buf->st_ctime = time(NULL);
> -	    return 0;
> -	}
> -	default:
> -	    break;
> -    }
> -
>   error:
>      printk("statf(%d): Bad descriptor\n", fd);
>      errno = EBADF;
> @@ -538,21 +547,9 @@ int fcntl(int fd, int cmd, ...)
>      arg = va_arg(ap, long);
>      va_end(ap);
>  
> -    switch (cmd) {
> -#ifdef HAVE_LWIP
> -	case F_SETFL:
> -	    if (files[fd].type == FTYPE_SOCKET && !(arg & ~O_NONBLOCK)) {
> -		/* Only flag supported: non-blocking mode */
> -		uint32_t nblock = !!(arg & O_NONBLOCK);
> -		return lwip_ioctl(files[fd].fd, FIONBIO, &nblock);
> -	    }
> -	    /* Fallthrough */
> -#endif
> -	default:
> -	    printk("fcntl(%d, %d, %lx/%lo)\n", fd, cmd, arg, arg);
> -	    errno = ENOSYS;
> -	    return -1;
> -    }
> +    printk("fcntl(%d, %d, %lx/%lo)\n", fd, cmd, arg, arg);
> +    errno = ENOSYS;
> +    return -1;
>  }
>  
>  DIR *opendir(const char *name)
> @@ -586,23 +583,6 @@ int closedir(DIR *dir)
>  
>  /* We assume that only the main thread calls select(). */
>  
> -#if defined(LIBC_DEBUG) || defined(LIBC_VERBOSE)
> -static const char *const file_types[] = {
> -    [FTYPE_NONE]    = "none",
> -    [FTYPE_SOCKET]  = "socket",
> -};
> -
> -static const char *get_type_name(unsigned int type)
> -{
> -    if ( type < ARRAY_SIZE(file_ops) && file_ops[type] )
> -        return file_ops[type]->name;
> -
> -    if ( type < ARRAY_SIZE(file_types) && file_types[type] )
> -        return file_types[type];
> -
> -    return "none";
> -}
> -#endif
>  #ifdef LIBC_DEBUG
>  static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
>  {
> @@ -613,7 +593,7 @@ static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *except
>  	if (FD_ISSET(i, set)) { \
>  	    if (comma) \
>  		printk(", "); \
> -            printk("%d(%s)", i, get_type_name(files[i].type)); \
> +            printk("%d(%s)", i, get_file_ops(files[i].type)->name); \
>  	    comma = 1; \
>  	} \
>      } \
> @@ -647,7 +627,7 @@ static void dump_pollfds(struct pollfd *pfd, int nfds, int timeout)
>          fd = pfd[i].fd;
>          if (comma)
>              printk(", ");
> -        printk("%d(%s)/%02x", fd, get_type_name(files[fd].type),
> +        printk("%d(%s)/%02x", fd, get_file_ops(files[fd].type)->name,
>              pfd[i].events);
>              comma = 1;
>      }
> @@ -809,7 +789,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  	printk("%d(%d): ", nb, sock_n);
>  	for (i = 0; i < nfds; i++) {
>  	    if (nbread[i] || nbwrite[i] || nbexcept[i])
> -                printk(" %d(%c):", i, get_type_name(files[i].type));
> +                printk(" %d(%c):", i, get_file_ops(files[i].type)->name);
>  	    if (nbread[i])
>  	    	printk(" %dR", nbread[i]);
>  	    if (nbwrite[i])
> -- 
> 2.26.2
> 

-- 
Samuel
*** s has joined channel #ens-mim
<N> re 
<s> pfff 
<s> mare de la pfp. 
<s> pas commencer et j'en ai deja marre. 
<s> bon ct juste un cou de gueule ++ 
*** s has left channel #ens-mim (s)
 -+- #ens-mim et la peufeupeu -+-


From minios-devel-bounces@lists.xenproject.org Sun Jan 16 21:03:12 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 16 Jan 2022 21:03:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.257988.443787 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CgC-000139-Kp; Sun, 16 Jan 2022 21:03:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 257988.443787; Sun, 16 Jan 2022 21:03:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9CgC-00012x-HB; Sun, 16 Jan 2022 21:03:12 +0000
Received: by outflank-mailman (input) for mailman id 257988;
 Sun, 16 Jan 2022 21:03:11 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=g2po=SA=ens-lyon.org=samuel.thibault@srs-se1.protection.inumbo.net>)
 id 1n9CgB-0000bW-Lm
 for minios-devel@lists.xenproject.org; Sun, 16 Jan 2022 21:03:11 +0000
Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id b639847d-770f-11ec-9bbc-9dff3e4ee8c5;
 Sun, 16 Jan 2022 22:03:11 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 876E318A;
 Sun, 16 Jan 2022 22:03:10 +0100 (CET)
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id wpgL5lKz2DMv; Sun, 16 Jan 2022 22:03:09 +0100 (CET)
Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 8E3939E;
 Sun, 16 Jan 2022 22:03:09 +0100 (CET)
Received: from samy by begin with local (Exim 4.95)
 (envelope-from <samuel.thibault@ens-lyon.org>) id 1n9Cg9-005uh2-5z;
 Sun, 16 Jan 2022 22:03:09 +0100
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: b639847d-770f-11ec-9bbc-9dff3e4ee8c5
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Date: Sun, 16 Jan 2022 22:03:09 +0100
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	wl@xen.org
Subject: Re: [MINIOS PATCH v3 00/12] remove device specific struct file
 members
Message-ID: <20220116210309.ye2w3uemapabcnq4@begin>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20220116083328.26524-1-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 876E318A
X-Spamd-Result: default: False [0.40 / 15.00];
	 ARC_NA(0.00)[];
	 RCVD_VIA_SMTP_AUTH(0.00)[];
	 FROM_HAS_DN(0.00)[];
	 RCPT_COUNT_THREE(0.00)[4];
	 TO_DN_SOME(0.00)[];
	 TO_MATCH_ENVRCPT_ALL(0.00)[];
	 MIME_GOOD(-0.10)[text/plain];
	 HAS_ORG_HEADER(0.00)[];
	 RCVD_COUNT_THREE(0.00)[3];
	 FROM_EQ_ENVFROM(0.00)[];
	 MIME_TRACE(0.00)[0:+];
	 RCVD_TLS_LAST(0.00)[];
	 MID_RHS_NOT_FQDN(0.50)[]

Juergen Gross, le dim. 16 janv. 2022 09:33:16 +0100, a ecrit:
> This series is a followup to the series sent recently:
> 
> https://lists.xen.org/archives/html/xen-devel/2022-01/threads.html#00635
> 
> It contains the last cleanups related to struct file and can only be
> applied after the Xen libraries have stopped using the related union
> members:
> 
> https://lists.xen.org/archives/html/xen-devel/2022-01/threads.html#00643
> 
> The three series applied have been tested to work with:
> 
> - xenstorepvh-stubdom
> - pv-grub
> - ioemu-stubdom

Thanks!

Samuel


From minios-devel-bounces@lists.xenproject.org Tue Jan 18 14:29:14 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 18 Jan 2022 14:29:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.258559.445415 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9pTy-0004z5-RE; Tue, 18 Jan 2022 14:29:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 258559.445415; Tue, 18 Jan 2022 14:29:10 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9pTy-0004yy-OH; Tue, 18 Jan 2022 14:29:10 +0000
Received: by outflank-mailman (input) for mailman id 258559;
 Tue, 18 Jan 2022 14:29:09 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=1rGk=SC=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n9pTx-0004yn-86
 for minios-devel@lists.xenproject.org; Tue, 18 Jan 2022 14:29:09 +0000
Received: from ppsw-42.csi.cam.ac.uk (ppsw-42.csi.cam.ac.uk [131.111.8.142])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id fe802bc6-786a-11ec-a115-11989b9578b4;
 Tue, 18 Jan 2022 15:29:08 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:48430)
 by ppsw-42.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.138]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n9pTv-0002td-6X (Exim 4.95) (return-path <amc96@srcf.net>);
 Tue, 18 Jan 2022 14:29:07 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id CCE4F1FC87;
 Tue, 18 Jan 2022 14:29:06 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fe802bc6-786a-11ec-a115-11989b9578b4
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <44a8d75f-718c-ce72-4b5e-cd67df6087be@srcf.net>
Date: Tue, 18 Jan 2022 14:29:06 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.5.0
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-4-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
Subject: Re: [MINIOS PATCH v3 03/12] use alloc_file_type() and
 get_file_from_fd() in xs
In-Reply-To: <20220116083328.26524-4-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 16/01/2022 08:33, Juergen Gross wrote:
> diff --git a/lib/xs.c b/lib/xs.c
> index 4af0f960..c12341aa 100644
> --- a/lib/xs.c
> +++ b/lib/xs.c
> @@ -18,23 +18,56 @@ static inline int _xs_fileno(struct xs_handle *h) {
>      return (intptr_t) h;
>  }
>  
> +static int xs_close_fd(struct file *file)
> +{
> +    struct xenbus_event *event, *next;
> +
> +    for (event = file->dev; event; event = next)
> +    {
> +        next = event->next;
> +        free(event);
> +    }
> +
> +    return 0;
> +}
> +
> +static bool xs_can_read(struct file *file)
> +{
> +    return file && file->dev;

Just 'return file->dev;' ?

> @@ -169,18 +202,20 @@ char **xs_directory(struct xs_handle *h, xs_transaction_t t,
>  
>  bool xs_watch(struct xs_handle *h, const char *path, const char *token)
>  {
> -    int fd = _xs_fileno(h);
> +    struct file *file = get_file_from_fd(_xs_fileno(h));
> +
>      printk("xs_watch(%s, %s)\n", path, token);
>      return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token,
> -                   (xenbus_event_queue *)&files[fd].dev));
> +                   (xenbus_event_queue *)&file->dev));

This is utterly mad.  In particular, close() looks to be very racy with
new watches arriving.

However, can the indentation at least be fixed here as the line is
changing.  That's a parameter to xenbus_watch_path_token(), not xs_bool().

> diff --git a/xenbus/xenbus.c b/xenbus/xenbus.c
> index b687678f..785389fb 100644
> --- a/xenbus/xenbus.c
> +++ b/xenbus/xenbus.c
> @@ -393,6 +393,7 @@ static int allocate_xenbus_id(void)
>  void init_xenbus(void)
>  {
>      int err;
> +

Spurious hunk?

~Andrew


From minios-devel-bounces@lists.xenproject.org Tue Jan 18 14:32:12 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 18 Jan 2022 14:32:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.258564.445441 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9pWu-0006ga-Gw; Tue, 18 Jan 2022 14:32:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 258564.445441; Tue, 18 Jan 2022 14:32:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9pWu-0006gT-Dn; Tue, 18 Jan 2022 14:32:12 +0000
Received: by outflank-mailman (input) for mailman id 258564;
 Tue, 18 Jan 2022 14:32:10 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=1rGk=SC=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n9pWs-0006Qe-Ff
 for minios-devel@lists.xenproject.org; Tue, 18 Jan 2022 14:32:10 +0000
Received: from ppsw-32.csi.cam.ac.uk (ppsw-32.csi.cam.ac.uk [131.111.8.132])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 695fd4dd-786b-11ec-9bbc-9dff3e4ee8c5;
 Tue, 18 Jan 2022 15:32:08 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:49506)
 by ppsw-32.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.136]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n9pWo-000xQR-1A (Exim 4.95) (return-path <amc96@srcf.net>);
 Tue, 18 Jan 2022 14:32:06 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id 1DD101FA12;
 Tue, 18 Jan 2022 14:32:06 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 695fd4dd-786b-11ec-9bbc-9dff3e4ee8c5
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <fe8f11f6-fdcf-f99f-4767-8248c6f0c2cf@srcf.net>
Date: Tue, 18 Jan 2022 14:32:05 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.5.0
Subject: Re: [MINIOS PATCH v3 04/12] use alloc_file_type() and
 get_file_from_fd() in tpm_tis
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-5-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <20220116083328.26524-5-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

On 16/01/2022 08:33, Juergen Gross wrote:
> diff --git a/tpm_tis.c b/tpm_tis.c
> index 477f5550..b88ec874 100644
> --- a/tpm_tis.c
> +++ b/tpm_tis.c
> @@ -1093,6 +1097,26 @@ ssize_t tpm_getcap(struct tpm_chip *chip, uint32_t subcap_id, cap_t *cap,
>          return rc;
>  }
>  
> +static void shutdown_tpm_tis(struct tpm_chip *tpm)
> +{
> +    int i;
> +
> +    printk("Shutting down tpm_tis device\n");
> +
> +    iowrite32(TPM_INT_ENABLE(tpm, tpm->locality), ~TPM_GLOBAL_INT_ENABLE);
> +
> +    /* Unmap all of the mmio pages */
> +    for ( i = 0; i < 5; ++i )
> +    {
> +        if ( tpm->pages[i] != NULL )
> +        {
> +            iounmap(tpm->pages[i], PAGE_SIZE);
> +            tpm->pages[i] = NULL;
> +        }
> +    }
> +    free(tpm);
> +    return;

Seeing as the function is moving anyway, this spurious return can go too.

~Andrew


From minios-devel-bounces@lists.xenproject.org Tue Jan 18 14:41:08 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 18 Jan 2022 14:41:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.258570.445457 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9pfV-00005V-Gb; Tue, 18 Jan 2022 14:41:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 258570.445457; Tue, 18 Jan 2022 14:41:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9pfV-00005O-CE; Tue, 18 Jan 2022 14:41:05 +0000
Received: by outflank-mailman (input) for mailman id 258570;
 Tue, 18 Jan 2022 14:41:04 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=1rGk=SC=srcf.net=amc96@srs-se1.protection.inumbo.net>)
 id 1n9pfU-00005D-3e
 for minios-devel@lists.xenproject.org; Tue, 18 Jan 2022 14:41:04 +0000
Received: from ppsw-43.csi.cam.ac.uk (ppsw-43.csi.cam.ac.uk [131.111.8.143])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id a8804c08-786c-11ec-9bbc-9dff3e4ee8c5;
 Tue, 18 Jan 2022 15:41:02 +0100 (CET)
Received: from hades.srcf.societies.cam.ac.uk ([131.111.179.67]:52128)
 by ppsw-43.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.139]:25)
 with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 id 1n9pfR-000UDf-p2 (Exim 4.95) (return-path <amc96@srcf.net>);
 Tue, 18 Jan 2022 14:41:01 +0000
Received: from [192.168.1.10] (host-92-12-61-86.as13285.net [92.12.61.86])
 (Authenticated sender: amc96)
 by hades.srcf.societies.cam.ac.uk (Postfix) with ESMTPSA id A48A21FC61;
 Tue, 18 Jan 2022 14:41:01 +0000 (GMT)
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: a8804c08-786c-11ec-9bbc-9dff3e4ee8c5
X-Cam-AntiVirus: no malware found
X-Cam-ScannerInfo: https://help.uis.cam.ac.uk/email-scanner-virus
Message-ID: <5dda5d9b-3488-04d2-0692-9ee12ae26ec7@srcf.net>
Date: Tue, 18 Jan 2022 14:41:01 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.5.0
Subject: Re: [MINIOS PATCH v3 06/12] use alloc_file_type() and
 get_file_from_fd() in blkfront
Content-Language: en-GB
To: Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-7-jgross@suse.com>
From: Andrew Cooper <amc96@srcf.net>
In-Reply-To: <20220116083328.26524-7-jgross@suse.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On 16/01/2022 08:33, Juergen Gross wrote:
> diff --git a/blkfront.c b/blkfront.c
> index e3f42bef..ed902702 100644
> --- a/blkfront.c
> +++ b/blkfront.c
> @@ -483,9 +483,13 @@ int blkfront_aio_poll(struct blkfront_dev *dev)
>  
>  moretodo:
>  #ifdef HAVE_LIBC
> -    if (dev->fd != -1) {
> -        files[dev->fd].read = false;
> -        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
> +    {
> +        struct file *file = get_file_from_fd(dev->fd);
> +
> +        if ( file ) {

Style, as this is is being indented.

> +            file->read = false;
> +            mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */

MiniOS is in desperate need of being dragged over to LKMM, and to stop
using inappropriate fences.  Things will go much faster when these have
all been corrected to smp barriers.

~Andrew


From minios-devel-bounces@lists.xenproject.org Tue Jan 18 14:54:01 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 18 Jan 2022 14:54:01 +0000
Received: from list by lists.xenproject.org with outflank-mailman.258583.445489 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9ps0-0002OR-El; Tue, 18 Jan 2022 14:54:00 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 258583.445489; Tue, 18 Jan 2022 14:54:00 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9ps0-0002O7-AY; Tue, 18 Jan 2022 14:54:00 +0000
Received: by outflank-mailman (input) for mailman id 258583;
 Tue, 18 Jan 2022 14:53:59 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=tdM9=SC=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n9pry-0002LL-Se
 for minios-devel@lists.xenproject.org; Tue, 18 Jan 2022 14:53:59 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 762b625f-786e-11ec-a115-11989b9578b4;
 Tue, 18 Jan 2022 15:53:56 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 5B877212BB;
 Tue, 18 Jan 2022 14:53:56 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2F49E13AC3;
 Tue, 18 Jan 2022 14:53:56 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id vS0BCoTU5mEwTgAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 18 Jan 2022 14:53:56 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 762b625f-786e-11ec-a115-11989b9578b4
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642517636; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=CAhh4ZMU+oM8Y33MkhKncq4h5rdl6IAEpDySUqphsbM=;
	b=uInbOgJvHLdXCiMBsirG6n27Xzng9VGSdER6OocI+49rqWaiD4mpbLidNhsnBSPCK05lwu
	/rFW4dvTkb5zMhX8EGtD6DTAhWdRsVZR9vnj0zzWAyCepK412KCa6C/wloSSmYaMUFnIR9
	Gs0a7OYI2Cxsf3XHkzuOEiLpEwvr4YI=
Message-ID: <919fd8ba-40f5-11e4-e0f2-cb48fe29136c@suse.com>
Date: Tue, 18 Jan 2022 15:53:55 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.1
Subject: Re: [MINIOS PATCH v3 03/12] use alloc_file_type() and
 get_file_from_fd() in xs
Content-Language: en-US
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-4-jgross@suse.com>
 <44a8d75f-718c-ce72-4b5e-cd67df6087be@srcf.net>
From: Juergen Gross <jgross@suse.com>
In-Reply-To: <44a8d75f-718c-ce72-4b5e-cd67df6087be@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="------------yqXgzFfgQBlIPCz66Gny16Le"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--------------yqXgzFfgQBlIPCz66Gny16Le
Content-Type: multipart/mixed; boundary="------------QbVBSHwhpK0DNosr701TSjzS";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <919fd8ba-40f5-11e4-e0f2-cb48fe29136c@suse.com>
Subject: Re: [MINIOS PATCH v3 03/12] use alloc_file_type() and
 get_file_from_fd() in xs
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-4-jgross@suse.com>
 <44a8d75f-718c-ce72-4b5e-cd67df6087be@srcf.net>
In-Reply-To: <44a8d75f-718c-ce72-4b5e-cd67df6087be@srcf.net>

--------------QbVBSHwhpK0DNosr701TSjzS
Content-Type: multipart/mixed; boundary="------------fZRF4F45JwJoJR7GGdKXfzaA"

--------------fZRF4F45JwJoJR7GGdKXfzaA
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: base64

T24gMTguMDEuMjIgMTU6MjksIEFuZHJldyBDb29wZXIgd3JvdGU6DQo+IE9uIDE2LzAxLzIw
MjIgMDg6MzMsIEp1ZXJnZW4gR3Jvc3Mgd3JvdGU6DQo+PiBkaWZmIC0tZ2l0IGEvbGliL3hz
LmMgYi9saWIveHMuYw0KPj4gaW5kZXggNGFmMGY5NjAuLmMxMjM0MWFhIDEwMDY0NA0KPj4g
LS0tIGEvbGliL3hzLmMNCj4+ICsrKyBiL2xpYi94cy5jDQo+PiBAQCAtMTgsMjMgKzE4LDU2
IEBAIHN0YXRpYyBpbmxpbmUgaW50IF94c19maWxlbm8oc3RydWN0IHhzX2hhbmRsZSAqaCkg
ew0KPj4gICAgICAgcmV0dXJuIChpbnRwdHJfdCkgaDsNCj4+ICAgfQ0KPj4gICANCj4+ICtz
dGF0aWMgaW50IHhzX2Nsb3NlX2ZkKHN0cnVjdCBmaWxlICpmaWxlKQ0KPj4gK3sNCj4+ICsg
ICAgc3RydWN0IHhlbmJ1c19ldmVudCAqZXZlbnQsICpuZXh0Ow0KPj4gKw0KPj4gKyAgICBm
b3IgKGV2ZW50ID0gZmlsZS0+ZGV2OyBldmVudDsgZXZlbnQgPSBuZXh0KQ0KPj4gKyAgICB7
DQo+PiArICAgICAgICBuZXh0ID0gZXZlbnQtPm5leHQ7DQo+PiArICAgICAgICBmcmVlKGV2
ZW50KTsNCj4+ICsgICAgfQ0KPj4gKw0KPj4gKyAgICByZXR1cm4gMDsNCj4+ICt9DQo+PiAr
DQo+PiArc3RhdGljIGJvb2wgeHNfY2FuX3JlYWQoc3RydWN0IGZpbGUgKmZpbGUpDQo+PiAr
ew0KPj4gKyAgICByZXR1cm4gZmlsZSAmJiBmaWxlLT5kZXY7DQo+IA0KPiBKdXN0ICdyZXR1
cm4gZmlsZS0+ZGV2OycgPw0KDQpZZXMuDQoNCj4gDQo+PiBAQCAtMTY5LDE4ICsyMDIsMjAg
QEAgY2hhciAqKnhzX2RpcmVjdG9yeShzdHJ1Y3QgeHNfaGFuZGxlICpoLCB4c190cmFuc2Fj
dGlvbl90IHQsDQo+PiAgIA0KPj4gICBib29sIHhzX3dhdGNoKHN0cnVjdCB4c19oYW5kbGUg
KmgsIGNvbnN0IGNoYXIgKnBhdGgsIGNvbnN0IGNoYXIgKnRva2VuKQ0KPj4gICB7DQo+PiAt
ICAgIGludCBmZCA9IF94c19maWxlbm8oaCk7DQo+PiArICAgIHN0cnVjdCBmaWxlICpmaWxl
ID0gZ2V0X2ZpbGVfZnJvbV9mZChfeHNfZmlsZW5vKGgpKTsNCj4+ICsNCj4+ICAgICAgIHBy
aW50aygieHNfd2F0Y2goJXMsICVzKVxuIiwgcGF0aCwgdG9rZW4pOw0KPj4gICAgICAgcmV0
dXJuIHhzX2Jvb2woeGVuYnVzX3dhdGNoX3BhdGhfdG9rZW4oWEJUX05VTEwsIHBhdGgsIHRv
a2VuLA0KPj4gLSAgICAgICAgICAgICAgICAgICAoeGVuYnVzX2V2ZW50X3F1ZXVlICopJmZp
bGVzW2ZkXS5kZXYpKTsNCj4+ICsgICAgICAgICAgICAgICAgICAgKHhlbmJ1c19ldmVudF9x
dWV1ZSAqKSZmaWxlLT5kZXYpKTsNCj4gDQo+IFRoaXMgaXMgdXR0ZXJseSBtYWQuwqAgSW4g
cGFydGljdWxhciwgY2xvc2UoKSBsb29rcyB0byBiZSB2ZXJ5IHJhY3kgd2l0aA0KPiBuZXcg
d2F0Y2hlcyBhcnJpdmluZy4NCg0KSW4gcHJhY3RpY2UgaXQgc2hvdWxkIGJlIG5vIHByb2Js
ZW0sIHRob3VnaCAoY2xvc2luZyB0aGUgZmlsZSBpbiBvbmUNCnRocmVhZCB3aGlsZSB0aGUg
b3RoZXIgb25lIGlzIGFkZGluZyBhIHdhdGNoIHdvdWxkIGJlIHJhdGhlciBzdHJhbmdlKS4N
Cg0KQWRkaXRpb25hbGx5IGNsb3NlKCkgZm9yIHhlbmJ1cyBpbiBNaW5pLU9TIGlzIGNhbGxl
ZCBvbmx5IHdoZW4gc3RvcHBpbmcNCnRoZSBkb21haW4gdG9kYXkuDQoNCj4gSG93ZXZlciwg
Y2FuIHRoZSBpbmRlbnRhdGlvbiBhdCBsZWFzdCBiZSBmaXhlZCBoZXJlIGFzIHRoZSBsaW5l
IGlzDQo+IGNoYW5naW5nLsKgIFRoYXQncyBhIHBhcmFtZXRlciB0byB4ZW5idXNfd2F0Y2hf
cGF0aF90b2tlbigpLCBub3QgeHNfYm9vbCgpLg0KDQpZZXMsIHRoYXQgc2hvdWxkIGJlIGRv
bmUuDQoNCj4gDQo+PiBkaWZmIC0tZ2l0IGEveGVuYnVzL3hlbmJ1cy5jIGIveGVuYnVzL3hl
bmJ1cy5jDQo+PiBpbmRleCBiNjg3Njc4Zi4uNzg1Mzg5ZmIgMTAwNjQ0DQo+PiAtLS0gYS94
ZW5idXMveGVuYnVzLmMNCj4+ICsrKyBiL3hlbmJ1cy94ZW5idXMuYw0KPj4gQEAgLTM5Myw2
ICszOTMsNyBAQCBzdGF0aWMgaW50IGFsbG9jYXRlX3hlbmJ1c19pZCh2b2lkKQ0KPj4gICB2
b2lkIGluaXRfeGVuYnVzKHZvaWQpDQo+PiAgIHsNCj4+ICAgICAgIGludCBlcnI7DQo+PiAr
DQo+IA0KPiBTcHVyaW91cyBodW5rPw0KDQpZZXMuDQoNCg0KSnVlcmdlbg0K
--------------fZRF4F45JwJoJR7GGdKXfzaA
Content-Type: application/pgp-keys; name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Disposition: attachment; filename="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Description: OpenPGP public key
Content-Transfer-Encoding: quoted-printable

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjri
oyspZKOBycWxw3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2
kaV2KL9650I1SJvedYm8Of8Zd621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i
1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y9bfIhWUiVXEK7MlRgUG6MvIj6Y3Am/B
BLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xqG7/377qptDmrk42GlSK
N4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR3Jvc3Mg
PGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsE
FgIDAQIeAQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4F
UGNQH2lvWAUy+dnyThpwdtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3Tye
vpB0CA3dbBQp0OW0fgCetToGIQrg0MbD1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u
+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbvoPHZ8SlM4KWm8rG+lIkGurq
qu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v5QL+qHI3EIP
tyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVy
Z2VuIEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJ
CAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4
RF7HoZhPVPogNVbC4YA6lW7DrWf0teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz7
8X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC/nuAFVGy+67q2DH8As3KPu0344T
BDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0LhITTd9jLzdDad1pQ
SToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLmXBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkM
nQfvUewRz80hSnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMB
AgAjBQJTjHDXAhsDBwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/
Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJnFOXgMLdBQgBlVPO3/D9R8LtF9DBAFPN
hlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1jnDkfJZr6jrbjgyoZHi
w/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0N51N5Jf
VRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwP
OoE+lotufe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK
/1xMI3/+8jbO0tsn1tqSEUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1
c2UuZGU+wsB5BBMBAgAjBQJTjHDrAhsDBwsJCAcDAgEGFQgCCQoLBBYCAwECHgEC
F4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3g3OZUEBmDHVVbqMtzwlmNC4
k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5dM7wRqzgJpJ
wK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu
5D+jLRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzB
TNh30FVKK1EvmV2xAKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37Io
N1EblHI//x/e2AaIHpzK5h88NEawQsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6
AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpWnHIs98ndPUDpnoxWQugJ6MpMncr
0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZRwgnBC5mVM6JjQ5x
Dk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNVbVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mm
we0icXKLkpEdIXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0I
v3OOImwTEe4co3c1mwARAQABwsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMv
Q/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEwTbe8YFsw2V/Buv6Z4Mysln3nQK5ZadD
534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1vJzQ1fOU8lYFpZXTXIH
b+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8VGiwXvT
yJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqc
suylWsviuGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5B
jR/i1DG86lem3iBDXzXsZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------fZRF4F45JwJoJR7GGdKXfzaA--

--------------QbVBSHwhpK0DNosr701TSjzS--

--------------yqXgzFfgQBlIPCz66Gny16Le
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHm1IMFAwAAAAAACgkQsN6d1ii/Ey8k
CQf9FsCXFo47IY8bBPFR9XlpCHae3WH6DWTTzvZ9E4ZNWXtu5LHMze0TRGF5DYpcGirkGlwia00E
VkBICoWb02RIg4QkBYqblST5ij3Ity8/0eVcpwyFal55IkOXG3pk6LFtrHaXXLK4gWYPXvPiuZBy
lTZw6PqEZASvy7FoacM+Kn7tYDv4wGlfTeWWIqCALqrKzW1NKwInAU0M4h+EwxVnbkCdN03JCvWf
4OdntoEktgFPJzzCXAcXULmp9VYQS4HW6pmj65y5ZBFJTFHwhNokTM35JSgBeBZzHB5caQaOHJ6C
V5TsIpxj1oepHPq1WTxu82l1IyC6uBC7AT+HONam6A==
=ONXC
-----END PGP SIGNATURE-----

--------------yqXgzFfgQBlIPCz66Gny16Le--


From minios-devel-bounces@lists.xenproject.org Tue Jan 18 14:54:33 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 18 Jan 2022 14:54:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.258586.445500 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9psX-0002u7-Gb; Tue, 18 Jan 2022 14:54:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 258586.445500; Tue, 18 Jan 2022 14:54:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9psX-0002tz-DA; Tue, 18 Jan 2022 14:54:33 +0000
Received: by outflank-mailman (input) for mailman id 258586;
 Tue, 18 Jan 2022 14:54:32 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=tdM9=SC=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n9psW-0002j7-N4
 for minios-devel@lists.xenproject.org; Tue, 18 Jan 2022 14:54:32 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 8b221ab9-786e-11ec-9bbc-9dff3e4ee8c5;
 Tue, 18 Jan 2022 15:54:31 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id AECD6218A9;
 Tue, 18 Jan 2022 14:54:31 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 85A8B13AC3;
 Tue, 18 Jan 2022 14:54:31 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id q41tH6fU5mGSTgAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 18 Jan 2022 14:54:31 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 8b221ab9-786e-11ec-9bbc-9dff3e4ee8c5
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642517671; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=DkqqooiueTSRrpomD9t4NXqh0JZYEpWP21NNPgurwUs=;
	b=e44Z/zgurXoTc9BpiV6oVxkLyrC9HgmMQ2IWLuFuZ5NylFiBm0Qd1pKx4jlm5b6fgX4o6k
	kk6gSXOVaaLqSE6H8FkMSEIbuRy/rLhmvbnzhM9YT7sWDqE+XyKt+AUMjZpzFJSiz8fa6/
	66me5ff4bkJnhNGoubnJ8hQBLmfFFL8=
Message-ID: <7eb2b1da-310c-009e-e06c-fb10d950e517@suse.com>
Date: Tue, 18 Jan 2022 15:54:31 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.1
Subject: Re: [MINIOS PATCH v3 04/12] use alloc_file_type() and
 get_file_from_fd() in tpm_tis
Content-Language: en-US
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-5-jgross@suse.com>
 <fe8f11f6-fdcf-f99f-4767-8248c6f0c2cf@srcf.net>
From: Juergen Gross <jgross@suse.com>
In-Reply-To: <fe8f11f6-fdcf-f99f-4767-8248c6f0c2cf@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="------------JmznQ2LzEbK0m5IKJmzCqAK6"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--------------JmznQ2LzEbK0m5IKJmzCqAK6
Content-Type: multipart/mixed; boundary="------------ZCqPjPVfbqxtsYwd02it6Tjf";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <7eb2b1da-310c-009e-e06c-fb10d950e517@suse.com>
Subject: Re: [MINIOS PATCH v3 04/12] use alloc_file_type() and
 get_file_from_fd() in tpm_tis
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-5-jgross@suse.com>
 <fe8f11f6-fdcf-f99f-4767-8248c6f0c2cf@srcf.net>
In-Reply-To: <fe8f11f6-fdcf-f99f-4767-8248c6f0c2cf@srcf.net>

--------------ZCqPjPVfbqxtsYwd02it6Tjf
Content-Type: multipart/mixed; boundary="------------hkhEPsBsvqqIYS9Boh2Co5X8"

--------------hkhEPsBsvqqIYS9Boh2Co5X8
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: base64

T24gMTguMDEuMjIgMTU6MzIsIEFuZHJldyBDb29wZXIgd3JvdGU6DQo+IE9uIDE2LzAxLzIw
MjIgMDg6MzMsIEp1ZXJnZW4gR3Jvc3Mgd3JvdGU6DQo+PiBkaWZmIC0tZ2l0IGEvdHBtX3Rp
cy5jIGIvdHBtX3Rpcy5jDQo+PiBpbmRleCA0NzdmNTU1MC4uYjg4ZWM4NzQgMTAwNjQ0DQo+
PiAtLS0gYS90cG1fdGlzLmMNCj4+ICsrKyBiL3RwbV90aXMuYw0KPj4gQEAgLTEwOTMsNiAr
MTA5NywyNiBAQCBzc2l6ZV90IHRwbV9nZXRjYXAoc3RydWN0IHRwbV9jaGlwICpjaGlwLCB1
aW50MzJfdCBzdWJjYXBfaWQsIGNhcF90ICpjYXAsDQo+PiAgICAgICAgICAgcmV0dXJuIHJj
Ow0KPj4gICB9DQo+PiAgIA0KPj4gK3N0YXRpYyB2b2lkIHNodXRkb3duX3RwbV90aXMoc3Ry
dWN0IHRwbV9jaGlwICp0cG0pDQo+PiArew0KPj4gKyAgICBpbnQgaTsNCj4+ICsNCj4+ICsg
ICAgcHJpbnRrKCJTaHV0dGluZyBkb3duIHRwbV90aXMgZGV2aWNlXG4iKTsNCj4+ICsNCj4+
ICsgICAgaW93cml0ZTMyKFRQTV9JTlRfRU5BQkxFKHRwbSwgdHBtLT5sb2NhbGl0eSksIH5U
UE1fR0xPQkFMX0lOVF9FTkFCTEUpOw0KPj4gKw0KPj4gKyAgICAvKiBVbm1hcCBhbGwgb2Yg
dGhlIG1taW8gcGFnZXMgKi8NCj4+ICsgICAgZm9yICggaSA9IDA7IGkgPCA1OyArK2kgKQ0K
Pj4gKyAgICB7DQo+PiArICAgICAgICBpZiAoIHRwbS0+cGFnZXNbaV0gIT0gTlVMTCApDQo+
PiArICAgICAgICB7DQo+PiArICAgICAgICAgICAgaW91bm1hcCh0cG0tPnBhZ2VzW2ldLCBQ
QUdFX1NJWkUpOw0KPj4gKyAgICAgICAgICAgIHRwbS0+cGFnZXNbaV0gPSBOVUxMOw0KPj4g
KyAgICAgICAgfQ0KPj4gKyAgICB9DQo+PiArICAgIGZyZWUodHBtKTsNCj4+ICsgICAgcmV0
dXJuOw0KPiANCj4gU2VlaW5nIGFzIHRoZSBmdW5jdGlvbiBpcyBtb3ZpbmcgYW55d2F5LCB0
aGlzIHNwdXJpb3VzIHJldHVybiBjYW4gZ28gdG9vLg0KDQpZZXMuDQoNCg0KSnVlcmdlbg0K
DQo=
--------------hkhEPsBsvqqIYS9Boh2Co5X8
Content-Type: application/pgp-keys; name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Disposition: attachment; filename="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Description: OpenPGP public key
Content-Transfer-Encoding: quoted-printable

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjri
oyspZKOBycWxw3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2
kaV2KL9650I1SJvedYm8Of8Zd621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i
1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y9bfIhWUiVXEK7MlRgUG6MvIj6Y3Am/B
BLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xqG7/377qptDmrk42GlSK
N4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR3Jvc3Mg
PGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsE
FgIDAQIeAQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4F
UGNQH2lvWAUy+dnyThpwdtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3Tye
vpB0CA3dbBQp0OW0fgCetToGIQrg0MbD1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u
+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbvoPHZ8SlM4KWm8rG+lIkGurq
qu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v5QL+qHI3EIP
tyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVy
Z2VuIEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJ
CAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4
RF7HoZhPVPogNVbC4YA6lW7DrWf0teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz7
8X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC/nuAFVGy+67q2DH8As3KPu0344T
BDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0LhITTd9jLzdDad1pQ
SToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLmXBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkM
nQfvUewRz80hSnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMB
AgAjBQJTjHDXAhsDBwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/
Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJnFOXgMLdBQgBlVPO3/D9R8LtF9DBAFPN
hlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1jnDkfJZr6jrbjgyoZHi
w/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0N51N5Jf
VRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwP
OoE+lotufe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK
/1xMI3/+8jbO0tsn1tqSEUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1
c2UuZGU+wsB5BBMBAgAjBQJTjHDrAhsDBwsJCAcDAgEGFQgCCQoLBBYCAwECHgEC
F4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3g3OZUEBmDHVVbqMtzwlmNC4
k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5dM7wRqzgJpJ
wK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu
5D+jLRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzB
TNh30FVKK1EvmV2xAKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37Io
N1EblHI//x/e2AaIHpzK5h88NEawQsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6
AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpWnHIs98ndPUDpnoxWQugJ6MpMncr
0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZRwgnBC5mVM6JjQ5x
Dk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNVbVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mm
we0icXKLkpEdIXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0I
v3OOImwTEe4co3c1mwARAQABwsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMv
Q/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEwTbe8YFsw2V/Buv6Z4Mysln3nQK5ZadD
534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1vJzQ1fOU8lYFpZXTXIH
b+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8VGiwXvT
yJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqc
suylWsviuGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5B
jR/i1DG86lem3iBDXzXsZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------hkhEPsBsvqqIYS9Boh2Co5X8--

--------------ZCqPjPVfbqxtsYwd02it6Tjf--

--------------JmznQ2LzEbK0m5IKJmzCqAK6
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHm1KcFAwAAAAAACgkQsN6d1ii/Ey+W
Ewf9ENFVlvSLJHbuYVboHNtdGuGvtq93TM1v7tkuXch0GuciRcjUylg9wW4OVdyIrJvV1Ch9ZwyZ
ZXT3GrWk2KEWLbH3xtdDp9G4/g+IPXQL1kH/BQRtUQ5G0yuCkjjainL3sGTzehfi+3rPLOhpn0vP
A0LE6RrwAMtCjN1joZz5bzjTJCaA5T8Iv8Y8ghOV3dW//6nEsvKohtSDcMsF0L8uVIl24dlIxMVf
o2/9O8HiAT2lSD6S6dhHtVFOerm/21sFEwmifEyrgeHEhM1d2jdjV7IPUMSc5zEyOZmijC1uhwPJ
jxXLZoD/cA4kg4WqKI9NtaBnbOGiOr5A2HbTYYDD9w==
=KFaX
-----END PGP SIGNATURE-----

--------------JmznQ2LzEbK0m5IKJmzCqAK6--


From minios-devel-bounces@lists.xenproject.org Tue Jan 18 14:55:51 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 18 Jan 2022 14:55:51 +0000
Received: from list by lists.xenproject.org with outflank-mailman.258592.445514 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9ptn-0003hL-2y; Tue, 18 Jan 2022 14:55:51 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 258592.445514; Tue, 18 Jan 2022 14:55:51 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1n9ptn-0003hE-01; Tue, 18 Jan 2022 14:55:51 +0000
Received: by outflank-mailman (input) for mailman id 258592;
 Tue, 18 Jan 2022 14:55:49 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=tdM9=SC=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1n9ptl-0003h3-Jo
 for minios-devel@lists.xenproject.org; Tue, 18 Jan 2022 14:55:49 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id b8e798f4-786e-11ec-9bbc-9dff3e4ee8c5;
 Tue, 18 Jan 2022 15:55:48 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 7E6D7212BB;
 Tue, 18 Jan 2022 14:55:48 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 56DDB13AC3;
 Tue, 18 Jan 2022 14:55:48 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id Z6oQFPTU5mFdTwAAMHmgww
 (envelope-from <jgross@suse.com>); Tue, 18 Jan 2022 14:55:48 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: b8e798f4-786e-11ec-9bbc-9dff3e4ee8c5
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642517748; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=or2PiCDNGQe2X0Sg/R4r64z6A8ES3IgWNQu0DofNAtw=;
	b=F54U1AfYIQGIcDEAinzuzRZhuyZtKs5HsN7+0pcYhiasIKsUOAoTH3H9oikyQ2NhJzmt/Y
	fpWtXyMEb8eWRRIb1jYqpzAXZwNOdPb2xeAYtCsxIlHL/3i/Ck4krKGxf79rAxcU7JmUhi
	rQ10N9meXKBJtpyE+pHiI0xEbWDamDc=
Message-ID: <6b951401-a62a-5397-9b00-7daae27d2ed5@suse.com>
Date: Tue, 18 Jan 2022 15:55:47 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.1
Subject: Re: [MINIOS PATCH v3 06/12] use alloc_file_type() and
 get_file_from_fd() in blkfront
Content-Language: en-US
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-7-jgross@suse.com>
 <5dda5d9b-3488-04d2-0692-9ee12ae26ec7@srcf.net>
From: Juergen Gross <jgross@suse.com>
In-Reply-To: <5dda5d9b-3488-04d2-0692-9ee12ae26ec7@srcf.net>
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature";
 boundary="------------NR3lvnkhe8nAeosTfSbHapfW"

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--------------NR3lvnkhe8nAeosTfSbHapfW
Content-Type: multipart/mixed; boundary="------------ZS2T2Ptfx9VRRLCWQ6tB8HK2";
 protected-headers="v1"
From: Juergen Gross <jgross@suse.com>
To: Andrew Cooper <amc96@srcf.net>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org
Message-ID: <6b951401-a62a-5397-9b00-7daae27d2ed5@suse.com>
Subject: Re: [MINIOS PATCH v3 06/12] use alloc_file_type() and
 get_file_from_fd() in blkfront
References: <20220116083328.26524-1-jgross@suse.com>
 <20220116083328.26524-7-jgross@suse.com>
 <5dda5d9b-3488-04d2-0692-9ee12ae26ec7@srcf.net>
In-Reply-To: <5dda5d9b-3488-04d2-0692-9ee12ae26ec7@srcf.net>

--------------ZS2T2Ptfx9VRRLCWQ6tB8HK2
Content-Type: multipart/mixed; boundary="------------20AIdZ8ov2ThYDD9BQREECju"

--------------20AIdZ8ov2ThYDD9BQREECju
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: base64

T24gMTguMDEuMjIgMTU6NDEsIEFuZHJldyBDb29wZXIgd3JvdGU6DQo+IE9uIDE2LzAxLzIw
MjIgMDg6MzMsIEp1ZXJnZW4gR3Jvc3Mgd3JvdGU6DQo+PiBkaWZmIC0tZ2l0IGEvYmxrZnJv
bnQuYyBiL2Jsa2Zyb250LmMNCj4+IGluZGV4IGUzZjQyYmVmLi5lZDkwMjcwMiAxMDA2NDQN
Cj4+IC0tLSBhL2Jsa2Zyb250LmMNCj4+ICsrKyBiL2Jsa2Zyb250LmMNCj4+IEBAIC00ODMs
OSArNDgzLDEzIEBAIGludCBibGtmcm9udF9haW9fcG9sbChzdHJ1Y3QgYmxrZnJvbnRfZGV2
ICpkZXYpDQo+PiAgIA0KPj4gICBtb3JldG9kbzoNCj4+ICAgI2lmZGVmIEhBVkVfTElCQw0K
Pj4gLSAgICBpZiAoZGV2LT5mZCAhPSAtMSkgew0KPj4gLSAgICAgICAgZmlsZXNbZGV2LT5m
ZF0ucmVhZCA9IGZhbHNlOw0KPj4gLSAgICAgICAgbWIoKTsgLyogTWFrZSBzdXJlIHRvIGxl
dCB0aGUgaGFuZGxlciBzZXQgcmVhZCB0byAxIGJlZm9yZSB3ZSBzdGFydCBsb29raW5nIGF0
IHRoZSByaW5nICovDQo+PiArICAgIHsNCj4+ICsgICAgICAgIHN0cnVjdCBmaWxlICpmaWxl
ID0gZ2V0X2ZpbGVfZnJvbV9mZChkZXYtPmZkKTsNCj4+ICsNCj4+ICsgICAgICAgIGlmICgg
ZmlsZSApIHsNCj4gDQo+IFN0eWxlLCBhcyB0aGlzIGlzIGlzIGJlaW5nIGluZGVudGVkLg0K
DQpPaCwgbWlzc2VkIHRoYXQgb25lLiA6LSgNCg0KPiANCj4+ICsgICAgICAgICAgICBmaWxl
LT5yZWFkID0gZmFsc2U7DQo+PiArICAgICAgICAgICAgbWIoKTsgLyogTWFrZSBzdXJlIHRv
IGxldCB0aGUgaGFuZGxlciBzZXQgcmVhZCB0byAxIGJlZm9yZSB3ZSBzdGFydCBsb29raW5n
IGF0IHRoZSByaW5nICovDQo+IA0KPiBNaW5pT1MgaXMgaW4gZGVzcGVyYXRlIG5lZWQgb2Yg
YmVpbmcgZHJhZ2dlZCBvdmVyIHRvIExLTU0sIGFuZCB0byBzdG9wDQo+IHVzaW5nIGluYXBw
cm9wcmlhdGUgZmVuY2VzLsKgIFRoaW5ncyB3aWxsIGdvIG11Y2ggZmFzdGVyIHdoZW4gdGhl
c2UgaGF2ZQ0KPiBhbGwgYmVlbiBjb3JyZWN0ZWQgdG8gc21wIGJhcnJpZXJzLg0KDQpJbmRl
ZWQuDQoNCg0KSnVlcmdlbg0K
--------------20AIdZ8ov2ThYDD9BQREECju
Content-Type: application/pgp-keys; name="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Disposition: attachment; filename="OpenPGP_0xB0DE9DD628BF132F.asc"
Content-Description: OpenPGP public key
Content-Transfer-Encoding: quoted-printable

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjri
oyspZKOBycWxw3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2
kaV2KL9650I1SJvedYm8Of8Zd621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i
1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y9bfIhWUiVXEK7MlRgUG6MvIj6Y3Am/B
BLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xqG7/377qptDmrk42GlSK
N4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR3Jvc3Mg
PGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsE
FgIDAQIeAQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4F
UGNQH2lvWAUy+dnyThpwdtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3Tye
vpB0CA3dbBQp0OW0fgCetToGIQrg0MbD1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u
+6WGM6nHwbh2l5O8ZiHkH32iaSTfN7Eu5RnNVUJbvoPHZ8SlM4KWm8rG+lIkGurq
qu5gu8q8ZMKdsdGC4bBxdQKDKHEFExLJK/nRPFmAuGlId1E3fe10v5QL+qHI3EIP
tyfE7i9Hz6rVwi7lWKgh7pe0ZvatAudZ+JNIlBKptb64FaiIOAWDCx1SzR9KdWVy
Z2VuIEdyb3NzIDxqZ3Jvc3NAc3VzZS5jb20+wsB5BBMBAgAjBQJTjHCvAhsDBwsJ
CAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/Ey/HmQf/RtI7kv5A2PS4
RF7HoZhPVPogNVbC4YA6lW7DrWf0teC0RR3MzXfy6pJ+7KLgkqMlrAbN/8Dvjoz7
8X+5vhH/rDLa9BuZQlhFmvcGtCF8eR0T1v0nC/nuAFVGy+67q2DH8As3KPu0344T
BDpAvr2uYM4tSqxK4DURx5INz4ZZ0WNFHcqsfvlGJALDeE0LhITTd9jLzdDad1pQ
SToCnLl6SBJZjDOX9QQcyUigZFtCXFst4dlsvddrxyqT1f17+2cFSdu7+ynLmXBK
7abQ3rwJY8SbRO2iRulogc5vr/RLMMlscDAiDkaFQWLoqHHOdfO9rURssHNN8WkM
nQfvUewRz80hSnVlcmdlbiBHcm9zcyA8amdyb3NzQG5vdmVsbC5jb20+wsB5BBMB
AgAjBQJTjHDXAhsDBwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQsN6d1ii/
Ey8PUQf/ehmgCI9jB9hlgexLvgOtf7PJnFOXgMLdBQgBlVPO3/D9R8LtF9DBAFPN
hlrsfIG/SqICoRCqUcJ96Pn3P7UUinFG/I0ECGF4EvTE1jnDkfJZr6jrbjgyoZHi
w/4BNwSTL9rWASyLgqlA8u1mf+c2yUwcGhgkRAd1gOwungxcwzwqgljf0N51N5Jf
VRHRtyfwq/ge+YEkDGcTU6Y0sPOuj4Dyfm8fJzdfHNQsWq3PnczLVELStJNdapwP
OoE+lotufe3AM2vAEYJ9rTz3Cki4JFUsgLkHFqGZarrPGi1eyQcXeluldO3m91NK
/1xMI3/+8jbO0tsn1tqSEUGIJi7ox80eSnVlcmdlbiBHcm9zcyA8amdyb3NzQHN1
c2UuZGU+wsB5BBMBAgAjBQJTjHDrAhsDBwsJCAcDAgEGFQgCCQoLBBYCAwECHgEC
F4AACgkQsN6d1ii/Ey+LhQf9GL45eU5vOowA2u5N3g3OZUEBmDHVVbqMtzwlmNC4
k9Kx39r5s2vcFl4tXqW7g9/ViXYuiDXb0RfUpZiIUW89siKrkzmQ5dM7wRqzgJpJ
wK8Bn2MIxAKArekWpiCKvBOB/Cc+3EXE78XdlxLyOi/NrmSGRIov0karw2RzMNOu
5D+jLRZQd1Sv27AR+IP3I8U4aqnhLpwhK7MEy9oCILlgZ1QZe49kpcumcZKORmzB
TNh30FVKK1EvmV2xAKDoaEOgQB4iFQLhJCdP1I5aSgM5IVFdn7v5YgEYuJYx37Io
N1EblHI//x/e2AaIHpzK5h88NEawQsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6
AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpWnHIs98ndPUDpnoxWQugJ6MpMncr
0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZRwgnBC5mVM6JjQ5x
Dk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNVbVF
LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mm
we0icXKLkpEdIXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0I
v3OOImwTEe4co3c1mwARAQABwsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMv
Q/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEwTbe8YFsw2V/Buv6Z4Mysln3nQK5ZadD
534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1vJzQ1fOU8lYFpZXTXIH
b+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8VGiwXvT
yJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqc
suylWsviuGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5B
jR/i1DG86lem3iBDXzXsZDn8R38=3D
=3D2wuH
-----END PGP PUBLIC KEY BLOCK-----

--------------20AIdZ8ov2ThYDD9BQREECju--

--------------ZS2T2Ptfx9VRRLCWQ6tB8HK2--

--------------NR3lvnkhe8nAeosTfSbHapfW
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmHm1PMFAwAAAAAACgkQsN6d1ii/Ey/V
/wf/cX5zQ6inizr/t9ikrUnteHhjP577v/c345akQAWXI3FceoicY69N6WOR4/Q24ZnlYsH2knBD
l7pPXIj4ifg5B2hnSyO8XFHQU8PRpLsZGSW/yc4+XZiRlb5OKlwY6Oqh/ythLFshhSfUf9fTkGfM
JFJulO1KNWMIM9s3X5faJXv5fkspxSaYmfEmdWogLtukb/Kfs8os8/yAjZVxTIyYc91uXCc6Ldu+
i/fx5XvoykPo+wwiM1LU4TVQjAIA6/Bt6Lja8z2Cd0VLvJw8Cc80rcdTBIUS88i5ii73Jmoiuzau
sxm6zvZbQGkiXmdtw27o3p8VLILR0VMc3buHs/s5Wg==
=0gQK
-----END PGP SIGNATURE-----

--------------NR3lvnkhe8nAeosTfSbHapfW--


From minios-devel-bounces@lists.xenproject.org Wed Jan 19 13:06:11 2022
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 19 Jan 2022 13:06:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.258833.446222 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1nAAf8-0008H9-Az; Wed, 19 Jan 2022 13:06:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 258833.446222; Wed, 19 Jan 2022 13:06:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1nAAf8-0008H2-7N; Wed, 19 Jan 2022 13:06:06 +0000
Received: by outflank-mailman (input) for mailman id 258833;
 Wed, 19 Jan 2022 13:06:04 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=7l/E=SD=suse.com=jgross@srs-se1.protection.inumbo.net>)
 id 1nAAf6-0008Gr-CI
 for minios-devel@lists.xenproject.org; Wed, 19 Jan 2022 13:06:04 +0000
Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 8de5fc63-7928-11ec-9bbc-9dff3e4ee8c5;
 Wed, 19 Jan 2022 14:06:03 +0100 (CET)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by smtp-out1.suse.de (Postfix) with ESMTPS id 6FAD421122;
 Wed, 19 Jan 2022 13:06:02 +0000 (UTC)
Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512)
 (No client certificate requested)
 by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3BB2613B61;
 Wed, 19 Jan 2022 13:06:02 +0000 (UTC)
Received: from dovecot-director2.suse.de ([192.168.254.65])
 by imap2.suse-dmz.suse.de with ESMTPSA id HJ1FDboM6GEzMAAAMHmgww
 (envelope-from <jgross@suse.com>); Wed, 19 Jan 2022 13:06:02 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 8de5fc63-7928-11ec-9bbc-9dff3e4ee8c5
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
	t=1642597562; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:
	 mime-version:mime-version:  content-transfer-encoding:content-transfer-encoding;
	bh=X9TF0UCrVN8MPXUemayk1jcTqVk+WiDi0ZPq15Svabs=;
	b=BCTE42a/5QwlUsQifKXEorG4GOX7pqBhlbbxrz40hmVSj0XKxcn+485uIMrrL5nagkpW0m
	NU+NXfX4NW9OAN1da8ZwFXDQZdiGTXnGp/j2tEuvaHLTXIwAJ6a7IMSphS837g2TpcgEfL
	O7t79vPkXqp3C+2jg06dc3B654eqC4c=
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH] fix wrong function declaration
Date: Wed, 19 Jan 2022 14:06:00 +0100
Message-Id: <20220119130600.27579-1-jgross@suse.com>
X-Mailer: git-send-email 2.31.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Coverity spotted a wrong function declaration, fix it.

Coverity-Id: 1497423
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/balloon.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/balloon.h b/include/balloon.h
index 8f7c8bd8..510e475a 100644
--- a/include/balloon.h
+++ b/include/balloon.h
@@ -50,7 +50,7 @@ static inline int chk_free_pages(unsigned long needed)
 {
     return needed <= nr_free_pages;
 }
-static inline balloon_set_nr_pages(unsigned long pages, unsigned long pfn) { }
+static inline void balloon_set_nr_pages(unsigned long pages, unsigned long pfn) { }
 
 #endif /* CONFIG_BALLOON */
 #endif /* _BALLOON_H_ */
-- 
2.31.1



