It is not so hard coded as you state. The maximum number for your system is
For me, that would be 3257198. If you are adventurous (changing kernel parameters on the fly, mmmmmm), you can change that number.
The absolute maximum is given by the fact that this is a
long integer in C, and the maximum would therefore be 2147483647.
On a per process basis, the maximum is
(on my system also your 1048576).
Technically, this is an unsigned long (see
fs.h; search for
unsigned long max_files; in the
struct files_stat_struct. But, your number of open files per process must be below the system-wide maximum, so it should be below 2147483647 or below your
cat /proc/sys/fs/file-max vaule.