An implementation in expl3
that works over Plain TeX:
Main file hap.tex
\input expl3-generic
\ExplSyntaxOn
% we implement a stack
\seq_new:N \g_hap_filename_seq
\seq_gput_right:Nx \g_hap_filename_seq { \c_sys_jobname_str }
\cs_new_protected:Npn \sinput #1
{
\seq_gput_right:Nx \g_hap_filename_seq { #1 }
\tex_input:D #1 \scan_stop:
\seq_gpop_right:NN \g_hap_filename_seq \l_tmpa_tl
}
\cs_new:Npn \currentfile
{
\hap_parent:n { -1 }
}
\cs_new:Npn \parentfile
{
\hap_parent:n { -2 }
}
\cs_new:Nn \hap_parent:n
{
\seq_item:Nn \g_hap_filename_seq { #1 }
}
\ExplSyntaxOff
current file: \currentfile, parent file: \parentfile
\sinput{hap-first}
\bye
Secondary file hap-first.tex
current file: \currentfile, parent file: \parentfile
\sinput{hap-second}
Secondary file hap-second.tex
current file: \currentfile, parent file: \parentfile
Output

With just Plain TeX:
\newtoks\filestack
\global\filestack={{\jobname}{}}
\def\sinput#1{%
\edef\sinputtemp{{#1}\the\filestack}%
\global\filestack=\expandafter{\sinputtemp}%
%\immediate\write20{Stack: \the\filestack}% for debugging
\input #1\relax
\edef\sinputtemp{\expandafter\gobble\the\filestack}%
\global\filestack=\expandafter{\sinputtemp}%
%\immediate\write20{Stack: \the\filestack}% for debugging
}
\def\currentfile{\expandafter\firstitem\the\filestack\filestack}
\def\parentfile{\expandafter\seconditem\the\filestack\filestack}
\def\gobble#1{}
\def\firstitem#1#2\filestack{#1}
\def\seconditem#1#2#3\filestack{#2}
current file: \currentfile, parent file: \parentfile
\sinput{hap-first}
\bye