From owner-freebsd-hackers@FreeBSD.ORG Wed Nov 23 11:23:08 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9F31416A41F for ; Wed, 23 Nov 2005 11:23:08 +0000 (GMT) (envelope-from asmrookie@gmail.com) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.194]) by mx1.FreeBSD.org (Postfix) with ESMTP id 31C6843D66 for ; Wed, 23 Nov 2005 11:23:08 +0000 (GMT) (envelope-from asmrookie@gmail.com) Received: by zproxy.gmail.com with SMTP id 9so182555nzo for ; Wed, 23 Nov 2005 03:23:07 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=o9kp3vWiQMjREgqc7/q+bSQJ2zOtC2ouXpK6KMkY6MPDDjIOCeCQEESzu0IZauC9ANeC6U9AtOTwgvG10hQWbq1L+vZ8a4XUbdb0LdcXhCUZ+DDtWBkhhrrp8lsNM7EOQzpOJIXAoV8jnnv6m+qaqgrP2FZXI7EiEy1liZSpkSM= Received: by 10.36.132.9 with SMTP id f9mr4726234nzd; Wed, 23 Nov 2005 03:23:07 -0800 (PST) Received: by 10.36.42.16 with HTTP; Wed, 23 Nov 2005 03:23:07 -0800 (PST) Message-ID: <3bbf2fe10511230323xafaea9cr@mail.gmail.com> Date: Wed, 23 Nov 2005 12:23:07 +0100 From: rookie To: Daniel Rudy In-Reply-To: <4383F0CA.2030609@pacbell.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4383F0CA.2030609@pacbell.net> Cc: freebsd-hackers@freebsd.org Subject: Re: getdirentries_args and other kernel syscall structures X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: rookie@gufi.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Nov 2005 11:23:09 -0000 2005/11/23, Daniel Rudy : > > Ok, I'va got a little question here. In the structure > getdirentries_args, there seems to be duplicated fields that I'm not > entirely sure what they do. Here's the definition of a structure > verbatim from sys/sysproto.h: > > struct getdirentries_args { > char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; > char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)= ]; > char count_l_[PADL_(u_int)]; u_int count; char > count_r_[PADR_(u_int)]; > char basep_l_[PADL_(long *)]; long * basep; char > basep_r_[PADR_(long *)]; > }; > > Now my question is what does the l and r variables do? It seems that > they do something with padding the data based on the endian of the > machine? I look through this header file, and I see all the structures > have similar constructs. Is it something that can be safely ignored It just pads in the right way (according with endianism) the structure to the right word. For example, x86 gots sizeof(long *) =3D=3D 4. If you want to have a syscall structure like that: struct example_sys { char f; short p; int g; }; it is misaligned. In order to get a proper padded structure (all 32 bits entries) to speed-up accesses to the members, this little trick is used. Attilio -- Peace can only be achieved by understanding - A. Einstein