Dag-Erling Smorgrav wrote:

> Ben Smithurst <[EMAIL PROTECTED]> writes:
>> I was gonna commit a fix for this, but after reporting the problem DES
>> never tested the patch I supplied. :-(
> 
> I never got a patch.

Oh.  Well I'll leave you to figure out why the attached mail, which I
sent two weeks ago, didn't get to you then.

2001-06-23 20:26:28 15Dt36-000Kos-00 <= [EMAIL PROTECTED] 
H=strontium.shef.vinosystems.com [192.168.91.36] U=root P=esmtp S=4879 
[EMAIL PROTECTED] for [EMAIL PROTECTED] [EMAIL PROTECTED] 
[EMAIL PROTECTED]
2001-06-23 20:26:35 15Dt36-000Kos-00 => [EMAIL PROTECTED] R=lookuphost T=remote_smtp 
H=flood.ping.uio.no [129.240.78.31] C="250 VAA79059 Message accepted for delivery"

-- 
Ben Smithurst / [EMAIL PROTECTED]


ok, I think I agree with phk that excluding drives should be done in the
config file somehow, something like

!md
!acd
!cd

... hack hack hack ...

Could you test the attached patch?  It allows lines like the above in
diskcheckd.conf.  Seems to work but ref5 is the only current machine I
have access to which is a bit of a pain for testing things.

Stefan wrote...

>> 2) The defaults make diskcheckd read 4KB per transaction from my 
>>   system disk. I think I'd rather have it reading 64KB/t at a 
>>   rate of 1 per 16 seconds. (Perhaps 32KB is a better size, in
>>   order to not flush the drives cache, once per second ...)
>>
>>   Reading 16, 32 or 64KB at a time should (except for cache effects)
>>   cause minimally higher load per transaction than 4KB, and the 
>>   reduced transaction rate should drastically reduce the impact
>>   on the system.

This shouldn't be too hard to implement, I'll see what I can do.

-- 
Ben Smithurst / [EMAIL PROTECTED]
Index: diskcheckd.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/diskcheckd/diskcheckd.c,v
retrieving revision 1.1
diff -u -r1.1 diskcheckd.c
--- diskcheckd.c        2001/06/03 20:02:03     1.1
+++ diskcheckd.c        2001/06/23 19:18:37
@@ -62,7 +62,7 @@
 
 volatile sig_atomic_t got_sighup = 0, got_sigterm = 0;
 
-char **getdisknames(void);
+char **getdisknames(char **, int);
 off_t dseek(struct disk *, off_t, int);
 struct disk *readconf(const char *);
 void getdisksize(struct disk *);
@@ -464,6 +464,8 @@
        double dval;
        long lval;
        int linenum;
+       char **skip;
+       int numskip;
 
        if ((fp = fopen(conf_file, "r")) == NULL) {
                syslog(LOG_NOTICE, "open %s failure: %m", conf_file);
@@ -482,6 +484,37 @@
                        line++;
                if (*line == '#' || *line == '\n' || *line == '\0')
                        continue;
+
+               /* First, if the line starts with '!', this is a disk name
+                * to ignore.  For example, '!md' will skip all '/dev/md*'
+                * devices.
+                */
+               if (*line == '!') {
+                       line++;
+                       while (isspace(*line))
+                               line++;
+                       field = strsep(&line, " \t\n");
+                       if (field == NULL || *field == '\0') {
+                               syslog(LOG_NOTICE, "%s:%d: missing disk name",
+                                 conf_file, linenum);
+                               continue;
+                       }
+
+                       numskip++;
+                       if ((skip = reallocf(skip,
+                         numskip * sizeof (*skip))) == NULL) {
+                               syslog(LOG_NOTICE, "reallocf failure: %m");
+                               exit(EXIT_FAILURE);
+                       }
+
+                       if ((skip[numskip-1] = strdup(field)) == NULL) {
+                               syslog(LOG_NOTICE, "strdup failure: %m");
+                               exit(EXIT_FAILURE);
+                       }
+
+                       continue;
+               }
+
                fields = flags = 0;
                while ((field = strsep(&line, " \t\n")) != NULL) {
                        if (*field == '\0')
@@ -602,7 +635,7 @@
        onumdisks = numdisks;
        for (dp = disks; dp < disks + onumdisks; dp++) {
                if (strcmp(dp->device, "*") == 0) {
-                       for (np = np0 = getdisknames(); *np != NULL; np++) {
+                       for (np = np0 = getdisknames(skip, numskip); *np != NULL; 
+np++) {
                                odisks = disks;
                                if ((disks = reallocf(disks,
                                    (numdisks + 1) * sizeof (*disks))) == NULL) {
@@ -746,10 +779,11 @@
  * is returned.
  */
 char **
-getdisknames(void) {
+getdisknames(char **skip, int numskip) {
        char *string, *field;
        size_t size, numdisks;
        char **disks;
+       int i;
 
        if (sysctlbyname("kern.disks", NULL, &size, NULL, 0) != 0 &&
            errno != ENOMEM) {
@@ -768,6 +802,13 @@
        disks = NULL;
        numdisks = 0;
        while ((field = strsep(&string, " ")) != NULL) {
+               /* check for disks we ignore */
+               for (i = 0; i < numskip; i++)
+                       if (strncmp(field, skip[i], strlen(skip[i])) == 0)
+                               break;
+               if (i < numskip)
+                       continue;
+
                if ((disks = reallocf(disks,
                  (numdisks + 1) * sizeof (*disks))) == NULL) {
                        syslog(LOG_NOTICE, "reallocf failure: %m");


Reply via email to