Resources | Resources |



Customizing SPAR rules

Customizing directories being monitored

To add SPAR rules for additional directories, do the following:

  • Add the directories to be monitored to OEMFSSpar_AccessCbk(), which is in cs\src\oem\oemfs\OEMFSSpar.c.

    OEMFSSpar_AccessCbk() calls diag_fs_register_access_check() to register the array of directories with DIAG.

  • Note that ppszDirList has a predefined size of NUM_WATCH_DIR (4). If more directories need to be monitored, you need to define a new array of directories and populate it with the directory paths before calling diag_fs_register_access_check().
  • Add code to OEMFSSpar_Access() for the directories that were added to determine whether they can be granted access with accessing mode dwMode.

Blocking all access to fs:/sys

To block all access to fs:/sys, OEMFSSpar_Access(), which is in cs\src\oem\oemfs\OEMFSSpar.c, should be changed as follows:

boolean OEMFSSpar_Access(char *pszName, uint32 dwMode,
                                    PFNCHKRMTACCESS pfn)
   char pszPathCanonical[FS_PATH_MAX];
   int nLen = sizeof(pszPathCanonical);
   if('/' == pszName[0]) {
      pszName += 1; // guard against some device returning / with path.
   if(AEE_SUCCESS !=
      OEMefs_GetPathFromNative(pszName, pszPathCanonical, nLen, 0))
      return TRUE;
   // only check for mif, mod, sys, ringers
   If( std_strbegins(pszPathCanonical, AEEFS_SYS_DIR) )
      return FALSE; // This would be where OEM checks access to sys dir.
                        // Do not need to check dwMode to unconditionally
                        // block access, including listing access
   else  if(!(std_strbegins(pszPathCanonical, AEEFS_MIF_DIR) ||
      std_strbegins(pszPathCanonical, AEEFS_MOD_DIR) ||
      std_strbegins(pszPathCanonical, "fs:/ringers/")))
      return TRUE;

   return pfn(pszPathCanonical, OEMFSSpar_Mode(dwMode)); // fallback to SPAR rules
   return TRUE;