Forcing the system to allow me to insert any character in the file name

I had an exam this week, and one of the questions was (with one correct answer):

The file name can contain the character:

a) \

b) /

c) ?

d) !

I chose c) ? because it looked OK to me. When I came home I tested it on my machine (Ubuntu 14.04) and the file was created successfully. In the ready reckoner the correct answer is marked to be d) !.

I knew that the exam was Windows specific, but on the test paper the platform was not specified.

It's clear that \ and / characters are not supported in a file name, BUT is there any way to force the operating system to allow them?

It would be really cool to proove that even \ and / characters are supported.

-
In MS Windows, d) is the correct answer. –  choroba Jun 19 '14 at 7:58
@choroba I know, but on Linux ? is correct as well. Also, the platform was not specified. :-) –  Ionică Bizău Jun 19 '14 at 8:05

There are two limiting factors when considering the characters permitted in a file name — restrictions related to the operating system, and restrictions related to the file system. For this question I will assume we are talking about recent versions of Linux and ext4.

Linux only disallows two characters in filenames: /, because it is the path separator, and \0 (ASCII NUL), because it terminates cstrings. In addition to this, the special names . and .. are also reserved by the filesystem for use as navigational hard links.

You can easily demonstrate that the other characters mentioned in your question are allowed:

$touch '\' '?' '!'$ ls
!  ?  \

-
Isn't there any way to force the system to accept / as well? I know it's a restriction, but maybe there are workarounds... –  Ionică Bizău Jun 19 '14 at 8:08
@IonicăBizău Almost certainly not through conventional methods. You could try using debugfs, but you should expect bad things to happen if you succeed. –  Chris Down Jun 19 '14 at 8:21
I don't care about bad things, how can I use debugfs to create a file named foo/bar, for example? –  Ionică Bizău Jun 19 '14 at 11:05
@IonicăBizău you can also cheat. Try copying this into a terminal: touch 'foo̸̸ bar' –  terdon Jun 19 '14 at 13:08
@terdon That's a good idea, but not perfect. This is perfect: touch 'foo ∕ bar'. So, Chris, you can update your answer and I will mark it! :-) –  Ionică Bizău Jun 19 '14 at 15:17