Re: Missing extattr syscalls on compat32 (was Re: libarchive extattr i386/amd64 syscall issue)

From: Kostik Belousov <kostikbel_at_gmail.com>
Date: Fri, 5 Jun 2009 17:40:52 +0300
On Fri, Jun 05, 2009 at 09:45:51AM -0400, John Baldwin wrote:
> On Thursday 04 June 2009 9:54:02 am Kostik Belousov wrote:
> > On Wed, Jun 03, 2009 at 09:43:28PM -0700, Tim Kientzle wrote:
> > > Dmitry Marakasov wrote:
> > > >
> > > >The problem: on recent current, 32bit bsdtar won't write archives when
> > > >running under 64bit kernel, dying with exit code 140 and `Bad system 
> call'
> > > >message. I've ran into that using i386 tinderbox jail on amd64 host.
> > > >The problem actually happens in libarchive:
> > > >
> > > >--- lib/libarchive/archive_read_disk_entry_from_file.c ---
> > > >   484		if (!a->follow_symlinks)
> > > >   485			list_size = extattr_list_link(path, 
> > > >   namespace, NULL, 0);   // <-- HERE
> > > >   486		else
> > > >   487			list_size = extattr_list_file(path, 
> > > >   namespace, NULL, 0);
> > > >--- lib/libarchive/archive_read_disk_entry_from_file.c ---
> > > 
> > > Yes, it looks like only about half of the extattr calls are
> > > actually connected in the freebsd32 compatibility layer. (see below)
> > > According to SVN history, peter_at_ reserved these slots back
> > > in December 2003 but no one ever went back and connected
> > > them up.  I don't know if there was a reason for not
> > > connecting them or if simply no one remembered to do so.
> > > I would guess the latter; the ones that are connected
> > > were all implemented before mid-2002.
> > > 
> > > I don't see any obvious reason these should not just
> > > work.  If you're feeling adventurous, you could try
> > > copying the data from /usr/src/kern/syscalls.master
> > > and see what happens.  I don't have a 64-bit system
> > > handy here or I would try this myself.
> > > 
> > > You can test by going to /usr/src/lib/libarchive/test and
> > > running "make check".  That will build and run the libarchive
> > > test suite, which does exercise the extended attribute support.
> > > (Of course, you should revert your change first so that the
> > > extended attribute support is actually compiled.)
> > > 
> > > Let me know if you find anything,
> > > 
> > > Tim
> > > 
> > > 
> > > $ grep extattr /usr/src/sys/compat/freebsd32/syscalls.master
> > > 355     AUE_EXTATTRCTL  NOPROTO { int extattrctl(const char *path, int 
> > > cmd, \
> > > 356     AUE_EXTATTR_SET_FILE    NOPROTO { int extattr_set_file( \
> > > 357     AUE_EXTATTR_GET_FILE    NOPROTO { ssize_t extattr_get_file( \
> > > 358     AUE_EXTATTR_DELETE_FILE NOPROTO { int extattr_delete_file( \
> > > 371     AUE_EXTATTR_SET_FD      NOPROTO { int extattr_set_fd(int fd, \
> > > 372     AUE_EXTATTR_GET_FD      NOPROTO { ssize_t extattr_get_fd(int fd, \
> > > 373     AUE_EXTATTR_DELETE_FD   NOPROTO { int extattr_delete_fd(int fd, \
> > > 412     AUE_EXTATTR_SET_LINK    UNIMPL  extattr_set_link
> > > 413     AUE_EXTATTR_GET_LINK    UNIMPL  extattr_get_link
> > > 414     AUE_EXTATTR_DELETE_LINK UNIMPL  extattr_delete_link
> > > 437     AUE_EXTATTR_LIST_FD     UNIMPL  extattr_list_fd
> > > 438     AUE_EXTATTR_LIST_FILE   UNIMPL  extattr_list_file
> > > 439     AUE_EXTATTR_LIST_LINK   UNIMPL  extattr_list_link
> > 
> > The size_t arguments need translation. Please try the patch below.
> 
> Err, size_t is 32-bit for freebsd32.  Only 64-bit types like off_t need this 
> sort of fixup.  See 'read' and 'write' which just use the native versions for 
> example.  I don't think these calls need any sort of wrapper but the native 
> versions should just work.

Yes, I obvioulsy confused it with off_t.

diff --git a/sys/compat/freebsd32/freebsd32_proto.h b/sys/compat/freebsd32/freebsd32_proto.h
index 5a12c5d..587fdc4 100644
--- a/sys/compat/freebsd32/freebsd32_proto.h
+++ b/sys/compat/freebsd32/freebsd32_proto.h
_at__at_ -3,7 +3,7 _at__at_
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 191673 2009-04-29 21:14:15Z jamie 
+ * created from FreeBSD
  */
 
 #ifndef _FREEBSD32_SYSPROTO_H_
diff --git a/sys/compat/freebsd32/freebsd32_syscall.h b/sys/compat/freebsd32/freebsd32_syscall.h
index 73fc7b3..43a68b3 100644
--- a/sys/compat/freebsd32/freebsd32_syscall.h
+++ b/sys/compat/freebsd32/freebsd32_syscall.h
_at__at_ -3,7 +3,7 _at__at_
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 191673 2009-04-29 21:14:15Z jamie 
+ * created from FreeBSD
  */
 
 #define	FREEBSD32_SYS_syscall	0
_at__at_ -303,6 +303,9 _at__at_
 #define	FREEBSD32_SYS_statfs	396
 #define	FREEBSD32_SYS_fstatfs	397
 #define	FREEBSD32_SYS_fhstatfs	398
+#define	FREEBSD32_SYS_extattr_set_link	412
+#define	FREEBSD32_SYS_extattr_get_link	413
+#define	FREEBSD32_SYS_extattr_delete_link	414
 #define	FREEBSD32_SYS_freebsd32_sigaction	416
 #define	FREEBSD32_SYS_freebsd32_sigreturn	417
 #define	FREEBSD32_SYS_freebsd32_getcontext	421
_at__at_ -315,6 +318,9 _at__at_
 #define	FREEBSD32_SYS_freebsd32_umtx_lock	434
 #define	FREEBSD32_SYS_freebsd32_umtx_unlock	435
 #define	FREEBSD32_SYS_jail_attach	436
+#define	FREEBSD32_SYS_extattr_list_fd	437
+#define	FREEBSD32_SYS_extattr_list_file	438
+#define	FREEBSD32_SYS_extattr_list_link	439
 #define	FREEBSD32_SYS_freebsd32_thr_suspend	442
 #define	FREEBSD32_SYS_thr_wake	443
 #define	FREEBSD32_SYS_kldunloadf	444
diff --git a/sys/compat/freebsd32/freebsd32_syscalls.c b/sys/compat/freebsd32/freebsd32_syscalls.c
index c31d080..a69d907 100644
--- a/sys/compat/freebsd32/freebsd32_syscalls.c
+++ b/sys/compat/freebsd32/freebsd32_syscalls.c
_at__at_ -3,7 +3,7 _at__at_
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 191673 2009-04-29 21:14:15Z jamie 
+ * created from FreeBSD
  */
 
 const char *freebsd32_syscallnames[] = {
_at__at_ -419,9 +419,9 _at__at_ const char *freebsd32_syscallnames[] = {
 	"#409",			/* 409 = __mac_get_pid */
 	"#410",			/* 410 = __mac_get_link */
 	"#411",			/* 411 = __mac_set_link */
-	"#412",			/* 412 = extattr_set_link */
-	"#413",			/* 413 = extattr_get_link */
-	"#414",			/* 414 = extattr_delete_link */
+	"extattr_set_link",			/* 412 = extattr_set_link */
+	"extattr_get_link",			/* 413 = extattr_get_link */
+	"extattr_delete_link",			/* 414 = extattr_delete_link */
 	"#415",			/* 415 = __mac_execve */
 	"freebsd32_sigaction",			/* 416 = freebsd32_sigaction */
 	"freebsd32_sigreturn",			/* 417 = freebsd32_sigreturn */
_at__at_ -444,9 +444,9 _at__at_ const char *freebsd32_syscallnames[] = {
 	"freebsd32_umtx_lock",			/* 434 = freebsd32_umtx_lock */
 	"freebsd32_umtx_unlock",			/* 435 = freebsd32_umtx_unlock */
 	"jail_attach",			/* 436 = jail_attach */
-	"#437",			/* 437 = extattr_list_fd */
-	"#438",			/* 438 = extattr_list_file */
-	"#439",			/* 439 = extattr_list_link */
+	"extattr_list_fd",			/* 437 = extattr_list_fd */
+	"extattr_list_file",			/* 438 = extattr_list_file */
+	"extattr_list_link",			/* 439 = extattr_list_link */
 	"#440",			/* 440 = kse_switchin */
 	"#441",			/* 441 = ksem_timedwait */
 	"freebsd32_thr_suspend",			/* 442 = freebsd32_thr_suspend */
diff --git a/sys/compat/freebsd32/freebsd32_sysent.c b/sys/compat/freebsd32/freebsd32_sysent.c
index a44eb58..5d64fca 100644
--- a/sys/compat/freebsd32/freebsd32_sysent.c
+++ b/sys/compat/freebsd32/freebsd32_sysent.c
_at__at_ -3,7 +3,7 _at__at_
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 191673 2009-04-29 21:14:15Z jamie 
+ * created from FreeBSD
  */
 
 #include "opt_compat.h"
_at__at_ -450,9 +450,9 _at__at_ struct sysent freebsd32_sysent[] = {
 	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0 },			/* 409 = __mac_get_pid */
 	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0 },			/* 410 = __mac_get_link */
 	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0 },			/* 411 = __mac_set_link */
-	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0 },			/* 412 = extattr_set_link */
-	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0 },			/* 413 = extattr_get_link */
-	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0 },			/* 414 = extattr_delete_link */
+	{ AS(extattr_set_link_args), (sy_call_t *)extattr_set_link, AUE_EXTATTR_SET_LINK, NULL, 0, 0, 0 },	/* 412 = extattr_set_link */
+	{ AS(extattr_get_link_args), (sy_call_t *)extattr_get_link, AUE_EXTATTR_GET_LINK, NULL, 0, 0, 0 },	/* 413 = extattr_get_link */
+	{ AS(extattr_delete_link_args), (sy_call_t *)extattr_delete_link, AUE_EXTATTR_DELETE_LINK, NULL, 0, 0, 0 },	/* 414 = extattr_delete_link */
 	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0 },			/* 415 = __mac_execve */
 	{ AS(freebsd32_sigaction_args), (sy_call_t *)freebsd32_sigaction, AUE_SIGACTION, NULL, 0, 0, 0 },	/* 416 = freebsd32_sigaction */
 	{ AS(freebsd32_sigreturn_args), (sy_call_t *)freebsd32_sigreturn, AUE_SIGRETURN, NULL, 0, 0, 0 },	/* 417 = freebsd32_sigreturn */
_at__at_ -475,9 +475,9 _at__at_ struct sysent freebsd32_sysent[] = {
 	{ AS(freebsd32_umtx_lock_args), (sy_call_t *)freebsd32_umtx_lock, AUE_NULL, NULL, 0, 0, 0 },	/* 434 = freebsd32_umtx_lock */
 	{ AS(freebsd32_umtx_unlock_args), (sy_call_t *)freebsd32_umtx_unlock, AUE_NULL, NULL, 0, 0, 0 },	/* 435 = freebsd32_umtx_unlock */
 	{ AS(jail_attach_args), (sy_call_t *)jail_attach, AUE_NULL, NULL, 0, 0, 0 },	/* 436 = jail_attach */
-	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0 },			/* 437 = extattr_list_fd */
-	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0 },			/* 438 = extattr_list_file */
-	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0 },			/* 439 = extattr_list_link */
+	{ AS(extattr_list_fd_args), (sy_call_t *)extattr_list_fd, AUE_EXTATTR_LIST_FD, NULL, 0, 0, 0 },	/* 437 = extattr_list_fd */
+	{ AS(extattr_list_file_args), (sy_call_t *)extattr_list_file, AUE_EXTATTR_LIST_FILE, NULL, 0, 0, 0 },	/* 438 = extattr_list_file */
+	{ AS(extattr_list_link_args), (sy_call_t *)extattr_list_link, AUE_EXTATTR_LIST_LINK, NULL, 0, 0, 0 },	/* 439 = extattr_list_link */
 	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0 },			/* 440 = kse_switchin */
 	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0 },			/* 441 = ksem_timedwait */
 	{ AS(freebsd32_thr_suspend_args), (sy_call_t *)freebsd32_thr_suspend, AUE_NULL, NULL, 0, 0, 0 },	/* 442 = freebsd32_thr_suspend */
diff --git a/sys/compat/freebsd32/syscalls.master b/sys/compat/freebsd32/syscalls.master
index 50e30ad..7da270b 100644
--- a/sys/compat/freebsd32/syscalls.master
+++ b/sys/compat/freebsd32/syscalls.master
_at__at_ -708,9 +708,17 _at__at_
 409	AUE_NULL	UNIMPL	__mac_get_pid
 410	AUE_NULL	UNIMPL	__mac_get_link
 411	AUE_NULL	UNIMPL	__mac_set_link
-412	AUE_EXTATTR_SET_LINK	UNIMPL	extattr_set_link
-413	AUE_EXTATTR_GET_LINK	UNIMPL	extattr_get_link
-414	AUE_EXTATTR_DELETE_LINK	UNIMPL	extattr_delete_link
+412	AUE_EXTATTR_SET_LINK	NOPROTO	{ int extattr_set_link( \
+				    const char *path, int attrnamespace, \
+				    const char *attrname, void *data, \
+				    size_t nbytes); }
+413	AUE_EXTATTR_GET_LINK	NOPROTO	{ ssize_t extattr_get_link( \
+				    const char *path, int attrnamespace, \
+				    const char *attrname, void *data, \
+				    size_t nbytes); }
+414	AUE_EXTATTR_DELETE_LINK	NOPROTO	{ int extattr_delete_link( \
+				    const char *path, int attrnamespace, \
+				    const char *attrname); }
 415	AUE_NULL	UNIMPL	__mac_execve
 416	AUE_SIGACTION	STD	{ int freebsd32_sigaction(int sig, \
 				    struct sigaction32 *act, \
_at__at_ -741,9 +749,15 _at__at_
 434	AUE_NULL	STD	{ int freebsd32_umtx_lock(struct umtx *umtx); }
 435	AUE_NULL	STD	{ int freebsd32_umtx_unlock(struct umtx *umtx); }
 436	AUE_NULL	NOPROTO	{ int jail_attach(int jid); }
-437	AUE_EXTATTR_LIST_FD	UNIMPL	extattr_list_fd
-438	AUE_EXTATTR_LIST_FILE	UNIMPL	extattr_list_file
-439	AUE_EXTATTR_LIST_LINK	UNIMPL	extattr_list_link
+437	AUE_EXTATTR_LIST_FD	NOPROTO	{ ssize_t extattr_list_fd(int fd, \
+				    int attrnamespace, void *data, \
+				    size_t nbytes); }
+438	AUE_EXTATTR_LIST_FILE	NOPROTO	{ ssize_t extattr_list_file( \
+				    const char *path, int attrnamespace, \
+				    void *data, size_t nbytes); }
+439	AUE_EXTATTR_LIST_LINK	NOPROTO	{ ssize_t extattr_list_link( \
+				    const char *path, int attrnamespace, \
+				    void *data, size_t nbytes); }
 440	AUE_NULL	UNIMPL	kse_switchin
 441	AUE_NULL	UNIMPL	ksem_timedwait
 442	AUE_NULL	STD	{ int freebsd32_thr_suspend( \

Received on Fri Jun 05 2009 - 12:41:03 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:49 UTC