aboutsummaryrefslogblamecommitdiffstats
path: root/nmount.c
blob: ecb02199c4e4c305080a748d572d526bb67d9559 (plain) (tree)
1
2
3
4
5
6
7
8







                      




                        



                                                                                         























                                
 

                                                               




                                 




















                                                                       
                              



                                

                                                                                                                          


                    
 
                         




                                                                                    
              
                                          
                                          
                                                                            
                                          
                                          
                                          

                                          
                                          

                                          
                                          
  
 

















                               
                

                       


                                          
                              


                    

               

                                              





                                 

                               
                              




                                          



















                                                                                              













                                                                                            












                                                                                            












                                                                          






                               
               
 











                                                                          
 



                               
              
                  







                                                   

                                         

                       
                                                          


                  
                     
                                        
                                      
                      

















                                               





                                




                                                                  

























                                                                     
                             









                                                            




                                                                                                       

                                                                     
         
        


                                               
     
 


                                                   
                                                             

                               
                                                  
                                                    
                                                                 



                                     
                                     

                                      
                                                                  
                                           


                                                          
                                                                                    
                                           

     


                                                                              

                                           
                                  














                                                        


             

 
#include <stdio.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <getopt.h>
#include <signal.h>
#include <string.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <errno.h>


/////////////////////////////////////////////////////////////////////////////////////////
/*FLAGS FROM KERNEL*/

#define _MS_RDONLY       (1<<0)
#define _MS_NOSUID       (1<<1)
#define _MS_NODEV        (1<<2)
#define _MS_NOEXEC       (1<<3)
#define _MS_SYNCHRONOUS  (1<<4)
#define _MS_REMOUNT      (1<<5)
#define _MS_MANDLOCK     (1<<6)
#define _MS_DIRSYNC      (1<<7)
#define _MS_NOATIME      (1<<10)
#define _MS_NODIRATIME   (1<<11)
#define _MS_BIND         (1<<12)
#define _MS_MOVE         (1<<13)
#define _MS_REC          (1<<14)
#define _MS_SILENT       (1<<15)
#define _MS_POSIXACL     (1<<16)
#define _MS_UNBINDABLE   (1<<17)
#define _MS_PRIVATE      (1<<18)
#define _MS_SLAVE        (1<<19)
#define _MS_SHARED       (1<<20)
#define _MS_RELATIME     (1<<21)
#define _MS_KERNMOUNT    (1<<22)
#define _MS_I_VERSION    (1<<23)
#define _MS_STRICTATIME  (1<<24)
#define _MS_LAZYTIME     (1<<25)

#define STRUCT_LEN(VAR,STRUCT) ((sizeof(VAR)/sizeof(STRUCT))-1)

#define max(a,b) \
   ({ __typeof__ (a) _a = (a); \
       __typeof__ (b) _b = (b); \
     _a > _b ? _a : _b; })

typedef struct vfs_option_params {
    char *val;
    char *descr;
} vfs_option_params;

vfs_option_params vfs_options_proc_params_hidepid[] = {
    {"0","Everybody may access all proc"},
    {"1","User can access only their own proc, not other /proc/[pid]"},
    {"2","As for mode 1, extra hides pid directories of others"},
    {NULL,NULL},
};

vfs_option_params vfs_options_proc_params_gid[] = {
    {"gid","usergroup who sees /proc in mode 0"},
    {NULL,NULL},
};

typedef struct vfs_options 
{
    char *options;
    char *description;
    vfs_option_params *params;
} vfs_options;

vfs_options vfs_options_proc[] =
{
    {"hidepid=\%u" ,"",                                     (struct vfs_option_params *)&vfs_options_proc_params_hidepid},
    {"gid=\%u"     ,"user group that can access process",   (struct vfs_option_params *)&vfs_options_proc_params_gid},
    {NULL,NULL,NULL}
};


static const struct vfs {
    char *name;           //filesystem name
    long flags;           //dunno
    char *mountpoint;     //default mount point if mount dir is not set
    int nosource;         //does fs have source or not
    vfs_options *options; //hellpers to show all possible options to config fs mount
} vfstab[] = {