Re: Add support for rdonly keyword in fstab

2017-06-15 Thread Jérôme FRGACIC

On Wed, 14 Jun 2017 12:49:19 -0700, Klemens Nanni wrote:

fstab(5) has always used ro/rw for this exclusively, which is sufficient
enough imho.


I dare say mount(8) actually has too many ways to say the same thing:
-r
-o ro
-r norw
-o rdonly

How about removing some of those?


I think you're right, that's sound better. ;)



Add support for rdonly keyword in fstab

2017-06-14 Thread Jérôme FRGACIC

Hi @tech,

I recently realized that the word "rdonly" is not an alias for "ro" in 
the fstab file, which is inconsistent with the mount(1) command. I would 
suggest to add support for it with this small patch.


Index: fstab.c
===
RCS file: /cvs/src/lib/libc/gen/fstab.c,v
retrieving revision 1.22
diff -u -p -u -r1.22 fstab.c
--- fstab.c 17 Mar 2016 23:48:42 -  1.22
+++ fstab.c 14 Jun 2017 17:53:24 -
@@ -116,8 +116,6 @@ fstabscan(void)
strlcpy(subline, _fs_fstab.fs_mntops, sizeof subline);
for (typexx = 0, cp = strtok_r(subline, ",", ); cp;
 cp = strtok_r(NULL, ",", )) {
-   if (strlen(cp) != 2)
-   continue;
if (!strcmp(cp, FSTAB_RW)) {
_fs_fstab.fs_type = FSTAB_RW;
break;
@@ -127,6 +125,10 @@ fstabscan(void)
break;
}
if (!strcmp(cp, FSTAB_RO)) {
+   _fs_fstab.fs_type = FSTAB_RO;
+   break;
+   }
+   if (!strcmp(cp, FSTAB_RDONLY)) {
_fs_fstab.fs_type = FSTAB_RO;
break;
        }


Kind regards,


Jérôme FRGACIC



ed(1) doesn't support adress ranges which begin with comma or semicolon

2016-12-24 Thread Jérôme FRGACIC
Hi @tech,

I remark that ed(1) do not support adress ranges which begin with
comma or semicolon, for example ",10p" which is equivalent to "1,10p" or
"; +10p" which is equivalent to ".;+10p". These adress ranges are
specified by Open Group Base Specifications Issue 6 (IEEE Std 1003.1,
2004 Edition) (in fact, there are also adress ranges like "10," which
is equivalent to "10,10" but they seem useless to me...).

I would suggest this diff to add support for these adress ranges.

Index: main.c
===
RCS file: /cvs/src/bin/ed/main.c,v
retrieving revision 1.58
diff -u -r1.58 main.c
--- main.c  16 Aug 2016 20:04:46 -  1.58
+++ main.c  24 Dec 2016 15:26:41 -
@@ -383,7 +383,9 @@
ibufp++;
addr_cnt++;
second_addr = (c == ';') ?
current_addr : 1;
-   addr = addr_last;
+   addr = next_addr();
+   if (addr < 0)
+   addr = addr_last;
break;
}
/* FALLTHROUGH */

PS : I haven't subcribe to the tech mailing list, so please add me as
recipient if you reply.
PPS : Merry Christmas.


Kind regards,


Jérôme FRGACIC



Modify disklabel(8) manual about possible units

2016-12-07 Thread Jérôme FRGACIC
Hello tech,

While reading disklabel(8) man page I remark that the two possibles
units '%' (percent of total) and '&' (percent of free) are only
mentioned in the description of the 'p' option but not in the section
which list available units.

I would suggest to move the '%' and '&' units description in the later
section.

Index: disklabel.8
===
RCS file: /cvs/src/sbin/disklabel/disklabel.8,v
retrieving revision 1.120
diff -u -r1.120 disklabel.8
--- disklabel.8 3 Dec 2016 07:34:39 -   1.120
+++ disklabel.8 7 Dec 2016 16:32:06 -
@@ -157,11 +157,6 @@
 instead of sectors.
 Valid units are b(ytes), c(ylinders), k(ilobytes), m(egabytes), g
(igabytes) and t(erabytes).
-For operations other than displaying a partition the
-.Ql %
-(percent of total) and
-.Ql &
-(percent of free) units are also accepted.
 .It Fl R
 Restore a disk label that was formatted in a prior operation and
 saved in an
@@ -265,9 +260,13 @@
 for megabytes,
 .Sq g
 for gigabytes,
-and
 .Sq t
-for terabytes.
+for terabytes,
+.Ql %
+for a percent of total
+and
+.Ql &
+for a percent of free.
 If no unit is given, the default is to use sectors
 (usually 512 bytes).
 Quantities will be rounded to the nearest

PS : I haven't subcribe to the tech mailing list, so please add me as
recipient if you reply.

Kind regards,


Jérôme FRGACIC



ed(1) exit without saving if output file is a command

2016-08-15 Thread Jérôme FRGACIC
Hello tech,

I recently use ed(1) to transmit some input lines to another command.
However, I remark that after the 'w' command, I can exit ed without any
warnings even if the data were not saved into a file.

Here is an example :

$ ed
P
*a
A simple line.
.
*w !sed 's/^/#/'
#A simple line.
15
*q
$ # No warning before exit

This behaviour seems not conform to the Open Group Base Specifications
Issue 6 (IEEE Std 1003.1, 2004 Edition). I would suggest this diff to
solve this problem.

Index: main.c
===
RCS file: /cvs/src/bin/ed/main.c,v
retrieving revision 1.57
diff -r1.57 main.c
862c862
<   else if (addr == addr_last)
---
>   else if (addr == addr_last && *fnp != '!')


PS : I haven't subcribe to the tech mailing list, so please add me as
recipient if you reply.


Kind regards,


Jérôme FRGACIC



apmd: add on demand adjustement mode

2015-03-02 Thread Jérôme Frgacic
Hello,

At present, there is no middle between cool running and automatic adjustement 
mode.
I would suggest to add an on demand adjustement mode which set hw.setperf to
maximum when CPU idle is lesser then 10% and reduce it when CPU idle is greater 
than
30%. Also, when hw.setperf is at maximum, verification of CPU idle is slow down.

This is based on a previous suggestion of Laurence Tratt.

PS : please add me to recepient if you reply.

Index: apm-proto.h
===
RCS file: /cvs/src/usr.sbin/apmd/apm-proto.h,v
retrieving revision 1.9
diff -u -p -r1.9 apm-proto.h
--- apm-proto.h 26 Mar 2012 20:17:45 -  1.9
+++ apm-proto.h 2 Mar 2015 14:56:34 -
@@ -38,6 +38,7 @@ enum apm_action {
SETPERF_LOW,
SETPERF_HIGH,
SETPERF_AUTO,
+   SETPERF_ONDEMAND,
SETPERF_COOL
 };
 
@@ -52,6 +53,7 @@ enum apm_perfmode {
PERF_NONE = -1,
PERF_MANUAL,
PERF_AUTO,
+   PERF_ONDEMAND,
PERF_COOL
 };
 
Index: apmd.8
===
RCS file: /cvs/src/usr.sbin/apmd/apmd.8,v
retrieving revision 1.44
diff -u -p -r1.44 apmd.8
--- apmd.8  24 Jul 2014 01:04:58 -  1.44
+++ apmd.8  2 Mar 2015 14:56:34 -
@@ -77,6 +77,16 @@ level is low.
 BIOS-initiated suspend or standby requests are
 ignored if the system is connected to line current and not running from
 batteries (user requests are still honored).
+.It Fl O
+Start
+.Nm
+in on demand performance adjustement mode.
+Set
+.Va hw.setperf
+to maximum when CPU idle is lesser than 90%, reduce it if CPU idle is
+greater than 30%. When
+.Va hw.setperf
+is at maximum, verification of CPU idle is ten times slower.
 .It Fl C
 Start
 .Nm

Index: apmd.c
===
RCS file: /cvs/src/usr.sbin/apmd/apmd.c,v
retrieving revision 1.65
diff -u -p -r1.65 apmd.c
--- apmd.c  26 Jul 2014 10:48:59 -  1.65
+++ apmd.c  2 Mar 2015 14:56:34 -
@@ -76,7 +76,7 @@ int bind_socket(const char *sn);
 enum apm_state handle_client(int sock_fd, int ctl_fd);
 int  get_avg_idle_mp(int ncpu);
 int  get_avg_idle_up(void);
-void perf_status(struct apm_power_info *pinfo, int ncpu);
+long perf_status(struct apm_power_info *pinfo, int ncpu);
 void suspend(int ctl_fd);
 void stand_by(int ctl_fd);
 void hibernate(int ctl_fd);
@@ -301,13 +301,14 @@ get_avg_idle_up(void)
return avg_idle;
 }
 
-void
+long
 perf_status(struct apm_power_info *pinfo, int ncpu)
 {
int avg_idle;
int hw_perf_mib[] = {CTL_HW, HW_SETPERF};
int perf;
int forcehi = 0;
+   long timeout = 1;
size_t perf_sz = sizeof(perf);
 
if (ncpu  1) {
@@ -330,6 +331,7 @@ perf_status(struct apm_power_info *pinfo
pinfo-battery_state == APM_BATTERY_ABSENT)
forcehi = 1;
break;
+   case PERF_ONDEMAND:
case PERF_COOL:
forcehi = 0;
break;
@@ -339,9 +341,13 @@ perf_status(struct apm_power_info *pinfo
syslog(LOG_INFO, cannot read hw.setperf);
 
if (forcehi || (avg_idle  PERFINCTHRES  perf  PERFMAX)) {
-   perf += PERFINC;
-   if (perf  PERFMAX)
+   if (doperf == PERF_ONDEMAND) {
perf = PERFMAX;
+   } else {
+   perf += PERFINC;
+   if (perf  PERFMAX)
+   perf = PERFMAX;
+   }
setperf(perf);
} else if (avg_idle  PERFDECTHRES  perf  PERFMIN) {
perf -= PERFDEC;
@@ -349,6 +355,13 @@ perf_status(struct apm_power_info *pinfo
perf = PERFMIN;
setperf(perf);
}
+   if (doperf == PERF_ONDEMAND) {
+   if (perf == PERFMAX)
+   timeout = 9;
+   else
+   timeout = 1;
+   }
+   return timeout;
 }
 
 char socketname[MAXPATHLEN];
@@ -452,6 +465,11 @@ handle_client(int sock_fd, int ctl_fd)
reply.newstate = NORMAL;
syslog(LOG_NOTICE, setting hw.setperf automatically);
break;
+   case SETPERF_ONDEMAND:
+   doperf = PERF_ONDEMAND;
+   reply.newstate = NORMAL;
+   syslog(LOG_NOTICE, setting hw.setperf on demand);
+   break;
case SETPERF_COOL:
doperf = PERF_COOL;
reply.newstate = NORMAL;
@@ -525,7 +543,7 @@ main(int argc, char *argv[])
int ncpu;
size_t ncpu_sz = sizeof(ncpu);
 
-   while ((ch = getopt(argc, argv, aACdHLsf:t:S:)) != -1)
+   while ((ch = getopt(argc, argv, aAOCdHLsf:t:S:)) != -1)
switch(ch) {
case 'a':
noacsleep = 1;
@@ -552,6 +570,11 @@ main(int argc, char *argv[])