Skip to contentSkip to conversation

More better in mount(2)

DISCUSSION Daniel Phillips 2 participants 2 messages Jan 5, 2001 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 6 lines · Nathan Scott
Quoted 5 lines · Daniel Phillips

...
This filesystem mount option parsing code is completely ad hoc, and uses strtok which is horribly horribly broken. (Do man strtok and read the 'Bugs' section.)

Quoted 7 lines
Quoted 1 line

It would be worth thinking about how to do this better.

hmm ... can't claim I wrote this code, just looked at it. are you saying the kernel strtok is horribly broken or just the way its being used here? (and why?)

From the man page:

BUGS Never use this function. If you do, note that:
This function modifies its first argument.
The identity of the delimiting character is lost. This functions cannot be used on constant strings. The strtok () function uses a static buffer while parsing, so it's not thread safe. Use strtok_r () if this matters to
you.
--
Daniel
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
Quoted 9 lines · Daniel

[re strtok for mount option parsing]

BUGS Never use this function. If you do, note that:
This function modifies its first argument. The identity of the delimiting character is lost. This functions cannot be used on constant strings. The strtok() function uses a static buffer while parsing, so it's not thread safe. Use strtok_r() if this matters to you.

Luckily, when mount(8) is trying to mount a filesystem, it passes the mount options into the kernel each time, which does copy_from_user(), so the fact that strtok() breaks the data is OK. The only time this is bad is with Stephen's ext3 rootflags option...

Cheers, Andreas

Signature · 7 lines
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/