1 int main(int argc, char *argv[])
5 /* create needed IPC objects */
6 key = ftok("~/gapil/sources/DirMonitor.c", 1); /* define a key */
7 if (!(shmptr = ShmFind(key, 4096))) { /* get a shared memory segment */
8 perror("Cannot find shared memory");
11 if ((mutex = MutexFind(key)) == -1) { /* get the Mutex */
12 perror("Cannot find mutex");
16 MutexLock(mutex); /* lock shared memory */
17 printf("Ci sono %d file dati\n", shmptr->tot_regular);
18 printf("Ci sono %d directory\n", shmptr->tot_dir);
19 printf("Ci sono %d link\n", shmptr->tot_link);
20 printf("Ci sono %d fifo\n", shmptr->tot_fifo);
21 printf("Ci sono %d socket\n", shmptr->tot_sock);
22 printf("Ci sono %d device a caratteri\n", shmptr->tot_char);
23 printf("Ci sono %d device a blocchi\n", shmptr->tot_block);
24 printf("Totale %d file, per %d byte\n",
25 shmptr->tot_files, shmptr->tot_size);
26 MutexUnlock(mutex); /* unlock shared memory */