Reading mounted partitions

How do you read a list of all mounted disk and NFS partitions in QNX425?
I’ve been all over the documentation and the header files. I’m using ‘C’.

Thanks,

-Jim

“There’s always one more bug…”
– Bubba DuPree (1986)

James Winton <spamthis@home.com> wrote:

How do you read a list of all mounted disk and NFS partitions in QNX425?
I’ve been all over the documentation and the header files. I’m using ‘C’.

Under QNX4, everything like that starts from the prefix table. (Try doing
a “prefix” from the command line.) The function qnx_prefix_query() will
get you the list of all prefixes in the system.

Then, you have to walk through them to determine which are disk/NFS
partitions and which are something else. Took a look around for a
way to do this (other than by “guessing” based on what pid owns them
and what they look like) and couldn’t figure out that next step.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Good idea, thanks! I’ll check it out.

-Jim

David Gibbs wrote:

James Winton <> spamthis@home.com> > wrote:
How do you read a list of all mounted disk and NFS partitions in QNX425?
I’ve been all over the documentation and the header files. I’m using ‘C’.

Under QNX4, everything like that starts from the prefix table. (Try doing
a “prefix” from the command line.) The function qnx_prefix_query() will
get you the list of all prefixes in the system.

Then, you have to walk through them to determine which are disk/NFS
partitions and which are something else. Took a look around for a
way to do this (other than by “guessing” based on what pid owns them
and what they look like) and couldn’t figure out that next step.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

df [-h]

“James Winton” <spamthis@home.com> schrieb im Newsbeitrag
news:3D5118F4.8F4248DB@home.com

How do you read a list of all mounted disk and NFS partitions in QNX425?
I’ve been all over the documentation and the header files. I’m using ‘C’.

Thanks,

-Jim

“There’s always one more bug…”
– Bubba DuPree (1986)

FYI, a quick and dirty code snippet to read and display the mounted partitions
(thanks again, David).

Oh, one other thing. It seems that fsys_get_mount_pt() only returns the mount
point of the first mounted NFS partition regardless of which NFS “device” I feed
it. What am I doing wrong?

-Jim


void
print_partition_path(char *mpath)
{
struct statfs fs;
char buf[256], mnt[256];
int ret;


memset(&fs, 0, sizeof(fs));
ret = statfs(mpath, &fs, sizeof(fs), 0);
if (ret == -1)
{
printf(“statfs ret’%d’, %s\n”, ret, strerror(errno));
return;
}

printf(“partition: %s\n”, mpath);
printf(" fs: f_fstype’%d’\n", fs.f_fstype);
printf(" fs: f_bsize’%d’\n", fs.f_bsize);
printf(" fs: f_frsize’%d’\n", fs.f_frsize);
printf(" fs: f_blocks’%d’\n", fs.f_blocks);
printf(" fs: f_bfree’%d’\n", fs.f_bfree);
printf(" fs: f_files’%d’\n", fs.f_files);
printf(" fs: f_ffree’%d’\n", fs.f_ffree);
printf(" fs: f_fname’%s’\n", _format_hd(fs.f_fname, 6, 0));
printf(" fs: f_fpack’%s’\n", _format_hd(fs.f_fpack, 6, 0));

ret = fsys_get_mount_dev(mpath, buf);
if (ret == -1)
printf(“fsys_get_mount_dev ret’%d’, %s\n”, ret, strerror(errno));
else
{
printf(“mountdev: %s\n”, buf);
ret = fsys_get_mount_pt(buf, mnt);
if (ret == -1)
printf(“fsys_get_mount_pt ret’%d’, %s\n”, ret,
strerror(errno));
else
printf(“mountpt: %s\n”, mnt);
}
}

int
find_partition_paths(char *buf, int len)
{
pid_t sockpid, fsyspid, pid;
int ret, nparm;
char *p, *pend;
static char pfx[2048], pidnum[2048], unit[1];

sockpid = qnx_name_locate(0, “/qnx/socket”, 1024, 0);
if (sockpid == -1)
{
perror(“locate Socket”);
exit(-1);
}
fsyspid = qnx_name_locate(0, “qnx/fsys32”, 1024, 0);
if (fsyspid == -1)
{
perror(“locate Fsys”);
exit(-1);
}

ret = qnx_prefix_query(0, “”, buf, len);
if (ret == -1)
printf(“qnx_prefix_query ret’%d’, %s\n”, ret, strerror(errno));
else
{
printf(“prefixes: %s\n”, buf);

p = buf;
pend = p + strlen(p);
while (p && p < pend)
{
nparm = sscanf(p, “%[^=]=%[^,],%[^:]”, pfx, pidnum, unit);
if (nparm == 3)
{
/* found a resource mgr /
pid = atoi(pidnum);
if ((pid == sockpid) || (pid == fsyspid))
{
/
found a partition */
print_partition_path(pfx);
}
}
p = strchr(p, ‘:’);
p = p ? p + 1 : p;
}
}

return ret;
}

David Gibbs wrote:

James Winton <> spamthis@home.com> > wrote:
How do you read a list of all mounted disk and NFS partitions in QNX425?
I’ve been all over the documentation and the header files. I’m using ‘C’.

Under QNX4, everything like that starts from the prefix table. (Try doing
a “prefix” from the command line.) The function qnx_prefix_query() will
get you the list of all prefixes in the system.

Then, you have to walk through them to determine which are disk/NFS
partitions and which are something else. Took a look around for a
way to do this (other than by “guessing” based on what pid owns them
and what they look like) and couldn’t figure out that next step.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.


“There’s always one more bug…”
– Bubba DuPree (1986)

James Winton <spamthis@home.com> wrote:

FYI, a quick and dirty code snippet to read and display the mounted partitions
(thanks again, David).

Welcome…glad I could point you in the right direction.

Oh, one other thing. It seems that fsys_get_mount_pt() only
returns the mount point of the first mounted NFS partition
regardless of which NFS “device” I feed it.

Well, like everything else under QNX, it is going to build a message
and send it off to the server that owns it.

What am I doing wrong?

Probably nothing – I’ll bet that the TCP/IP server isn’t responding
quite intelligently enough to that message.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.