/** * @brief Returns the mount list * * @return The mount list */ mountlist nfs_Get_MountList(void) { if(isFullDebug(COMPONENT_NFSPROTO)) nfs_Print_MountList(); return MNT_List_head; }
/** * @brief Purges the whole mount list * * @return true if successful, false otherwise */ bool nfs_Purge_MountList(void) { mountlist piter_mnt_list_entry __attribute__((unused)), piter_mnt_list_entry_next __attribute__((unused)); piter_mnt_list_entry = MNT_List_head; piter_mnt_list_entry_next = MNT_List_head; #ifndef _NO_MOUNT_LIST while(piter_mnt_list_entry_next != NULL) { piter_mnt_list_entry_next = piter_mnt_list_entry->ml_next; gsh_free(piter_mnt_list_entry->ml_hostname); gsh_free(piter_mnt_list_entry->ml_directory); gsh_free(piter_mnt_list_entry); piter_mnt_list_entry = piter_mnt_list_entry_next; } MNT_List_head = NULL; MNT_List_tail = NULL; if(isFullDebug(COMPONENT_NFSPROTO)) nfs_Print_MountList(); #endif return 1; } /* nfs_Purge_MountList */
/** * * nfs_Add_MountList_Entry: Adds a client to the mount list. * * Adds a client to the mount list. * * @param hostname [IN] the hostname for the client * @param dirpath [IN] the mounted path * * @return 1 if successful, 0 otherwise * */ int nfs_Add_MountList_Entry(char *hostname, char *dirpath) { #ifndef _NO_MOUNT_LIST mountlist pnew_mnt_list_entry; #endif /* Sanity check */ if(hostname == NULL || dirpath == NULL) return 0; #ifndef _NO_MOUNT_LIST /* Allocate the new entry */ if((pnew_mnt_list_entry = gsh_calloc(1, sizeof(struct mountbody))) == NULL) return 0; if((pnew_mnt_list_entry->ml_hostname = gsh_calloc(1, MAXHOSTNAMELEN)) == NULL) { gsh_free(pnew_mnt_list_entry); return 0; } if((pnew_mnt_list_entry->ml_directory = gsh_calloc(1, MAXPATHLEN)) == NULL) { gsh_free(pnew_mnt_list_entry->ml_hostname); gsh_free(pnew_mnt_list_entry); return 0; } /* Copy the data */ strncpy(pnew_mnt_list_entry->ml_hostname, hostname, MAXHOSTNAMELEN); strncpy(pnew_mnt_list_entry->ml_directory, dirpath, MAXPATHLEN); /* initialize next pointer */ pnew_mnt_list_entry->ml_next = NULL; /* This should occur only for the first mount */ if(MNT_List_head == NULL) { MNT_List_head = pnew_mnt_list_entry; } /* Append to the tail of the list */ if(MNT_List_tail == NULL) MNT_List_tail = pnew_mnt_list_entry; else { MNT_List_tail->ml_next = pnew_mnt_list_entry; MNT_List_tail = pnew_mnt_list_entry; } if(isFullDebug(COMPONENT_NFSPROTO)) nfs_Print_MountList(); #endif return 1; } /* nfs_Add_MountList_Entry */
/** * @brief Initializes the mount list * * @return 1 if successful, 0 otherwise * */ int nfs_Init_MountList(void) { MNT_List_head = NULL; MNT_List_tail = NULL; if(isFullDebug(COMPONENT_NFSPROTO)) nfs_Print_MountList(); return 1; } /* nfs_Init_MountList */
/** * * @brief Remove a client from the mount list * * @param[in] hostname The hostname for the client * @param[in] dirpath The mounted path * * @return true if successful, false otherwise */ bool nfs_Remove_MountList_Entry(char *hostname, char *dirpath) { #ifndef _NO_MOUNT_LIST mountlist piter_mnt_list_entry; mountlist piter_mnt_list_entry_prev; int found = 0; #endif if(hostname == NULL) return 0; #ifndef _NO_MOUNT_LIST piter_mnt_list_entry_prev = NULL; for(piter_mnt_list_entry = MNT_List_head; piter_mnt_list_entry != NULL; piter_mnt_list_entry = piter_mnt_list_entry->ml_next) { /* BUGAZOMEU: pas de verif sur le path */ if(!strncmp(piter_mnt_list_entry->ml_hostname, hostname, MAXHOSTNAMELEN) /* && !strncmp( piter_mnt_list_entry->ml_directory, dirpath, MAXPATHLEN ) */ ) { found = 1; break; } piter_mnt_list_entry_prev = piter_mnt_list_entry; } if(found) { /* remove head item ? */ if(piter_mnt_list_entry_prev == NULL) MNT_List_head = MNT_List_head->ml_next; else piter_mnt_list_entry_prev->ml_next = piter_mnt_list_entry->ml_next; /* remove tail item ? */ if(MNT_List_tail == piter_mnt_list_entry) MNT_List_tail = piter_mnt_list_entry_prev; gsh_free(piter_mnt_list_entry->ml_hostname); gsh_free(piter_mnt_list_entry->ml_directory); gsh_free(piter_mnt_list_entry); } if(isFullDebug(COMPONENT_NFSPROTO)) nfs_Print_MountList(); #endif return 1; } /* nfs_Remove_MountList_Entry */