9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: yaroslav <yarikos@gmail.com>
To: 9fans@9fans.net
Subject: Re: [9fans] device names in venti conf
Date: Fri, 13 Sep 2013 14:57:46 +0300	[thread overview]
Message-ID: <6133f8948eb96c712736c7c15b341a2c@isd.dp.ua> (raw)

[-- Attachment #1: Type: text/plain, Size: 358 bytes --]

> Can we avoid explicit device names in venti conf? Changes in device
> names on new hardware cause unnecessary delays during FS recovery.

One of available options is to modify venti so it prepends the
non-rooted partitions with the same prefix as the config file has.
/dev/sdC0/arenas may then have a config wired in with entries
like"isect isect".

[-- Attachment #2: config.c.diff --]
[-- Type: text/plain, Size: 2768 bytes --]

/n/sources/plan9/sys/src/cmd/venti/srv/config.c:44,49 - /sys/src/cmd/venti/srv/config.c:44,55
  	return 0;
  }

+ static int
+ isrooted(char* s)
+ {
+ 	return *s == '/' || *s == '#';
+ }
+
  /*
   * configs	:
   *		| configs config
/n/sources/plan9/sys/src/cmd/venti/srv/config.c:69,75 - /sys/src/cmd/venti/srv/config.c:75,81
  	ArenaPart **av;
  	ISect **sv;
  	IFile f;
- 	char *s, *line, *flds[MaxArgs + 1];
+ 	char *s, *p, *q, *line, *flds[MaxArgs + 1];
  	int i, ok;

  	if(readifile(&f, file) < 0)
/n/sources/plan9/sys/src/cmd/venti/srv/config.c:78,83 - /sys/src/cmd/venti/srv/config.c:84,98
  	config->mem = Unspecified;
  	ok = -1;
  	line = nil;
+
+ 	/* conf basename as default prefix for partitions */
+ 	p = estrdup(file);
+ 	s = strrchr(p, '/');
+ 	if(s)
+ 		*s = 0;
+ 	else
+ 		*p = 0;
+
  	for(;;){
  		s = ifileline(&f);
  		if(s == nil){
/n/sources/plan9/sys/src/cmd/venti/srv/config.c:92,98 - /sys/src/cmd/venti/srv/config.c:107,118
  				sv[i] = config->sects[i];
  			free(config->sects);
  			config->sects = sv;
- 			config->sects[config->nsects] = configisect(flds[1]);
+ 			if(!isrooted(flds[1])){
+ 				q = smprint("%s/%s", p, flds[1]);
+ 				config->sects[config->nsects] = configisect(q);
+ 				free(q);
+ 			}else
+ 				config->sects[config->nsects] = configisect(flds[1]);
  			if(config->sects[config->nsects] == nil)
  				break;
  			config->nsects++;
/n/sources/plan9/sys/src/cmd/venti/srv/config.c:102,108 - /sys/src/cmd/venti/srv/config.c:122,133
  				av[i] = config->aparts[i];
  			free(config->aparts);
  			config->aparts = av;
- 			config->aparts[config->naparts] = configarenas(flds[1]);
+ 			if(!isrooted(flds[1])){
+ 				q = smprint("%s/%s", p, flds[1]);
+ 				config->aparts[config->naparts] = configarenas(q);
+ 				free(q);
+ 			}else
+ 				config->aparts[config->naparts] = configarenas(flds[1]);
  			if(config->aparts[config->naparts] == nil)
  				break;
  			config->naparts++;
/n/sources/plan9/sys/src/cmd/venti/srv/config.c:111,117 - /sys/src/cmd/venti/srv/config.c:136,148
  				seterr(EAdmin, "duplicate bloom lines in configuration file %s", file);
  				break;
  			}
- 			if((config->bloom = configbloom(flds[1])) == nil)
+ 			if(!isrooted(flds[1])){
+ 				q = smprint("%s/%s", p, flds[1]);
+ 				config->bloom = configbloom(q);
+ 				free(q);
+ 			}else
+ 				config->bloom = configbloom(flds[1]);
+ 			if(config->bloom == nil)
  				break;
  		}else if(i == 2 && strcmp(flds[0], "index") == 0){
  			if(nameok(flds[1]) < 0){
/n/sources/plan9/sys/src/cmd/venti/srv/config.c:183,188 - /sys/src/cmd/venti/srv/config.c:214,220
  		free(line);
  		line = nil;
  	}
+ 	free(p);
  	free(line);
  	freeifile(&f);
  	if(ok < 0){

             reply	other threads:[~2013-09-13 11:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-13 11:57 yaroslav [this message]
2014-04-04  9:28 ` Yaroslav
  -- strict thread matches above, loose matches on Subject: below --
2013-09-12  7:39 Yaroslav

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6133f8948eb96c712736c7c15b341a2c@isd.dp.ua \
    --to=yarikos@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).