FreeBSD/sys/kern/vfs_mount.c
/*
 * Check that no unknown options are given
 */
Check that no unknown options are given
Check that no unknown options are given
int
vfs_filteropt(struct vfsoptlist *opts, const char **legal)
{
	struct vfsopt *opt;
	char errmsg[255];
	const char **t, *p, *q;
	int ret = 0;
	TAILQ_FOREACH(opt, opts, link) {
		p = opt->name;
		q = NULL;
		if (p[0] == 'n' && p[1] == 'o')
			q = p + 2;
		for(t = global_opts; *t != NULL; t++) {
			if (strcmp(*t, p) == 0)
				break;
			if (q != NULL) {
				if (strcmp(*t, q) == 0)
					break;
			}
		}
		if (*t != NULL)
			continue;
		for(t = legal; *t != NULL; t++) {
			if (strcmp(*t, p) == 0)
				break;
			if (q != NULL) {
				if (strcmp(*t, q) == 0)
					break;
			}
		}
		if (*t != NULL)
			continue;
		snprintf(errmsg, sizeof(errmsg),
		    "mount option <%s> is unknown", p);
		ret = EINVAL;
	}
	if (ret != 0) {
		TAILQ_FOREACH(opt, opts, link) {
			if (strcmp(opt->name, "errmsg") == 0) {
				strncpy((char *)opt->value, errmsg, opt->len);
				break;
			}
		}
		if (opt == NULL)
			printf("%s\n", errmsg);
	}
	return (ret);
}
int vfs_filteropt ( struct vfsoptlist * opts , const char * * legal ) { struct vfsopt * opt ; char errmsg [ 255 ] ; const char * * t , * p , * q ; int ret = 0 ; TAILQ_FOREACH ( opt , opts , link ) { p = opt -> name ; q = NULL ; if ( p [ 0 ] == ' ' && p [ 1 ] == ' ' ) q = p + 2 ; for ( t = global_opts ; * t != NULL ; t ++ ) { if ( strcmp ( * t , p ) == 0 ) break ; if ( q != NULL ) { if ( strcmp ( * t , q ) == 0 ) break ; } } if ( * t != NULL ) continue ; for ( t = legal ; * t != NULL ; t ++ ) { if ( strcmp ( * t , p ) == 0 ) break ; if ( q != NULL ) { if ( strcmp ( * t , q ) == 0 ) break ; } } if ( * t != NULL ) continue ; snprintf ( errmsg , sizeof ( errmsg ) , " " , p ) ; ret = EINVAL ; } if ( ret != 0 ) { TAILQ_FOREACH ( opt , opts , link ) { if ( strcmp ( opt -> name , " " ) == 0 ) { strncpy ( ( char * ) opt -> value , errmsg , opt -> len ) ; break ; } } if ( opt == NULL ) printf ( " \n " , errmsg ) ; } return ( ret ) ; }
Check that no unknown options are given
Check that no unknown options are given