VFSv2 control library API (libvfsctrl)

Introduction

VFSv2 has a control interface to make an advanced management on Jari OS file system layer.

Currently this library has a minimal set of features. This documentation will be updated up to date while new functionality will be added.

TODO

  • Advanced statistics about opened resources about each task
  • Mount points statistics
  • Advanced register/unregister operations
  • Advanced access control
  • Control on VFSv2 limits

Currently implemented

  • Link points statistics
  • Mount points exchange feature

Build and installation notes

To use this library, add --with-libvfsctrl option to syslibs configure script

Headers


#include <sys/vfs/vfsctrl.h>             

Structures


 

typedef struct __lp_head_t 
{
   uint64_t lp_id : 32;       /* link point ID */
   uint64_t vfs_flags : 16;   /* VFS-side flags */
   uint64_t state : 16;       /* how much time was mounted */
   uint64_t ref_count : 32;   /* resources on this point are opened */
   time_t reg_time;           /* time of registration on VFS */
} __attribute__ ((packed)) lp_head_t;

struct vfs_lp_t 
{
     lp_head_t head;
     char *fstype;
};

 

Functions

Prototypes


int open_vfs_control_session(void);

int close_vfs_control_session(void);

LPS *get_vfs_lps(void);

int lps_read_next_item(LPS *r,struct vfs_lp_t *item);

void lps_destroy(LPS *r);

int vfs_pnode_exchange(const char *pnode_src,const char *pnode_dest);

open_vfs_control_session()

Opening a session to a VFSv2 control interface.

Returns 0 if ok, -1 and errno set to error on errors.

close_vfs_control_session()

Close a session to a VFSv2 control interface.

Returns 0 if ok, -1 and errno set to error on errors.

get_vfs_lps()

Get a LPS stream to a VFSv2 links points.

Returns a pointer to LPS stream, or NULL and errno set to error.

lps_read_next_item()

Reads next item to pointed structure. Returning 0 if stream end, 1 otherwise.

lps_destroy()

Destroy LPS stream.

vfs_pnode_exchange()

Exchange mount points. Returns 0 if done, -1 and errno set to error if not.

NOTE: Use it with care, this function available only for supervisor, or those who have rights for operations of this kind.

Example

Reading link points stream.


  LPS *is;
  struct vfs_lp_t item;
  char fst[LPS_MAX_TYPE_LEN];

  item.fstype=fst;

  open_vfs_control_session();

  is=get_vfs_lps();
  if(!is) fprintf(stderr,"Failed to get LPS stream, errno=%d\n",errno);
  else {
   
       printf("Link points on VFSv2 service:\n");
       while(lps_read_next_item(is,&item))
           printf("FS: %s;ID: %d;Flags: %d;Mounted times: %d;Opened resources: %d\n",
                               item.fstype, item.head.lp_id,item.head.vfs_flags,item.head.state,
                               item.head.ref_count);
  }

  lps_destroy(is);
  close_vfs_control_session();