View topic - QNX4 mountimg

QNX4 mountimg

Read-only archive of qnx.qnx4 (General QNX4 Discussion Group) at inn.qnx.com

QNX4 mountimg

Postby Pavol Kycina » Tue Sep 27, 2005 6:50 am

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
 

Re: QNX4 mountimg

Postby John Garvey » Tue Sep 27, 2005 9:58 pm

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
 

Re: QNX4 mountimg

Postby Pavol Kycina » Wed Sep 28, 2005 7:19 am

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" ...
Pavol Kycina
 

Re: QNX4 mountimg

Postby Pavol Kycina » Fri Oct 07, 2005 9:48 am

"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
 

Re: QNX4 mountimg

Postby Pavol Kycina » Fri Oct 07, 2005 11:28 am

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
 

Re: QNX4 mountimg

Postby John Garvey » Fri Oct 07, 2005 9:32 pm

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 ...
Attachments
contig.c.gz
(1.2 KiB) Downloaded 224 times
John Garvey
 

Re: QNX4 mountimg

Postby Pavol Kycina » Mon Oct 10, 2005 5:47 am

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 <filename> <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 <filename> and <size>");
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 <size> 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[i] = 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[i], 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);
}
Pavol Kycina
 


Return to qnx.qnx4

Who is online

Users browsing this forum: No registered users and 3 guests