QNX4 mountimg

I would like to mount file (stored in DOS file system) as QNX file system
(using mountimg).



This is the problem I encounter:

If I format CF card in this way:

  • no partition table (as large floppy disc)

  • dos file system



    I am unable to mount the file. I tried these commands (also with error
    messages)

mountimg -t 6.77 -m /disk /dev/ata0:file.qfs … Mountimg: ‘/dev/ata0’ is
not a local device

mountimg -t 6 -m /disk /dev/ata0:file.qfs … Mountimg: ‘/dev/ata0’ is not
a local device

mountimg -t 77 -m /disk /dev/ata0:file.qfs … Mountimg: ‘/dev/ata0’ is not
a local device

mountimg -m /disk /dev/ata0:file.qfs … Mountimg: ‘/dev/ata0’ is not a
local device



But at the same time I am able to start succesfully Fatfsys as follow:

Fatfsys /dos/c=/dev/ata0



Any ideas?



Thanks, Pavol Kycina

Pavol Kycina wrote:

mountimg -m /disk /dev/ata0:file.qfs … Mountimg: ‘/dev/ata0’ is not a
local device

Try specifying the device/file as “//0/dev/ata0:file.qfs” …

Great!!!

Now it works (with //0/dev…)

Thanks, Pavol Kycina

“John Garvey” <jgarvey@qnx.com> wrote in message
news:dhcf8b$e6p$1@inn.qnx.com

Pavol Kycina wrote:
mountimg -m /disk /dev/ata0:file.qfs … Mountimg: ‘/dev/ata0’ is not a
local device

Try specifying the device/file as “//0/dev/ata0:file.qfs” …

“John Garvey” <jgarvey@qnx.com> wrote in message
news:dhcf8b$e6p$1@inn.qnx.com

Pavol Kycina wrote:
mountimg -m /disk /dev/ata0:file.qfs … Mountimg: ‘/dev/ata0’ is not a
local device

Try specifying the device/file as “//0/dev/ata0:file.qfs” …

I have one more problem:

I can’t mount “file” as file system, if the file is stored in ram disk.
(storing the file in ram disk seems to me the easiest way to make the file
contiguos)

Preparation:
dinit /dev/ram
mount /dev/ram /ram
cp /file.qfs /ram

First attempt:
mountimg -m/disk /ram/file.qfs
mountimg: unable to auto-generate ext-partition name

Second attempt (more serious … Fsys manager SIGSEGVed):
mountimg -t77 -m/disk /ram/file.qfs
/bin/Fsys terminated (SIGSEGV) at 0005:0000E2A3
mountimg: (No such process)

Any hints?

Thanks, Pavol Kycina

Hello (to myself)…

I have found a workaround:

1.) cp /file.qfs /dev/ram
2.) mount /dev/ram /ram
3.) … work, update, …
4.) umount /dev/ram
5.) dd if=/dev/ram of=/filenew.qfs count=(size of file.qfs)/512

Pavol Kycina

“Pavol Kycina” <xkycina@microstep-hdo.sk> wrote in message
news:4346446e$1@news.microstep-hdo.sk

“John Garvey” <> jgarvey@qnx.com> > wrote in message
news:dhcf8b$e6p$> 1@inn.qnx.com> …
Pavol Kycina wrote:
mountimg -m /disk /dev/ata0:file.qfs … Mountimg: ‘/dev/ata0’ is not
a
local device

Try specifying the device/file as “//0/dev/ata0:file.qfs” …

I have one more problem:

I can’t mount “file” as file system, if the file is stored in ram disk.
(storing the file in ram disk seems to me the easiest way to make the file
contiguos)

Preparation:
dinit /dev/ram
mount /dev/ram /ram
cp /file.qfs /ram

First attempt:
mountimg -m/disk /ram/file.qfs
mountimg: unable to auto-generate ext-partition name

Second attempt (more serious … Fsys manager SIGSEGVed):
mountimg -t77 -m/disk /ram/file.qfs
/bin/Fsys terminated (SIGSEGV) at 0005:0000E2A3
mountimg: (No such process)

Any hints?

Thanks, Pavol Kycina

Pavol Kycina wrote:

I can’t mount “file” as file system, if the file is stored in ram disk.
(storing the file in ram disk seems to me the easiest way to make the file
contiguos)

mountimg is an unsupported utility. I am not suprised it doesn’t work
against /dev/ram though. The attached (and also unsupported) piece of
code can be used to create a contiguous QNX4 Fsys-hosted disk file …

Thanks,

Its working fine.

PK

“John Garvey” <jgarvey@qnx.com> wrote in message
news:di6pcs$61m$1@inn.qnx.com

Pavol Kycina wrote:
I can’t mount “file” as file system, if the file is stored in ram disk.
(storing the file in ram disk seems to me the easiest way to make the
file
contiguos)

mountimg is an unsupported utility. I am not suprised it doesn’t work
against /dev/ram though. The attached (and also unsupported) piece of
code can be used to create a contiguous QNX4 Fsys-hosted disk file …





#ifdef __USAGE
%C - Create contiguous file

%C <size
#endif

#include <env.h
#include <errno.h
#include <fcntl.h
#include <limits.h
#include <stdarg.h
#include <stdio.h
#include <stdlib.h
#include <string.h
#include <sys/disk.h
#include <sys/fsys.h
#include <sys/stat.h
#include <unistd.h

#define MAX_ATTEMPTS 128

int trygrow(int blkdev, int fd, int nblks)
{
struct _fsys_stat st;
struct _xblk xblk;
long blkno;

if (lseek(fd, nblks * _BLOCK_SIZE - 1, SEEK_SET) == -1)
return(errno);
if (write(fd, “”, 1) != 1)
return(errno);
if (fsys_fstat(fd, &st) == -1)
return(errno);
if (st.st_num_xtnts == 1)
return(EOK);
for (blkno = st.st_xblk; block_read(blkdev, blkno, 1, &xblk) == 1 &&
xblk.xblk_next_xblk != 0; blkno = xblk.xblk_next_xblk)
;
if (ltrunc(fd, -xblk.xblk_xtnts[xblk.xblk_num_xtnts - 1].xtnt_size *
_BLOCK_SIZE, SEEK_END) == -1)
return(errno);
return(-1);
}

static void fatal(const char *prog, const char *errmsg, …)
{
va_list args;

fprintf(stderr, "%s: ", prog);
va_start(args, errmsg);
vfprintf(stderr, errmsg, args);
va_end(args);
fprintf(stderr, “\n”);
exit(EXIT_FAILURE);
}

int main(int argc, char *argv[])
{
char *filename, *tmpfilename, *cp;
int nblks, bytes, result, i, j;
int blkdev, fd[MAX_ATTEMPTS];
char device[PATH_MAX + 1], tmp[L_tmpnam + 1];

if (argc != 3)
fatal(argv[0], "specify and ");
filename = argv[1];
bytes = strtol(argv[2], &cp, 0);
if (*cp == ‘b’ || *cp == ‘B’)
bytes *= _BLOCK_SIZE, ++cp;
else if (*cp == ‘k’ || *cp == ‘K’)
bytes <<= 10, ++cp;
else if (*cp == ‘m’ || *cp == ‘M’)
bytes <<= 20, ++cp;
if (!bytes || *cp != ‘\0’)
fatal(argv[0], “invalid specification”);
nblks = (bytes - 1) / _BLOCK_SIZE + 1;
if ((cp = strrchr(filename, ‘/’)) != NULL) {
*cp = ‘\0’;
setenv(“TMPDIR”, filename, !0);
if (fsys_get_mount_dev(filename, device) == -1)
fatal(argv[0], “unable to determine underlying device - %s”,
strerror(errno));
*cp = ‘/’;
}
else {
setenv(“TMPDIR”, “.”, !0);
device[0] = ‘.’, device[1] = ‘\0’;
}
if ((blkdev = open(device, O_RDONLY)) == -1)
fatal(argv[0], “unable to open underlying device - %s”, strerror(errno));
result = -1;
for (i = 0; i < MAX_ATTEMPTS; ++i) {
tmpfilename = tmpnam(tmp);
if ((fd > = open(tmpfilename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR |
S_IWUSR | S_IRGRP | S_IROTH)) == -1)
fatal(argv[0], “unable to create working file - %s”, strerror(errno));
if ((result = trygrow(blkdev, fd> , nblks)) == EOK) {
if (rename(tmpfilename, filename) != -1)
break;
result = errno;
}
unlink(tmpfilename);
if (result != -1)
fatal(argv[0], “unable to grow working file - %s”, strerror(result));
}
for (j = 0; j <= i; ++j)
close(fd[j]);
close(blkdev);
if (result)
fatal(argv[0], “unable to create contiguous file - disk too fragmented”);
return(EXIT_SUCCESS);
}