System mount points

Hi all

I’m using RPM for detecting system mount point, but it’s so slowly. I need another faster method.
Which methods I need to use for detecting system mount points from shell or directly fom source code (C) without RPMlibrary?

rpm -qa --qf '%{RPMTAG_DIRNAMES}:%{VENDOR}
' | grep :'SUSE' | cut -d: -f1 | uniq | sort | uniq | while read D; do if mountpoint -q "$D"; then echo "$D";fi done

I do not understand at all what you try to achieve. I see no connections between mount points and RPMs. When I want to know which mounts are active I use:

boven:~ # mount
/dev/sda2 on / type ext3 (rw,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw)
udev on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/sda3 on /home type ext3 (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
boven:~ #

The command you use give will IMHO give you all the directories where at least one file of all RPM installed products fom SUSE is put.

Having said that you may load one program less in your command line by using the -u option with **sort, **omitting the unique.

mount point show all mount points on system, but i need only system mount points.

example:
My system have 5 partitions(LVM)/mount points:
/
/boot
/home
/data
/storage

In this list are just 2 system mount points - linux require this mount points/partition for boot (/, /boot) and the rest is “data” mount points or whatever.
My idea is:

  • System mount points are partitions where are installed all RPM packages (or packages member of “System” group) which have vendor “SUSE”, “RedHat” or any other distribution.
  • Boot mount point is partition where is installed grub/lilo RPM package

I may sound a bit harsh, bit imho this is an invention of your own. There is no definition of what is a ‘system’ mount point (from the view of the system).

As you have seen above, I only have / and /home as mountpoints at the moment. So it is not true that Linux requires /boot as a seperate partition (and thus mount).

Grub is installed at a lot of places besides /boot/boot and /boot/grub, in /usr/bin, /usr/lib/grub, /usr/sbin, /usr/share/doc/packages, …

You also seem to reduce to the term ‘system’ those RPMs that are from YaST repos that have somewhere the word SUSE in it. I have Amarok from the Packman repo and not from the SUSE repo, but did does not make it less ‘system’.

All this is not very interesting as it is not up to me to tell you what you want to you on your system. I only try to understand what you technicaly want to achieve. And as the term ‘system mountpoint’ had (and still has) no value for me, I did not understand what you want.

I have run your command and it takes about 3 seconds to come to an end (including the answer: /). Now again, it is up to you to call this “slowly”. What do you expect? I do not hope you want to run this thousands of times a day?

And does it really do what you want?

  1. It makes a list of all directories involved in all RPM installs with the vendor names.
  2. It leaves out all those where ‘:SUSE’ is not in the string.
  3. It cuts off the vendor part, leving just the names of the directories.
  4. When (by accident) two or more of the same lines follow each other they are reduced two only one of them (I say by accident and it shows, on my system it reduced the total from 793 to 701 lines).
  5. The whole is sorted.
  6. Again uniq (this time more usefull, it reduced to 92 lines).
  7. Take each of the remaining directories and check if they happen to be a mount point, when yes, print them.

As I told you above, I got / as the answer. Of course I could not have much more. **But **I only got it because the RPM of product ‘filesystem’ has it. Not because it is the root of al directories mentioned in all RPMs! This product ‘filesystem’ sees that at least a skeleton of directories is there. I am not convinced that mentioning / in this RPM is really needed because / will be there directly after the mount of the root partition during install already. So when it is left out, I even wouldn’t have / as a ‘system mountpoint’!

Hm,

actually i try to found equivalent windows API (GetWindowsDirectory) for Linux :wink:

I try this command line from source code with rpm library, but rpm is released under GPL license (for non commercial and open sourced software)

I can’t help you there, I know almost nothing about windows and have no idea what GetWindowsDirectory is about.

But I doubt if an equivalent is usefull. The concepts are very different. And I have the vague idea that you still do not get what you want, maybe because it is simply does not exist in Linux.

I am not sure I am following you here. Something being GPL does not normally offer a problem.

But your original problem was that your command takes to much time. I have 3 seconds. How long takes it in your case and why is that to long?

I know that windows and linux concepts are very very different. On windows system we have only one ‘system’ directory/partition - C:\windows, but on linux we have more than one ‘system’ directory

Yes my original problem is command line, because RPM is GPL.
Because i have idea: Run rpm command from source code (man popen(3)), but executing command is very slowly :frowning:

If i write my C code with RPM library equivalent command line, executing program less one second. Executing from command line from 8 to 20 seconds. It is a very very slowly.
Speed is very important for my software.

BR

[quote="“Motokultivator,post:7,topic:12851”]
I know that windows and linux concepts are very very different. On windows system we have only one ‘system’ directory/partition - C:\windows, but on linux we have more than one ‘system’ directory[/QOUTE]
What you say is not true. You better forget about windows and try to understand Linux starting from an empty mind. Else you will stumble into more things you think you understand over and over again. But in fact you are missing tiny points that will spoil your expirience.

I still do not understand the GPL part of your story.
But I think I understand that your answer is that the command you introduced in your first post takes 8 - 20 secs. I suggested to leave out both uniq commands and to change the sort to sort -u, but I agree that the rpm command takes most of the processing time. may be rebuilding (thus defragmenting) the database may speed up things:

rpm --rebuilddb

BTW this is part of a recommended SDB:Speed up Package Manager Stack - openSUSE