Q's about IBM TSM (was Re: HEADSUP: ibcs2 and svr4 compatheaded
for history)
Per Kristian Hove
Per.Hove at math.ntnu.no
Wed Jun 30 07:18:26 PDT 2004
[Daniel O'Connor, 2004-06-30]
| On Wed, 30 Jun 2004 01:11, Paul Mather wrote:
| > having an empty or missing /compat/linux/etc/mtab file. Creating a
| > proper mtab file solves these problems. One way to do this is via
| > something like the following:
| >
| > sed 's/ufs/ext2/' < /etc/fstab > /compat/linux/etc/mtab
| >
| > That way, the Linux TSM "sees" your UFS partitions and will
| > backup/restore to them.
|
| I wonder if it could work with an LD_PRELOAD or some other linker trickery..
LD_PRELOADing ought to work. The attached file is an example library.
Compile with "gcc -o libmtab.so -shared -fpic libmtab.c" to test
(you'll probably have to add "-ldl" to compile it on Linux, if you
want to test TSM).
This is just a proof-of-concept; you'd probably want to substitue the
system() call with something sane, make sure you only s/ufs/ext2/ in
the third column, etc. Example:
# cat /etc/mtab
cat: /etc/mtab: No such file or directory
# export LD_PRELOAD=$PWD/libmtab.so
# cat /etc/mtab
/dev/ad0s1a / ext2 rw 1 1
/dev/ad0s1b none swap sw 0 0
/dev/ad0s1b /tmp mfs rw,-s=1046528 0 0
/dev/ad0s1e /var ext2 rw 1 2
/dev/ad0s1f /usr ext2 rw 1 2
/dev/acd0c /cdrom cd9660 ro,nosuid,nodev,noauto 0 0
/dev/ad0s2a /work ext2 rw 1 1
To be complete, the library should also work with relative pathnames.
Implementing that is left as an exercise for the reader. The example
library doesn't do that:
# cd /etc; cat mtab
cat: mtab: No such file or directory
--
Per Kristian Hove <Per.Hove at math.ntnu.no>
Chief engineer
Dept. of Mathematical Sciences
Norwegian University of Science and Technology
-------------- next part --------------
#include <stdio.h>
#include <dlfcn.h>
#include <string.h>
#include <limits.h>
#include <fcntl.h>
#ifndef RTLD_NEXT
#define RTLD_NEXT ((void *) -1l)
#endif
#define PATH_MTAB "/etc/mtab"
int open(const char *path, int oflag, ...) {
static int (*func) (const char *, int, ...);
int fd, fdfstab;
char tmpfile[] = "/tmp/mtab.XXXXXX";
char cmd[80];
if (!func)
func = (int (*) (const char *, int, ...)) dlsym (RTLD_NEXT, "open");
if (strcmp(path, PATH_MTAB))
return func(path, oflag, 0600);
if ((fd = mkstemp(tmpfile)) < 0) {
perror("libmtab.so: mkstemp:");
}
sprintf(cmd, "sed 's/ufs/ext2/' < /etc/fstab > %s", tmpfile);
system(cmd);
unlink(tmpfile);
return (fd);
}
More information about the freebsd-current
mailing list