A data processing apparatus for writing data to a recording medium having
a predetermined file system configured therein includes the following
elements: an insertion portion that removably holds the recording medium,
the data processing apparatus writing data to the recording medium
inserted in the insertion portion; an insertion/removal detector that
detects that the recording medium is inserted in or removed from the
insertion portion; a writing state storage unit that stores, when the
insertion/removal detector detects removal of the recording medium, a
data writing state upon removal of the recording medium; and a
restoration/analysis determining unit that determines, when the
insertion/removal detector detects insertion of the recording medium,
whether it is necessary to perform analysis regarding restoration of the
file system configured in the inserted recording medium on the basis of
the state stored in the writing state storage unit.