[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: some more JOBS



On Fri, Aug 10, 2001 at 10:29:15AM +0530, Nikunj A. Dadhania wrote:
> Marcus Brinkmann <Marcus.Brinkmann@ruhr-uni-bochum.de> writes:
> > On Thu, Aug 09, 2001 at 04:26:30PM +0530, Nikunj A. Dadhania wrote:
> > > can i make changes in /include/bits/types.h to make stat work...
> > > if yes then i will send the patch.
> > 
> > Most certainly not, but sometimes yes.  You need to explain to us which
> > changes you want to make and, more important, why.  In other words, what is
> > missing in that file, and how is this used in the application?
> 
> There is a member of stat structure fsid. its declared as
>    typedef __u_quad_t __fsid_t;	/* Type of file system IDs.  */

The program stat has two issues:

1. It accesses internal symbols of glibc (__var).  Everything beginning with
two underscores is "strictly forbidden" if you want to follow the book.
More so, there is absolutely no need to access those symbols.  As the GNU
version of st_fsid shows, the special definition of the fsid type is
purely a technical implementation issue to make the variable occupy a
certain number of bytes in some special way.  Applications should be
completely unaware of this.

stat should be changed to simply access st_fsid (not __val at all), and
print it out as a long long.  For this you need to reformat the format
specifiers a bit (%-16Lx for example, etc)

2. In fs.h, you will find a list of fs identifiers.  Why stat doesn't
include some Linux header file for this is an interesting question.  Maybe
because of the fact that those definitions are spread over many files.
You will need to put them in #ifdef __linux__, and use the Hurd's
identifiers on GNU, like this:

fs.h:

#if defined(__linux__)
/* define the magic numbers as given by statfs(2) */
/* please send additions to meskes@debian.org     */

#define AFFS_SUPER_MAGIC      0xADFF
...
#define NTFS_SUPER_MAGIC      0x5346544e
#elif defined(__GNU__)
#include <hurd/hurd_types.h>
#endif

The header file hurd/hurd_types.h contains a lot of symbols of the form
FSTYPE_UFS etc.  In stat.c, the code should look like:

        switch (statfsbuf.f_type) {
#if defined(__linux__)
                case AFFS_SUPER_MAGIC:
...
                case NTFS_SUPER_MAGIC:
                        printf("NTFS\n");
                        break;
#elif defined(__GNU__)
		case FSTYPE_EXT2FS:
		 	printf("EXT2\n");
			break;
...
#endif

You should list all filesystem types in hurd/hurd_types.h.  In fact, this
could easily be scripted and the code automatically generated, but cut&paste
is also ok.  I suggest to simply use the XXX in FSTYPE_XXX for the string to
print.

Thanks,
Marcus

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org brinkmd@debian.org
Marcus Brinkmann              GNU    http://www.gnu.org    marcus@gnu.org
Marcus.Brinkmann@ruhr-uni-bochum.de
http://www.marcus-brinkmann.de



Reply to: