if there are no strong objections, I'd like to commit
the following minor patch to bsdlabel (and associated bsdlabel.8
changes) to implement a '-f' option which enables bsdlabel to
work on an image file too.
With this, and ports/sysutils/makefs, we will be able to
build a bootable image entirely without root privileges,
which should be of some interests for a number of applications
cheers
luigi
--- bsdlabel.c Mon Mar 15 23:10:34 2004
+++ /usr/src/sbin/bsdlabel/bsdlabel.c Tue Mar 30 00:18:18 2004
@@ -139,7 +139,7 @@
static int disable_write; /* set to disable writing to disk label */
-
+static int is_file; /* work on a file (abs. pathname), "-f" opt. */
int
main(int argc, char *argv[])
{
@@ -147,7 +147,7 @@
int ch, error = 0;
char const *name = 0;
- while ((ch = getopt(argc, argv, "ABb:em:nRrs:w")) != -1)
+ while ((ch = getopt(argc, argv, "ABb:efm:nRrs:w")) != -1)
switch (ch) {
case 'A':
allfields = 1;
@@ -158,6 +158,9 @@
case 'b':
xxboot = optarg;
break;
+ case 'f':
+ is_file=1;
+ break;
case 'm':
if (!strcmp(optarg, "i386") ||
!strcmp(optarg, "amd64") ||
@@ -214,6 +217,8 @@
/* Figure out the names of the thing we're working on */
if (argv[0][0] != '/') {
+ if (is_file)
+ errx(1, "-f requires an absolute pathname");
dkname = argv[0];
asprintf(&specname, "%s%s", _PATH_DEV, argv[0]);
} else {
@@ -446,6 +441,10 @@
f = open(specname, O_RDONLY);
if (f < 0)
err(1, specname);
+ if (is_file) {
+ secsize = DEV_BSIZE;
+ mediasize = lseek(f, (off_t)0, SEEK_END);
+ } else
/* New world order */
if ((ioctl(f, DIOCGMEDIASIZE, &mediasize) != 0) ||
(ioctl(f, DIOCGSECTORSIZE, &secsize) != 0)) {
@@ -1329,6 +1328,10 @@
return (NULL);
}
+ if (is_file) {
+ secsize = DEV_BSIZE;
+ mediasize = lseek(f, (off_t)0, SEEK_END);
+ } else
/* New world order */
if ((ioctl(f, DIOCGMEDIASIZE, &mediasize) != 0) ||
(ioctl(f, DIOCGSECTORSIZE, &secsize) != 0)) {
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
> -------------------------------------------------------------------------- <
發信人: julian@elischer.org (Julian Elischer), 看板: FB_current
標 題: Re: proposed bsdlabel patch
發信站: NCTU CSIE FreeBSD Server (Tue Mar 30 00:45:26 2004)
轉信站: ptt!FreeBSD.csie.NCTU!not-for-mail
certainly sounds fine to me, except I'm almost willing to believe that
if the type of the target is "file" then it should just automatically do
it..
Why does it need an argument?
On Mon, 29 Mar 2004, Luigi Rizzo wrote:
> if there are no strong objections, I'd like to commit
> the following minor patch to bsdlabel (and associated bsdlabel.8
> changes) to implement a '-f' option which enables bsdlabel to
> work on an image file too.
>
> With this, and ports/sysutils/makefs, we will be able to
> build a bootable image entirely without root privileges,
> which should be of some interests for a number of applications
>
> cheers
> luigi
>
> --- bsdlabel.c Mon Mar 15 23:10:34 2004
> +++ /usr/src/sbin/bsdlabel/bsdlabel.c Tue Mar 30 00:18:18 2004
> @@ -139,7 +139,7 @@
>
>
> static int disable_write; /* set to disable writing to disk label */
> -
> +static int is_file; /* work on a file (abs. pathname), "-f" opt. */
> int
> main(int argc, char *argv[])
> {
> @@ -147,7 +147,7 @@
> int ch, error = 0;
> char const *name = 0;
>
> - while ((ch = getopt(argc, argv, "ABb:em:nRrs:w")) != -1)
> + while ((ch = getopt(argc, argv, "ABb:efm:nRrs:w")) != -1)
> switch (ch) {
> case 'A':
> allfields = 1;
> @@ -158,6 +158,9 @@
> case 'b':
> xxboot = optarg;
> break;
> + case 'f':
> + is_file=1;
> + break;
> case 'm':
> if (!strcmp(optarg, "i386") ||
> !strcmp(optarg, "amd64") ||
> @@ -214,6 +217,8 @@
>
> /* Figure out the names of the thing we're working on */
> if (argv[0][0] != '/') {
> + if (is_file)
> + errx(1, "-f requires an absolute pathname");
> dkname = argv[0];
> asprintf(&specname, "%s%s", _PATH_DEV, argv[0]);
> } else {
> @@ -446,6 +441,10 @@
> f = open(specname, O_RDONLY);
> if (f < 0)
> err(1, specname);
> + if (is_file) {
> + secsize = DEV_BSIZE;
> + mediasize = lseek(f, (off_t)0, SEEK_END);
> + } else
> /* New world order */
> if ((ioctl(f, DIOCGMEDIASIZE, &mediasize) != 0) ||
> (ioctl(f, DIOCGSECTORSIZE, &secsize) != 0)) {
> @@ -1329,6 +1328,10 @@
> return (NULL);
> }
>
> + if (is_file) {
> + secsize = DEV_BSIZE;
> + mediasize = lseek(f, (off_t)0, SEEK_END);
> + } else
> /* New world order */
> if ((ioctl(f, DIOCGMEDIASIZE, &mediasize) != 0) ||
> (ioctl(f, DIOCGSECTORSIZE, &secsize) != 0)) {
> _______________________________________________
> freebsd-current@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
>
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
> -------------------------------------------------------------------------- <
發信人: marcel@xcllnt.net (Marcel Moolenaar), 看板: FB_current
標 題: Re: proposed bsdlabel patch
發信站: NCTU CSIE FreeBSD Server (Tue Mar 30 00:46:04 2004)
轉信站: ptt!FreeBSD.csie.NCTU!not-for-mail
On Mon, Mar 29, 2004 at 04:39:26PM -0800, Luigi Rizzo wrote:
> if there are no strong objections, I'd like to commit
> the following minor patch to bsdlabel (and associated bsdlabel.8
> changes) to implement a '-f' option which enables bsdlabel to
> work on an image file too.
As Julian mentioned, why not use stat(2) and DTRT without options?
That also removes the gratuitous requirement that the filename has
to be an absolute path. See also the implementation of gpt(8)...
--
Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
> -------------------------------------------------------------------------- <
發信人: bde@zeta.org.au (Bruce Evans), 看板: FB_current
標 題: Re: proposed bsdlabel patch
發信站: NCTU CSIE FreeBSD Server (Tue Mar 30 04:09:03 2004)
轉信站: ptt!FreeBSD.csie.NCTU!not-for-mail
On Mon, 29 Mar 2004, Marcel Moolenaar wrote:
> On Mon, Mar 29, 2004 at 04:39:26PM -0800, Luigi Rizzo wrote:
> > if there are no strong objections, I'd like to commit
> > the following minor patch to bsdlabel (and associated bsdlabel.8
> > changes) to implement a '-f' option which enables bsdlabel to
> > work on an image file too.
>
> As Julian mentioned, why not use stat(2) and DTRT without options?
> That also removes the gratuitous requirement that the filename has
> to be an absolute path. See also the implementation of gpt(8)...
I suggested this too (for the RELENG_4 version). lseek to the end
is a very bad way to determine the size of a file, especially when
it is used without error checking.
Both versions also have lots of style bugs.
I also suggested using a shell script to generate a protofile or
disktab entry and only fixing actual bugs in disklabel. It is very
easy to generate a dummy label in text form using stat(1) to get the
file size, although not so easy to do the error checking corresponding
to what the implementation using lseek doesn't do (the script would
have to look at the file type and not operate except for files whose
size according to stat(1) is valid).
Here is a a simple version that works with my version of disklabel.
%%%
#!/bin/sh
# filelabel -- apply a simple disk label to a regular file.
secsize=512
secpertrack=1
trackpercyl=1
if test $# -ne 1
then
echo "usage filelabel file"
exit 1
fi
filename="$1"
if test ! -f "$filename"
then
echo "'$filename' doesn't exist or isn't a regular file"
exit 1
fi
# XXX: the file name must be absolute to work around bugs in disklabel.
# This is not checked for.
filesize=`/usr/bin/stat -f %z "$filename"`
secperunit=$(($filesize / $secsize))
cylperunit=$(($secperunit / $secpertrack / $trackpercyl))
echo "
#
# Minimal set of fields for my version of disklabel. Add/delete/modify
# fields as necessary.
#
bytes/sector: $secsize
sectors/track: $secpertrack
tracks/cylinder: $trackpercyl
sectors/unit: $secperunit
cylinders: $cylperunit
rpm: 7200
8 partitions:
c: $secperunit 0 unused 0 0
" |
disklabel -Rr "$filename" /dev/stdin
%%%
This requires minor fixes to disklabel to work in RELENG_4 (ignore
errors from some ioctls if ioctl() sets errno to ENOTTY). Unfortunately,
it is far from working with bsdlabel, since it depends critically on
-r and support for -r has been axed in bsdlabel.
Bruce
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
> -------------------------------------------------------------------------- <
發信人: rizzo@icir.org (Luigi Rizzo), 看板: FB_current
標 題: Re: proposed bsdlabel patch
發信站: NCTU CSIE FreeBSD Server (Tue Mar 30 06:29:12 2004)
轉信站: ptt!FreeBSD.csie.NCTU!not-for-mail
On Mon, Mar 29, 2004 at 04:50:13PM -0800, Marcel Moolenaar wrote:
> On Mon, Mar 29, 2004 at 04:39:26PM -0800, Luigi Rizzo wrote:
> > if there are no strong objections, I'd like to commit
> > the following minor patch to bsdlabel (and associated bsdlabel.8
> > changes) to implement a '-f' option which enables bsdlabel to
> > work on an image file too.
>
> As Julian mentioned, why not use stat(2) and DTRT without options?
> That also removes the gratuitous requirement that the filename has
> to be an absolute path. See also the implementation of gpt(8)...
sure, will do that, and take care of the style bugs as bruce
suggested (the original patch was voluntarily formatted in
a way to reduce the diffs).
thanks for the feedback
cheers
luigi
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
> -------------------------------------------------------------------------- <
發信人: rizzo@icir.org (Luigi Rizzo), 看板: FB_current
標 題: Re: proposed bsdlabel patch
發信站: NCTU CSIE FreeBSD Server (Tue Mar 30 07:39:47 2004)
轉信站: ptt!FreeBSD.csie.NCTU!not-for-mail
actually, following up to myself:
you do need some way to disambiguate between the case of a device
("bsdlabel ad0") and a file in the current directory ("bdslabel
ad0"). This is why i introduced '-f' in the first place, and I
think either that or requiring absolute pathnames for files cannot
go away. As to which one is preferrable i am neutral.
Note that there are several utilities which have the same
problem with ambiguous command line syntax.
cheers
luigi
On Mon, Mar 29, 2004 at 11:06:43PM -0800, Luigi Rizzo wrote:
> On Mon, Mar 29, 2004 at 04:50:13PM -0800, Marcel Moolenaar wrote:
> > On Mon, Mar 29, 2004 at 04:39:26PM -0800, Luigi Rizzo wrote:
> > > if there are no strong objections, I'd like to commit
> > > the following minor patch to bsdlabel (and associated bsdlabel.8
> > > changes) to implement a '-f' option which enables bsdlabel to
> > > work on an image file too.
> >
> > As Julian mentioned, why not use stat(2) and DTRT without options?
> > That also removes the gratuitous requirement that the filename has
> > to be an absolute path. See also the implementation of gpt(8)...
>
> sure, will do that, and take care of the style bugs as bruce
> suggested (the original patch was voluntarily formatted in
> a way to reduce the diffs).
>
> thanks for the feedback
> cheers
> luigi
> _______________________________________________
> freebsd-current@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
> -------------------------------------------------------------------------- <
發信人: marcel@xcllnt.net (Marcel Moolenaar), 看板: FB_current
標 題: Re: proposed bsdlabel patch
發信站: NCTU CSIE FreeBSD Server (Tue Mar 30 07:41:15 2004)
轉信站: ptt!FreeBSD.csie.NCTU!not-for-mail
On Mon, Mar 29, 2004 at 11:42:12PM -0800, Luigi Rizzo wrote:
> actually, following up to myself:
>
> you do need some way to disambiguate between the case of a device
> ("bsdlabel ad0") and a file in the current directory ("bdslabel
> ad0").
The file takes precedence, because any filename that does not contain
any directory elements is assumed to live in the current directory. The
shorthand for device special files is secundairy to that, because it's
a convenience only. If the device special file is meant, it has to be
specified as /dev/ad0 in the example given.
--
Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
> -------------------------------------------------------------------------- <
發信人: harti@freebsd.org (Hartmut Brandt), 看板: FB_current
標 題: Re: proposed bsdlabel patch
發信站: NCTU CSIE FreeBSD Server (Tue Mar 30 08:07:56 2004)
轉信站: ptt!FreeBSD.csie.NCTU!not-for-mail
Marcel Moolenaar wrote:
> On Mon, Mar 29, 2004 at 11:42:12PM -0800, Luigi Rizzo wrote:
>
>>actually, following up to myself:
>>
>>you do need some way to disambiguate between the case of a device
>>("bsdlabel ad0") and a file in the current directory ("bdslabel
>>ad0").
>
>
> The file takes precedence, because any filename that does not contain
> any directory elements is assumed to live in the current directory. The
> shorthand for device special files is secundairy to that, because it's
> a convenience only. If the device special file is meant, it has to be
> specified as /dev/ad0 in the example given.
>
That makes it very easy to trash a file in the current directory.
harti
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
> -------------------------------------------------------------------------- <
發信人: rizzo@icir.org (Luigi Rizzo), 看板: FB_current
標 題: Re: proposed bsdlabel patch
發信站: NCTU CSIE FreeBSD Server (Tue Mar 30 08:07:17 2004)
轉信站: ptt!FreeBSD.csie.NCTU!not-for-mail
On Tue, Mar 30, 2004 at 10:17:06AM +0200, Hartmut Brandt wrote:
> Marcel Moolenaar wrote:
....
> > The file takes precedence, because any filename that does not contain
> > any directory elements is assumed to live in the current directory. The
> > shorthand for device special files is secundairy to that, because it's
> > a convenience only. If the device special file is meant, it has to be
> > specified as /dev/ad0 in the example given.
it may be secondary, but it has been the historical behaviour for
ages and I don't want to hear people rightly screaming for a change
that broke a huge number of existing scripts.
> That makes it very easy to trash a file in the current directory.
that is a minor concern. "rm" has the same problem :)
cheers
luigi
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
> -------------------------------------------------------------------------- <
發信人: harti@freebsd.org (Hartmut Brandt), 看板: FB_current
標 題: Re: proposed bsdlabel patch
發信站: NCTU CSIE FreeBSD Server (Tue Mar 30 08:52:38 2004)
轉信站: ptt!FreeBSD.csie.NCTU!not-for-mail
Luigi Rizzo wrote:
> On Tue, Mar 30, 2004 at 10:17:06AM +0200, Hartmut Brandt wrote:
>
>>Marcel Moolenaar wrote:
>
> ...
>
>>>The file takes precedence, because any filename that does not contain
>>>any directory elements is assumed to live in the current directory. The
>>>shorthand for device special files is secundairy to that, because it's
>>>a convenience only. If the device special file is meant, it has to be
>>>specified as /dev/ad0 in the example given.
>
>
> it may be secondary, but it has been the historical behaviour for
> ages and I don't want to hear people rightly screaming for a change
> that broke a huge number of existing scripts.
>
>
>>That makes it very easy to trash a file in the current directory.
>
>
> that is a minor concern. "rm" has the same problem :)
Not really. rm has no magic that interpretes da0 as /dev/da0. If you
happen to have a file da0 in your current directory (let's say the saved
disklabel or so) and specify just da0 to disklabel expecting that it
will work on /dev/da0 it will unexpecedly clobber your file. Such
automatisms make things not easier, but more complex - you have to
remember them. You need to get the habit to do ls -l before you do
disklabel da0. I'd say keep the '-f' option, that'll make things clearer.
harti
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
> -------------------------------------------------------------------------- <
發信人: ru@FreeBSD.org (Ruslan Ermilov), 看板: FB_current
標 題: Re: proposed bsdlabel patch
發信站: NCTU CSIE FreeBSD Server (Tue Mar 30 10:47:52 2004)
轉信站: ptt!FreeBSD.csie.NCTU!not-for-mail
--0eh6TmSyL6TZE2Uz
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, Mar 30, 2004 at 11:06:41AM +0200, Hartmut Brandt wrote:
> Luigi Rizzo wrote:
> >On Tue, Mar 30, 2004 at 10:17:06AM +0200, Hartmut Brandt wrote:
> >
> >>Marcel Moolenaar wrote:
> >
> >...
> >
> >>>The file takes precedence, because any filename that does not contain
> >>>any directory elements is assumed to live in the current directory. The
> >>>shorthand for device special files is secundairy to that, because it's
> >>>a convenience only. If the device special file is meant, it has to be
> >>>specified as /dev/ad0 in the example given.
> >
> >
> >it may be secondary, but it has been the historical behaviour for
> >ages and I don't want to hear people rightly screaming for a change
> >that broke a huge number of existing scripts.
> >
> >
> >>That makes it very easy to trash a file in the current directory.
> >
> >
> >that is a minor concern. "rm" has the same problem :)
>=20
> Not really. rm has no magic that interpretes da0 as /dev/da0. If you
> happen to have a file da0 in your current directory (let's say the saved
> disklabel or so) and specify just da0 to disklabel expecting that it
> will work on /dev/da0 it will unexpecedly clobber your file. Such
> automatisms make things not easier, but more complex - you have to
> remember them. You need to get the habit to do ls -l before you do
> disklabel da0. I'd say keep the '-f' option, that'll make things clearer.
>=20
FWIW, fdisk(8), diskinfo(8), fsck_ffs(8) (and probably others)
prefer the file in the current directory to a /dev entry.
Cheers,
--=20
Ruslan Ermilov
ru@FreeBSD.org
FreeBSD committer
--0eh6TmSyL6TZE2Uz
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)
iD8DBQFAaVKBUkv4P6juNwoRAhxQAJ4265xTX5mCKp6FWqt74T2Iv4gwfgCeMnmr
BM3YRvnL3AgmhELif2jhqek=
=l2Bi
-----END PGP SIGNATURE-----
--0eh6TmSyL6TZE2Uz--
> -------------------------------------------------------------------------- <
發信人: bde@zeta.org.au (Bruce Evans), 看板: FB_current
標 題: Re: proposed bsdlabel patch
發信站: NCTU CSIE FreeBSD Server (Tue Mar 30 11:15:09 2004)
轉信站: ptt!FreeBSD.csie.NCTU!not-for-mail
On Tue, 30 Mar 2004, Marcel Moolenaar wrote:
> On Mon, Mar 29, 2004 at 11:42:12PM -0800, Luigi Rizzo wrote:
> > actually, following up to myself:
> >
> > you do need some way to disambiguate between the case of a device
> > ("bsdlabel ad0") and a file in the current directory ("bdslabel
> > ad0").
The absolute path hack is a bad way to do this. It depends on the
historical brokenness of adding a /dev prefix to the pathname unless
the pathname begins with a leading slash.
> The file takes precedence, because any filename that does not contain
> any directory elements is assumed to live in the current directory. The
So should any pathname that doesn't contain a leading slash (e.g., ./foo,
or foo/bar).
> shorthand for device special files is secundairy to that, because it's
> a convenience only. If the device special file is meant, it has to be
> specified as /dev/ad0 in the example given.
Unfortunately, disklabel never worked like that, and bsdlabel inherited
most of disklabel's bugs and added more.
%%%
Script started on Tue Mar 30 21:37:05 2004
ttyp0:bde@besplex:/tmp> touch foo
ttyp0:bde@besplex:/tmp> bsdlabel foo
bsdlabel: /dev/foo: No such file or directory
ttyp0:bde@besplex:/tmp> bsdlabel ./foo
bsdlabel: /dev/./foo: No such file or directory
ttyp0:bde@besplex:/tmp> exit
Script done on Tue Mar 30 21:37:17 2004
%%%
Bruce
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
> -------------------------------------------------------------------------- <
發信人: rizzo@icir.org (Luigi Rizzo), 看板: FB_current
標 題: Re: proposed bsdlabel patch
發信站: NCTU CSIE FreeBSD Server (Tue Mar 30 12:07:39 2004)
轉信站: ptt!FreeBSD.csie.NCTU!not-for-mail
On Tue, Mar 30, 2004 at 09:38:18PM +1000, Bruce Evans wrote:
....
> > > you do need some way to disambiguate between the case of a device
> > > ("bsdlabel ad0") and a file in the current directory ("bdslabel
> > > ad0").
>
> The absolute path hack is a bad way to do this. It depends on the
> historical brokenness of adding a /dev prefix to the pathname unless
> the pathname begins with a leading slash.
Bruce, i understand that we live in a broken and inconsistent world
with pollution, war, injustice all over the place. But I am just
trying to add a trivial feature to the version of bsdlabel in
FreeBSD-current in a way that does not upset the vast majority of
its user and does not require fixing the world's brokenness or using
"your version of disklabel". I understand your point and your
comments in this and other related threads, but other than as a
statement of principles it is difficult to make any practical use
of them, sorry!
cheers
luigi
> > The file takes precedence, because any filename that does not contain
> > any directory elements is assumed to live in the current directory. The
>
> So should any pathname that doesn't contain a leading slash (e.g., ./foo,
> or foo/bar).
>
> > shorthand for device special files is secundairy to that, because it's
> > a convenience only. If the device special file is meant, it has to be
> > specified as /dev/ad0 in the example given.
>
> Unfortunately, disklabel never worked like that, and bsdlabel inherited
> most of disklabel's bugs and added more.
>
> %%%
> Script started on Tue Mar 30 21:37:05 2004
> ttyp0:bde@besplex:/tmp> touch foo
> ttyp0:bde@besplex:/tmp> bsdlabel foo
> bsdlabel: /dev/foo: No such file or directory
> ttyp0:bde@besplex:/tmp> bsdlabel ./foo
> bsdlabel: /dev/./foo: No such file or directory
> ttyp0:bde@besplex:/tmp> exit
>
> Script done on Tue Mar 30 21:37:17 2004
> %%%
>
> Bruce
> _______________________________________________
> freebsd-current@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
> -------------------------------------------------------------------------- <
發信人: bde@zeta.org.au (Bruce Evans), 看板: FB_current
標 題: Re: proposed bsdlabel patch
發信站: NCTU CSIE FreeBSD Server (Tue Mar 30 12:27:54 2004)
轉信站: ptt!FreeBSD.csie.NCTU!not-for-mail
On Tue, 30 Mar 2004, Ruslan Ermilov wrote:
> On Tue, Mar 30, 2004 at 11:06:41AM +0200, Hartmut Brandt wrote:
> > Not really. rm has no magic that interpretes da0 as /dev/da0. If you
> > happen to have a file da0 in your current directory (let's say the saved
> > disklabel or so) and specify just da0 to disklabel expecting that it
> > will work on /dev/da0 it will unexpecedly clobber your file. Such
> > automatisms make things not easier, but more complex - you have to
> > remember them. You need to get the habit to do ls -l before you do
> > disklabel da0. I'd say keep the '-f' option, that'll make things clearer.
I agree. The conversions are hard to remember and different for almost
every utility that perpetrates them. I never have problems with this
though. Clobbering real disks is easy enough that I usually do much
more than ls to check that I'm writing to the disk that I want.
> FWIW, fdisk(8), diskinfo(8), fsck_ffs(8) (and probably others)
> prefer the file in the current directory to a /dev entry.
The misbehaviour of fsck_ffs is actually more complicated:
- In 4.4BSD (where fsck_ffs was plain fsck), fsck actually operated
on the specified pathname.
- Merging NetBSD's fsck driver gave some or all of the following
conversions:
--- The driver part (fsck) adds a /dev prefix if the specified pathname
doesn't contain _any_ slashes, so ./foo works right, unlike for
bsdlabel.
--- The fsck_ffs part starts by adding a /dev prefix under the same
condition as fsck, so ./foo (almost) works right.
--- If fsck_fsck can't stat the file under its (possibly) converted
pathname, then it (fsck_ffs) prints a message and continues with the
specified pathname. This causes various misbehaviours, e.g.,
duplicate error messages.
Bruce
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"