Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"The identical is equal to itself, since it is different." -- Franco Spisani


devel / comp.lang.awk / Re: gawk "readdir" dynamic lib errors

SubjectAuthor
* gawk "readdir" dynamic lib errorsjeorge
+- Re: gawk "readdir" dynamic lib errorsKenny McCormack
+- Re: gawk "readdir" dynamic lib errorsManuel Collado
+- Re: gawk "readdir" dynamic lib errorsjeorge
`* Re: gawk "readdir" dynamic lib errorsAharon Robbins
 `- Re: gawk "readdir" dynamic lib errorsjeorge

1
gawk "readdir" dynamic lib errors

<u4gre4$2b2$1@nnrp.usenet.blueworldhosting.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1460&group=comp.lang.awk#1460

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!nnrp.usenet.blueworldhosting.com!.POSTED!not-for-mail
From: someone@invalid.invalid (jeorge)
Newsgroups: comp.lang.awk
Subject: gawk "readdir" dynamic lib errors
Date: Mon, 22 May 2023 16:47:32 -0600
Organization: Ministry of Madness
Message-ID: <u4gre4$2b2$1@nnrp.usenet.blueworldhosting.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 22 May 2023 22:47:32 -0000 (UTC)
Injection-Info: nnrp.usenet.blueworldhosting.com;
logging-data="2402"; mail-complaints-to="usenet@blueworldhosting.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:L11IojByCdBe4OauLkm/AEGGwF8= sha256:erFBQixJT3v+bpM179FgJuMEIkiOtjlb27svbg1l15I=
sha1:sx/TTB4kvf3J9DbsYp+gqxRWuzg= sha256:HyYej/3MlFJeeYXbzTdaX8rfY2zyqT2REyxd/yXzYdw=
Content-Language: en-US
 by: jeorge - Mon, 22 May 2023 22:47 UTC

Hello,
I'm wanting to take advantage of the readdir.so dynamic library that
ships with gawk but I'm having an issue on the target system which the
following test code reveals:

#-- test code --
@load "readdir"

BEGIN{
d="/proc/sys"
f=d"/kernel/version"
FS="/"
while(getline<d)
if($3=="d")
print $2
close(d)

FS=" "
while(getline<f)
print $0
close(f)

print "\nGNU Awk",PROCINFO["version"]
} #-- ---- ---- --

Output on my home system look fine but on the target system I get the
following errors/warnings right after the /proc/sys directory listing
which I don't understand:

#-- error msg --
awk: cmd. line:1: warning: dir_take_control_of: opendir/fdopendir
failed: Not a directory
awk: cmd. line:1: warning: input parser `readdir' failed to open
`/proc/sys/kernel/version'
#-- ----- --- --

Versioning (last line in code):
- home system: GNU Awk ver: 5.1.0
- target system: GNU Awk ver: 5.2.2

Other info for target machine:
- OS = Arch Linux (64bit)
- AWKLIBPATH = /usr/lib/gawk
- $ gawk --version |head -n1
=> GNU Awk 5.2.2, API 3.2, PMA Avon 8-g1, (GNU MPFR 4.2.0-p9, GNU MP
6.2.1)

Does this look like a fixable configuration quirk not requiring
recompiling or something else? I'm not admin on the target system but
benign configuration tweaks would likely be an option.

-J

Re: gawk "readdir" dynamic lib errors

<u4gt3a$879$1@news.xmission.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1461&group=comp.lang.awk#1461

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.awk
Subject: Re: gawk "readdir" dynamic lib errors
Date: Mon, 22 May 2023 23:15:54 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <u4gt3a$879$1@news.xmission.com>
References: <u4gre4$2b2$1@nnrp.usenet.blueworldhosting.com>
Injection-Date: Mon, 22 May 2023 23:15:54 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="8425"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Mon, 22 May 2023 23:15 UTC

In article <u4gre4$2b2$1@nnrp.usenet.blueworldhosting.com>,
jeorge <someone@invalid.invalid> wrote:
>Hello,
>I'm wanting to take advantage of the readdir.so dynamic library that
>ships with gawk but I'm having an issue on the target system which the
>following test code reveals:

Works fine here, but then again, that helps you not at all.

I doubt there's anything wrong with the readdir library (although it is
certainly possible that there is). More likely, something strange about
the contents of the /proc/sys directory on the "target" system.

Probably just the usual debugging techniques need to be applied. Keep
trying things until you figure out what step is not doing what you expect.

--
Elect a clown, expect a circus.

Re: gawk "readdir" dynamic lib errors

<u4hogj$2fokg$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1462&group=comp.lang.awk#1462

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mcollado2011@gmail.com (Manuel Collado)
Newsgroups: comp.lang.awk
Subject: Re: gawk "readdir" dynamic lib errors
Date: Tue, 23 May 2023 09:03:47 +0200
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <u4hogj$2fokg$1@dont-email.me>
References: <u4gre4$2b2$1@nnrp.usenet.blueworldhosting.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 23 May 2023 07:03:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ace01a5ad4883decb38550ec3d303704";
logging-data="2613904"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19NoP1gYJKnJgkovqvGoAl7E2yV7rHgRQk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:6dPata/lfKfjtRJUos8fJFAv2R8=
In-Reply-To: <u4gre4$2b2$1@nnrp.usenet.blueworldhosting.com>
Content-Language: en-US, es-ES
 by: Manuel Collado - Tue, 23 May 2023 07:03 UTC

El 23/5/23 a las 0:47, jeorge escribió:
> Hello,
> I'm wanting to take advantage of the readdir.so dynamic library that
> ships with gawk but I'm having an issue on the target system which the
> following test code reveals:
> [snip]
> Output on my home system look fine but on the target system I get the
> following errors/warnings right after the /proc/sys directory listing
> which I don't understand:
>
> #-- error msg --
> awk: cmd. line:1: warning: dir_take_control_of: opendir/fdopendir
> failed: Not a directory
> awk: cmd. line:1: warning: input parser `readdir' failed to open
> `/proc/sys/kernel/version'
> #-- ----- --- --

Some weird with /proc/sys/kernel/version in the target machine. Please
post the relevant part of the output of

ls -l /proc/sys/kernel/

Maybe .../version is a link instead of a regular directory.

HTH.
--
Manuel Collado - http://mcollado.z15.es

Re: gawk "readdir" dynamic lib errors

<u4imn9$2i1j$1@nnrp.usenet.blueworldhosting.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1463&group=comp.lang.awk#1463

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!nnrp.usenet.blueworldhosting.com!.POSTED!not-for-mail
From: someone@invalid.invalid (jeorge)
Newsgroups: comp.lang.awk
Subject: Re: gawk "readdir" dynamic lib errors
Date: Tue, 23 May 2023 09:39:21 -0600
Organization: Ministry of Madness
Message-ID: <u4imn9$2i1j$1@nnrp.usenet.blueworldhosting.com>
References: <u4gre4$2b2$1@nnrp.usenet.blueworldhosting.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 23 May 2023 15:39:21 -0000 (UTC)
Injection-Info: nnrp.usenet.blueworldhosting.com;
logging-data="84019"; mail-complaints-to="usenet@blueworldhosting.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:wmIJ+GFr7U1kHYccWTsFkMbyB9k= sha256:aOKKV9UanxX/ZiFhP7R04DAjtluHeQksOrkwdjoJkK8=
sha1:O8NKVN22PzvIB9StkghYNV+qKQM= sha256:rzk2e16gLiLLv7P6wKxgRbh9742RUa1581OG/n9MLBQ=
Content-Language: en-US
In-Reply-To: <u4gre4$2b2$1@nnrp.usenet.blueworldhosting.com>
 by: jeorge - Tue, 23 May 2023 15:39 UTC

Actually the warning occurs when gawk hits ## while(getline<f) ## as
seen below. I changed my test dir and file to "/etc" and "/etc/hosts"
to eliminate potential permissions issues in /proc/sys/:

$ cat readdir_test2.awk
#-- test code --
@load "readdir"
BEGIN{
d="/etc"
f=d"/hosts"
while(getline<f)
print $0
close(f)
} #-- ---- ---- --

Run & output:

$ gawk -f readdir_test2.awk
gawk: readdir_test.awk:6: warning:\
dir_take_control_of: opendir/fdopendir failed: Not a directory
gawk: readdir_test.awk:6: warning:\
input parser `readdir' failed to open `/etc/hosts'
=># Static table lookup for hostnames.
=># See hosts(5) for details.
=>
=>

It does output the contents of the hosts file as (=>) indicated.

Basically my goal is to use the "readdir" functionality to obtain the
paths to particular files which are then read in and processed. I found
additionally loading "readfile" provides a warning-free work-around:

$ cat readdir_test3.awk
#-- test code --
@load "readfile"
@load "readdir"
BEGIN{
d="/etc/"
f=d"hosts"
FS="/"
while(getline<d)
if($2~/[A-Z]/ && $3=="d")
print d$2
close(d)
str=readfile(f)
split(str,arr,"\n")
for(i in arr)
print arr[i]
} #-- ---- ---- --

Run & output:

$ gawk -f readdir_test3.awk
/etc/ODBCDataSources
/etc/R
/etc/X11
# Static table lookup for hostnames.
# See hosts(5) for details.

This seems an okay solution if the files to be processes aren't huge;
it would be better to only read as much as needed from the files.

I'm wondering it there is a way to UNload a dynamic library once one is
done with it, something like ## @unload "readdir" ## ? Might be useful.

-J

Re: gawk "readdir" dynamic lib errors

<646d79dc$0$702$14726298@news.sunsite.dk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1464&group=comp.lang.awk#1464

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
From: arnold@skeeve.com (Aharon Robbins)
Newsgroups: comp.lang.awk
Subject: Re: gawk "readdir" dynamic lib errors
References: <u4gre4$2b2$1@nnrp.usenet.blueworldhosting.com>
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: arnold@skeeve.com (Aharon Robbins)
Date: 24 May 2023 02:43:40 GMT
Lines: 88
Message-ID: <646d79dc$0$702$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 3c721625.news.sunsite.dk
X-Trace: 1684896220 news.sunsite.dk 702 arnold@skeeve.com/164.138.127.227:23508
X-Complaints-To: staff@sunsite.dk
 by: Aharon Robbins - Wed, 24 May 2023 02:43 UTC

Hello.

Mack The Knife forwarded your report to me. This kind of
question would have been better sent to the bug-gawk list,
as you've found an actual bug. (The first real bug for 5.2.2,
congratulations! :-)

The bug is due to a change in the readdir extension that
occurred with the 5.2.2 release. Here is a patch.

Thanks,

Arnold
-----------------------------------------------
diff --git a/extension/readdir.c b/extension/readdir.c
index e367ff12..4ae1626f 100644
--- a/extension/readdir.c
+++ b/extension/readdir.c
@@ -249,7 +249,7 @@ dir_can_take_file(const awk_input_buf_t *iobuf)
if (iobuf == NULL)
return awk_false;
- return (iobuf->fd != INVALID_HANDLE || S_ISDIR(iobuf->sbuf.st_mode));
+ return (S_ISDIR(iobuf->sbuf.st_mode));
}
/*
-----------------------------------------------

In article <u4gre4$2b2$1@nnrp.usenet.blueworldhosting.com>,
jeorge <someone@invalid.invalid> wrote:
>Hello,
>I'm wanting to take advantage of the readdir.so dynamic library that
>ships with gawk but I'm having an issue on the target system which the
>following test code reveals:
>
>#-- test code --
>@load "readdir"
>
>BEGIN{
>d="/proc/sys"
>f=d"/kernel/version"
>FS="/"
>while(getline<d)
> if($3=="d")
> print $2
>close(d)
>
>FS=" "
>while(getline<f)
> print $0
>close(f)
>
>print "\nGNU Awk",PROCINFO["version"]
>}
>#-- ---- ---- --
>
>Output on my home system look fine but on the target system I get the
>following errors/warnings right after the /proc/sys directory listing
>which I don't understand:
>
>#-- error msg --
>awk: cmd. line:1: warning: dir_take_control_of: opendir/fdopendir
>failed: Not a directory
>awk: cmd. line:1: warning: input parser `readdir' failed to open
>`/proc/sys/kernel/version'
>#-- ----- --- --
>
>Versioning (last line in code):
>- home system: GNU Awk ver: 5.1.0
>- target system: GNU Awk ver: 5.2.2
>
>Other info for target machine:
>- OS = Arch Linux (64bit)
>- AWKLIBPATH = /usr/lib/gawk
>- $ gawk --version |head -n1
> => GNU Awk 5.2.2, API 3.2, PMA Avon 8-g1, (GNU MPFR 4.2.0-p9, GNU MP
>6.2.1)
>
>Does this look like a fixable configuration quirk not requiring
>recompiling or something else? I'm not admin on the target system but
>benign configuration tweaks would likely be an option.
>
>-J

--
Aharon (Arnold) Robbins arnold AT skeeve DOT com

Re: gawk "readdir" dynamic lib errors

<u4lmvk$2ulr$1@nnrp.usenet.blueworldhosting.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1465&group=comp.lang.awk#1465

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!nnrp.usenet.blueworldhosting.com!.POSTED!not-for-mail
From: someone@invalid.invalid (jeorge)
Newsgroups: comp.lang.awk
Subject: Re: gawk "readdir" dynamic lib errors
Date: Wed, 24 May 2023 13:02:12 -0600
Organization: Ministry of Madness
Message-ID: <u4lmvk$2ulr$1@nnrp.usenet.blueworldhosting.com>
References: <u4gre4$2b2$1@nnrp.usenet.blueworldhosting.com>
<646d79dc$0$702$14726298@news.sunsite.dk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 24 May 2023 19:02:12 -0000 (UTC)
Injection-Info: nnrp.usenet.blueworldhosting.com;
logging-data="96955"; mail-complaints-to="usenet@blueworldhosting.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:MbWkMZ0NT3sgCvH0ycw6W9ltTl0= sha256:y0cI1t1sIAYZSTeBrMbbB2O7VQ1EEz1NFss0tst4Vqs=
sha1:6xSFreGtu6aB0WmFFiqgbikH11I= sha256:N8aOUOAqNNGmgxYh2ymwDmqewn3e/WpB6hcZKvaP604=
Content-Language: en-US
In-Reply-To: <646d79dc$0$702$14726298@news.sunsite.dk>
 by: jeorge - Wed, 24 May 2023 19:02 UTC

On 5/23/23 8:43 PM, Aharon Robbins wrote:
> Mack The Knife forwarded your report to me. This kind of
> question would have been better sent to the bug-gawk list,
> as you've found an actual bug. (The first real bug for 5.2.2,
> congratulations! 😄
>
> The bug is due to a change in the readdir extension that
> occurred with the 5.2.2 release. Here is a patch.
>
> Thanks,
>
> Arnold

LOL, thanks -- glad I could be of service! And thanks for your years of
gawk development; inspiring.

Cheers,
-J

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor