FreeBSD/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
/*
 * Search the sharetab for the given mountpoint and protocol, returning
 * a zfs_share_type_t value.
 */
Search the sharetab for the given mountpoint and protocol, returning
a zfs_share_type_t value.
Search the sharetab for the given mountpoint and protocol returning a zfs_share_type_t value .
static zfs_share_type_t
is_shared(libzfs_handle_t *hdl, const char *mountpoint, zfs_share_proto_t proto)
{
	char buf[MAXPATHLEN], *tab;
	char *ptr;
	if (hdl->libzfs_sharetab == NULL)
		return (SHARED_NOT_SHARED);
	(void) fseek(hdl->libzfs_sharetab, 0, SEEK_SET);
	while (fgets(buf, sizeof (buf), hdl->libzfs_sharetab) != NULL) {
		if ((tab = strchr(buf, '\t')) == NULL)
			continue;
		*tab = '\0';
		if (strcmp(buf, mountpoint) == 0) {
#ifdef illumos
			ptr = ++tab;
			if ((tab = strchr(ptr, '\t')) == NULL)
				continue;
			ptr = ++tab;
			if ((tab = strchr(ptr, '\t')) == NULL)
				continue;
			*tab = '\0';
			if (strcmp(ptr,
			    proto_table[proto].p_name) == 0) {
				switch (proto) {
				case PROTO_NFS:
					return (SHARED_NFS);
				case PROTO_SMB:
					return (SHARED_SMB);
				default:
					return (0);
				}
			}
#else
			if (proto == PROTO_NFS)
				return (SHARED_NFS);
#endif
		}
	}
	return (SHARED_NOT_SHARED);
}
static zfs_share_type_t is_shared ( libzfs_handle_t * hdl , const char * mountpoint , zfs_share_proto_t proto ) { char buf [ MAXPATHLEN ] , * tab ; char * ptr ; if ( hdl -> libzfs_sharetab == NULL ) return ( SHARED_NOT_SHARED ) ; ( void ) fseek ( hdl -> libzfs_sharetab , 0 , SEEK_SET ) ; while ( fgets ( buf , sizeof ( buf ) , hdl -> libzfs_sharetab ) != NULL ) { if ( ( tab = strchr ( buf , ' \t ' ) ) == NULL ) continue ; * tab = ' \0 ' ; if ( strcmp ( buf , mountpoint ) == 0 ) { #ifdef illumos ptr = ++ tab ; if ( ( tab = strchr ( ptr , ' \t ' ) ) == NULL ) continue ; ptr = ++ tab ; if ( ( tab = strchr ( ptr , ' \t ' ) ) == NULL ) continue ; * tab = ' \0 ' ; if ( strcmp ( ptr , proto_table [ proto ] . p_name ) == 0 ) { switch ( proto ) { case PROTO_NFS : return ( SHARED_NFS ) ; case PROTO_SMB : return ( SHARED_SMB ) ; default : return ( 0 ) ; } } #else if ( proto == PROTO_NFS ) return ( SHARED_NFS ) ; #endif } } return ( SHARED_NOT_SHARED ) ; }
Search the sharetab for the given mountpoint and protocol, returning
 a zfs_share_type_t value.
Search the sharetab for the given mountpoint and protocol returning a zfs_share_type_t value .
/* the mountpoint is the first entry on each line */ /*
			 * the protocol field is the third field
			 * skip over second field
			 */