Re: disklabel - 'P' option

2010-04-10 Thread Mark Lumsden

This diff includes the 'P' option in the manpage and interactive helptext.

The install floppys are here:

http://www.cyodesigns.com/diffs/floppy47.fs
http://www.cyodesigns.com/diffs/floppyB47.fs
http://www.cyodesigns.com/diffs/floppyC47.fs

If you take one for a spin, could you let me know pls. I have only 
tested floppyB47.fs on a vm since the my machine with a floppy drive is 
transit in a 40ft container somewhere.


-mark

Index: editor.c
===
RCS file: /cvs/src/sbin/disklabel/editor.c,v
retrieving revision 1.231
diff -u -p -r1.231 editor.c
--- editor.c4 Apr 2010 14:12:12 -   1.231
+++ editor.c9 Apr 2010 22:45:03 -
@@ -150,6 +150,7 @@ static u_int64_t starting_sector;
static u_int64_t ending_sector;
static int expert;
static int overlap;
+static int auto_print = 0;

/*
 * Simple partition editor.
@@ -164,7 +165,8 @@ editor(struct disklabel *lp, int f)
char buf[BUFSIZ], *cmd, *arg;
char **omountpoints = NULL;
char **origmountpoints = NULL, **tmpmountpoints = NULL;
-   int i, error = 0;
+   int i, error = 0, print_info = 0;
+   static char *argcpy;

/* Alloc and init mount point info */
if (!(omountpoints = calloc(MAXPARTITIONS, sizeof(char *))) ||
@@ -305,8 +307,19 @@ editor(struct disklabel *lp, int f)
editor_name(label, arg);
break;

+   case 'P':
+   free(argcpy);
+   argcpy = NULL;
+   if (arg) {
+   if ((argcpy = strdup(arg)) == NULL)
+   err(1, strdup);
+   auto_print = 1;
+   } else
+   auto_print = !auto_print;
+   break;
+
case 'p':
-   display_edit(label, arg ? *arg : 0, 
editor_countfree(label));
+   print_info = 1;
break;

case 'l':
@@ -475,6 +488,19 @@ editor(struct disklabel *lp, int f)
break;
}

+   if ((print_info || auto_print) 
+   (*cmd != 'h'  *cmd != '?')) {
+   if (auto_print) {
+   printf(-- \
+   --\n);
+   if (!print_info)
+   arg = argcpy;
+   }
+			display_edit(label, arg ? *arg : 0, 
+			editor_countfree(label));

+   print_info = 0;
+   }
+
/*
 * If no changes were made to label or mountpoints, then
 * restore undo info.
@@ -1734,6 +1760,11 @@ editor_help(char *arg)

/* XXX - put these strings in a table instead? */
switch (*arg) {
+   case 'P':
+   puts(
+The 'P' command will print disklabel information after every command.\n
+The information displayed and arguments accepted are equivalent to 'p'\n
+(see below).\n);
case 'p':
puts(
The 'p' command prints the current partitions.  By default, it prints size\n
@@ -1887,7 +1918,7 @@ editor_help(char *arg)
default:
puts(Available commands:);
puts(
-  ? [cmd]  - show help  n [part] - set mount point\n
+  ? [cmd]  - show help  P [unit] - always print partitions\n
  A- auto partition all space   p [unit] - print partitions\n
  a [part] - add partition  q- quit  save changes\n
  b- set OpenBSD boundaries R [part] - resize a partition\n
@@ -1899,6 +1930,7 @@ editor_help(char *arg)
  l [unit] - print disk label headerX- toggle expert mode\n
  M- disklabel(8) man page  x- exit  lose changes\n
  m [part] - modify partition   z- delete all partitions\n
+  n [part] - set mount point\n
\n
Suffixes can be used to indicate units other than sectors:\n
\t'b' (bytes), 'k' (kilobytes), 'm' (megabytes), 'g' (gigabytes)\n
Index: disklabel.8
===
RCS file: /cvs/src/sbin/disklabel/disklabel.8,v
retrieving revision 1.88
diff -u -p -r1.88 disklabel.8
--- disklabel.8 23 Mar 2010 18:43:06 -  1.88
+++ disklabel.8 9 Apr 2010 22:45:03 -
@@ -183,6 +183,8 @@ Disallow writing of the pack label area 
.It Fl n

Make no permanent changes to the disklabel
.Pq useful for debugging purposes .
+.It Fl P Ar unit
+Equivalent to 'p' (see below) but print information after every command.
.It Fl p Ar unit
Print partition sizes in
.Ar unit



Re: disklabel - 'P' option

2010-04-09 Thread Sean Kennedy
Meh, nothing like being an Inconsistent mad typist. . .
(I did learn on a Manual Typewriter... It was a Green Terminal, it worked
even if the power was out...)

I'd give a Yay to this variant. ( an Even Bigger Yay now it does  'p m'
even... )

-sean

 Date: Thu, 8 Apr 2010 10:03:27 +0200
 Subject: Re: disklabel - 'P' option
  'megabyte-able' printing more consistent to my liking.
 
  Attached is an amended diff that allows the 'P' option to take an
  argument just as the 'p' option does.
  That is the crux of the issue. For those of us who like to type less this
  diff helps, for you people who like type more... you're weird ;)
 
  Anyway, with only one yay, I don't think this will progress much further.
 I like this too, fwiw.
 Landry


_
Hotmail  Messenger are available on your phone. Try now.
http://go.microsoft.com/?linkid=9724461



Re: disklabel - 'P' option

2010-04-08 Thread Mark Lumsden

 When I use Disklabel, I have been in the habit of issuing 'p m enter'
 rather than just 'p enter'

 Since I do it for disk / usb thumb setups, and so forth, I find the
 'megabyte-able' printing more consistent to my liking.


Attached is an amended diff that allows the 'P' option to take an
argument just as the 'p' option does.

 I'd say leave it out, since CHS information may get scrolled off the
 screen if it was relevant. (Or am I thinking fdisk...?)
 As it is, both 'p' and 'm' keys have less wear than 'e' 't' and 's' and
 make for good finger dexterity...


That is the crux of the issue. For those of us who like to type less 
this diff helps, for you people who like type more... you're weird ;)


Anyway, with only one yay, I don't think this will progress much further.

-mark


Index: editor.c
===
RCS file: /cvs/src/sbin/disklabel/editor.c,v
retrieving revision 1.231
diff -u -p -r1.231 editor.c
--- editor.c4 Apr 2010 14:12:12 -1.231
+++ editor.c8 Apr 2010 07:03:35 -
@@ -150,6 +150,7 @@ static u_int64_t starting_sector;
static u_int64_t ending_sector;
static int expert;
static int overlap;
+static int auto_print = 0;

/*
* Simple partition editor.
@@ -164,7 +165,8 @@ editor(struct disklabel *lp, int f)
   char buf[BUFSIZ], *cmd, *arg;
   char **omountpoints = NULL;
   char **origmountpoints = NULL, **tmpmountpoints = NULL;
-int i, error = 0;
+int i, error = 0, print_info = 0;
+static char *argcpy;

   /* Alloc and init mount point info */
   if (!(omountpoints = calloc(MAXPARTITIONS, sizeof(char *))) ||
@@ -305,8 +307,19 @@ editor(struct disklabel *lp, int f)
   editor_name(label, arg);
   break;

+case 'P':
+free(argcpy);
+argcpy = NULL;
+if (arg) {
+if ((argcpy = strdup(arg)) == NULL)
+err(1, strdup);
+auto_print = 1;
+} else
+auto_print = !auto_print;
+break;
+
   case 'p':
-display_edit(label, arg ? *arg : 0, editor_countfree(label));
+print_info = 1;
   break;

   case 'l':
@@ -473,6 +486,17 @@ editor(struct disklabel *lp, int f)
   default:
   printf(Unknown option: %c ('?' for help)\n, *cmd);
   break;
+}
+
+if (print_info || auto_print) {
+if (auto_print) {
+printf(-- \
+--\n);
+if (!print_info)
+arg = argcpy;
+}
+display_edit(label, arg ? *arg : 0, editor_countfree(label));
+print_info = 0;
   }

   /*



Re: disklabel - 'P' option

2010-04-08 Thread Landry Breuil
On Thu, Apr 8, 2010 at 1:34 PM, Mark Lumsden m...@cyodesigns.com wrote:
 When I use Disklabel, I have been in the habit of issuing 'p m enter'
 rather than just 'p enter'

 Since I do it for disk / usb thumb setups, and so forth, I find the
 'megabyte-able' printing more consistent to my liking.


 Attached is an amended diff that allows the 'P' option to take an
 argument just as the 'p' option does.

 I'd say leave it out, since CHS information may get scrolled off the
 screen if it was relevant. (Or am I thinking fdisk...?)
 As it is, both 'p' and 'm' keys have less wear than 'e' 't' and 's' and
 make for good finger dexterity...


 That is the crux of the issue. For those of us who like to type less this
 diff helps, for you people who like type more... you're weird ;)

 Anyway, with only one yay, I don't think this will progress much further.

I like this too, fwiw.

Landry



disklabel - 'P' option

2010-04-07 Thread Mark Lumsden

I press 'p' then enter after everything I do in disklabel.

'P' automatically prints out the equivalent of 'p' after each command and saves 
on finger wear and tear.

like/dislike?

-mark

Index: editor.c
===
RCS file: /cvs/src/sbin/disklabel/editor.c,v
retrieving revision 1.231
diff -u -p -r1.231 editor.c
--- editor.c4 Apr 2010 14:12:12 -   1.231
+++ editor.c6 Apr 2010 06:06:14 -
@@ -150,6 +150,7 @@ static u_int64_t starting_sector;
static u_int64_t ending_sector;
static int expert;
static int overlap;
+static int print_mode = 0;

/*
* Simple partition editor.
@@ -164,7 +165,7 @@ editor(struct disklabel *lp, int f)
char buf[BUFSIZ], *cmd, *arg;
char **omountpoints = NULL;
char **origmountpoints = NULL, **tmpmountpoints = NULL;
-   int i, error = 0;
+   int i, error = 0, print_info;

/* Alloc and init mount point info */
if (!(omountpoints = calloc(MAXPARTITIONS, sizeof(char *))) ||
@@ -305,8 +306,12 @@ editor(struct disklabel *lp, int f)
editor_name(label, arg);
break;

+   case 'P':
+   print_mode = !print_mode;
+   break;
+
case 'p':
-   display_edit(label, arg ? *arg : 0, 
editor_countfree(label));
+   print_info = 1;
break;

case 'l':
@@ -475,6 +480,14 @@ editor(struct disklabel *lp, int f)
break;
}

+   if (print_info || print_mode) {
+   if (print_mode)
+   printf(-- \
+   --\n);
+   display_edit(label, arg ? *arg : 0, 
editor_countfree(label));
+   print_info = 0;
+   }
+
/*
 * If no changes were made to label or mountpoints, then
 * restore undo info.



Re: disklabel - 'P' option

2010-04-07 Thread LEVAI Daniel
On Wed, Apr 07, 2010 at 11:21:49AM +, Mark Lumsden wrote:
 I press 'p' then enter after everything I do in disklabel.
 
 'P' automatically prints out the equivalent of 'p' after each command and 
 saves on finger wear and tear.
 
 like/dislike?
Neat!


Dani

-- 
LIVAI Daniel
PGP key ID = 0x83B63A8F
Key fingerprint = DBEC C66B A47A DFA2 792D  650C C69B BE4C 83B6 3A8F



Re: disklabel - 'P' option

2010-04-07 Thread Stuart Henderson
On 2010/04/07 11:21, Mark Lumsden wrote:
 I press 'p' then enter after everything I do in disklabel.
 
 'P' automatically prints out the equivalent of 'p' after each command and 
 saves on finger wear and tear.
 
 like/dislike?

hmm..not sure. I might find it useful if it allowed setting the unit
too, but I doubt I'd remember it exists when actually using disklabel.

in any event, to be a complete diff it also needs

- helptext entry
- manpage entry

details of which install media have had a test-build would be useful too..



Re: disklabel - 'P' option

2010-04-07 Thread Sean Kennedy
When I use Disklabel, I have been in the habit of issuing 'p m enter'
rather than just 'p enter'

Since I do it for disk / usb thumb setups, and so forth, I find the
'megabyte-able' printing more consistent to my liking.

I'd say leave it out, since CHS information may get scrolled off the screen if
it was relevant. (Or am I thinking fdisk...?)
As it is, both 'p' and 'm' keys have less wear than 'e' 't' and 's' and make
for good finger dexterity...

-sean

 Date: Wed, 7 Apr 2010 13:41:25 +0100
 Subject: Re: disklabel - 'P' option

 On 2010/04/07 11:21, Mark Lumsden wrote:
  I press 'p' then enter after everything I do in disklabel.
  'P' automatically prints out the equivalent of 'p' after each command and
saves on finger wear and tear.
  like/dislike?

 hmm..not sure. I might find it useful if it allowed setting the unit
 too, but I doubt I'd remember it exists when actually using disklabel.


_
Live connected. Get Hotmail  Messenger on your phone.
http://go.microsoft.com/?linkid=9724462