Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Oct 2011 17:37:27 +1100
From:      Peter Jeremy <peterjeremy@acm.org>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        standards@freebsd.org, current@freebsd.org
Subject:   Re: st_dev and st_ino for pipes
Message-ID:  <20111004063727.GA25129@server.vk2pj.dyndns.org>
In-Reply-To: <20111002220405.GN1511@deviant.kiev.zoral.com.ua>
References:  <20111002220405.GN1511@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

--opJtzjQTFsWo+cga
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 2011-Oct-03 01:04:05 +0300, Kostik Belousov <kostikbel@gmail.com> wrote:
>Our implementation of pipes does not provide useful values for st_dev
>and st_ino when stat(2) is done on an anonymous pipe. It was noted by the
=2E..
>Patch below implements the requirement, by the cost of the small overhead
>at the pipe creation time, and slightly bigger cost at the destruction.

Does it need to be so complex?  This information isn't needed by the
kernel and, to be "meaningful", all that is required is that the
(st_dev,st_ino) pair is unique within the system.  Given this,
wouldn't it be sufficient to fake up a st_dev and then just make
st_ino be a counter that starts from 0 and increments (atomically?) on
every new pipe?  No need to retain state or "free" anything when the
pipe is destroyed.  (If necessary, pick a new fake st_dev when st_ino
wraps).

>--- a/sys/kern/sys_pipe.c
>+++ b/sys/kern/sys_pipe.c
=2E..
>+static ino_t pipedev_ino;
=2E.
>+	ub->st_dev =3D pipedev_ino;

st_dev is a dev_t and hence pipedev_ino (which seems misnamed to me)
should probably be dev_t rather than ino_t

--=20
Peter Jeremy

--opJtzjQTFsWo+cga
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (FreeBSD)

iEYEARECAAYFAk6KqacACgkQ/opHv/APuIchwgCfWM+y8Qgms2jySC5B/5UEIvPK
StoAoJjtd8kZNS5qZasE0CLWMD1Z0eB+
=Y2N3
-----END PGP SIGNATURE-----

--opJtzjQTFsWo+cga--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111004063727.GA25129>