kernels/linux-2.4.0/fs/vfat/namei.c
/* Checks the validity of a long MS-DOS filename */
/* Returns negative number on error, 0 for a normal
 * return, and 1 for . or .. */
Checks the validity of a long MS-DOS filename
Returns negative number on error, 0 for a normal
return, and 1 for . or
Checks the validity of a long MS - DOS filename Returns negative number on error 0 for a normal return and 1 for . or
static int vfat_valid_longname(const char *name, int len, int xlate)
{
	const char **reserved, *walk;
	unsigned char c;
	int i, baselen;
	if (len && name[len-1] == ' ') return -EINVAL;
	if (len >= 256) return -EINVAL;
	for (i = 0; i < len; i++) {
		c = name[i];
		if (xlate && c == ':') continue;
		if (strchr(bad_chars,c)) {
			return -EINVAL;
		}
	}
 	if (len < 3) return 0;
	for (walk = name; *walk != 0 && *walk != '.'; walk++);
	baselen = walk - name;
	if (baselen == 3) {
		for (reserved = reserved3_names; *reserved; reserved++) {
			if (!strnicmp(name,*reserved,baselen))
				return -EINVAL;
		}
	} else if (baselen == 4) {
		for (reserved = reserved4_names; *reserved; reserved++) {
			if (!strnicmp(name,*reserved,baselen))
				return -EINVAL;
		}
	}
	return 0;
}
static int vfat_valid_longname ( const char * name , int len , int xlate ) { const char * * reserved , * walk ; unsigned char c ; int i , baselen ; if ( len && name [ len - 1 ] == ' ' ) return - EINVAL ; if ( len >= 256 ) return - EINVAL ; for ( i = 0 ; i < len ; i ++ ) { c = name [ i ] ; if ( xlate && c == ' ' ) continue ; if ( strchr ( bad_chars , c ) ) { return - EINVAL ; } } if ( len < 3 ) return 0 ; for ( walk = name ; * walk != 0 && * walk != ' ' ; walk ++ ) ; baselen = walk - name ; if ( baselen == 3 ) { for ( reserved = reserved3_names ; * reserved ; reserved ++ ) { if ( ! strnicmp ( name , * reserved , baselen ) ) return - EINVAL ; } } else if ( baselen == 4 ) { for ( reserved = reserved4_names ; * reserved ; reserved ++ ) { if ( ! strnicmp ( name , * reserved , baselen ) ) return - EINVAL ; } } return 0 ; }
Checks the validity of a long MS-DOS filename
Returns negative number on error, 0 for a normal
 return, and 1 for .
Checks the validity of a long MS - DOS filename Returns negative number on error 0 for a normal return and 1 for .