Skip to contentSkip to conversation

About listing to /dev/autofs

DISCUSSION Stef Bon 1 participant 1 message Mar 23, 2010 Kernel automounter

lore
Share & tools
lore

Stef Bon

author
#0 lore raw

Hello,

I've written a small app, which listens to the device /dev/autofs, to read what kind of messages come from it.

Starting the automounter, with USE_MISC_DEVICE set to yes.

A small app, (copied from the fuse source..):

#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

int main(void)

{
        int fds;
        int nfds;

        fds = open("/dev/autofs", O_RDONLY);
        nfds = 2;

        while (1) {
                static char buf[4096];
                fd_set rfds;
                int rc;

                FD_ZERO(&rfds);

                FD_SET(fds, &rfds);

                rc = select(nfds, &rfds, NULL, NULL, NULL);

                if (rc < 0) {
                        perror("select");
                        return 1;
                }

                if (!FD_ISSET(fds, &rfds)) {
                                printf("_:   ");
                } else {

                    rc = read(fds, buf, sizeof(buf));

                    if (rc < 0) {
                        perror("read");
                        return 1;
                    }

                    printf("%02d ", rc);
                    
                }
                printf("\n");
        }
}

After compiling and starting it as normal user (and setting the properties of /dev/autofs to 666), I do not get any output. I expect some messages, like mounted directory...

Can somebody explain this??

Stef Bon