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

[MiNT] Harmless part of /kern



Hi,

there is one aspect of the /kern filesystem which would probably be widely
accepted (I hope so at least):

Every programmer knows that there are basically two ways to pass arguments
to a program: via the basepage command line or with the ARGV procedure.
Argument passing via the command line has several disadvantages, namely it
restricts the length of the argument vector to 124 bytes (mostly not
enough for something like "ls /usr/bin/*") and there is no clean way to
pass certain characters, notably space or tab.  The use of ARGV is more
flexible, you can pass all characters (except ASCII 0), the length of the
argument vector is only restricted by memory and you can also pass
zero-length arguments.  BTW, ARGV was already documented and recommended
by Atari in the GEMDOS days.

Parsing the argument vector is a little complicated, many special cases
and exceptions.  The code needed for parsing it is necessarily included in
every program linked against the MiNTLib and probably also in those that
are build in a Pure environment.

I wanted to have a file /kern/75/cmdline that output the argument vector
(for non-programmers: the command line you have started the program with,
for example "ls /usr/bin") and so I had to do this parsing job inside the
kernel.  This requires exactly 1508 bytes extra kernel space plus the
extra memory needed by the kernel to save the original command line for
each process (the actual length of the command line plus about 20 Bytes of
administrative stuff per process).

/kern/<PID>/cmdline was one idea behind this, the other was: As I
mentioned above, probably 99 % of all programs on your hard disk contain
the code to parse ARGV.  If they could simply enquire their argument
vector from the kernel that would save a lot of space and should
compensate for the extra kernel memory needed.  Of course most programs
will not rely on that new feature now but who knows for the future ...

Another positive side-effect: Low-level tools like ps or Paral would be
able to access the argument vector of every process without having to peek
into their environment (which can change) or without being restricted to
the first 124 bytes which are usually passed on the basepage command line
even if ARGV is used.

I would add a new ioctl on /proc (or an Ssystem opcode) to make this
information available no matter if /kern exists or not.  Anybody against
that?

BTW, no, this is not meant to start a new discussion, for information
only: The /kern filesystem currently makes the kernel 22 kB bigger. Some
things are still missing but there is also a lot of stuff which could be
optimized, a lot of code is duplicated because the internal design is not
really optimal.  At least 1.5 kB is consumed by some silly jokes. ;-)

Ciao

Guido
-- 
http://stud.uni-sb.de/~gufl0000/
mailto:guido@atari.org