On Wed, May 04, 2011 at 11:59:52PM -0400, Kenneth R Westerback wrote:
> And by using opendev(3) tunefs can accept disk UID's.
>
> Any actual tunefs(8) guru's out there who can explain what this
> might break?
>
> Inspired by oga@'s work on atactl.
millert already provided a diff for that, the the getpartition dance is
necessary if you want to be able to provide partition names from fstab
(say tunefs -N /home). This diff breaks that ability.
The diff is appended here for completeness (from millert, not me)
>
> This is the last use of opendisk(3) in the tree. Any reason to
> keep it if this goes in? ports?
I have no idea, but a porter should probably check the distfiles.
-0-
Index: tunefs.c
===================================================================
RCS file: /cvs/src/sbin/tunefs/tunefs.c,v
retrieving revision 1.30
diff -u -p -r1.30 tunefs.c
--- tunefs.c 27 Oct 2009 23:59:34 -0000 1.30
+++ tunefs.c 4 May 2011 18:30:33 -0000
@@ -71,7 +71,7 @@ static void bwrite(daddr64_t, char *, in
static void bread(daddr64_t, char *, int, const char *);
static int getnum(const char *, const char *, int, int);
static void getsb(struct fs *, const char *);
-static int openpartition(const char *, int, char *, size_t);
+static int openpartition(char *, int, char **);
static void usage(void);
int
@@ -79,8 +79,8 @@ main(int argc, char *argv[])
{
#define OPTSTRING "AFNe:g:h:m:o:"
int i, ch, Aflag, Fflag, Nflag, openflags;
- const char *special, *chg[2];
- char device[MAXPATHLEN];
+ char *special;
+ const char *chg[2];
int maxbpg, minfree, optim;
int avgfilesize, avgfpdir;
@@ -151,10 +151,8 @@ main(int argc, char *argv[])
openflags = Nflag ? O_RDONLY : O_RDWR;
if (Fflag)
fi = open(special, openflags);
- else {
- fi = openpartition(special, openflags, device, sizeof(device));
- special = device;
- }
+ else
+ fi = openpartition(special, openflags, &special);
if (fi == -1)
err(1, "%s", special);
getsb(&sblock, special);
@@ -319,11 +317,11 @@ bread(daddr64_t blk, char *buffer, int c
}
static int
-openpartition(const char *name, int flags, char *device, size_t devicelen)
+openpartition(char *name, int flags, char **devicep)
{
char rawspec[MAXPATHLEN], *p;
struct fstab *fs;
- int fd, oerrno;
+ int fd;
fs = getfsfile(name);
if (fs) {
@@ -334,11 +332,8 @@ openpartition(const char *name, int flag
} else
name = fs->fs_spec;
}
- fd = opendisk(name, flags, device, devicelen, 0);
- if (fd == -1 && errno == ENOENT) {
- oerrno = errno;
- strlcpy(device, name, devicelen);
- errno = oerrno;
- }
+ fd = opendev(name, flags, 0, devicep);
+ if (fd == -1 && errno == ENOENT)
+ devicep = &name;
return (fd);
}
--
I fell asleep reading a dull book, and I dreamt that I was reading on,
so I woke up from sheer boredom.