# Problem in deriving Electromagnetic tensor

I'm having troubles in understanding a mathematical step in the derivation of the electromagnetic tensor. In Landau&Lifshitz's book I found that the action of a particle in an electromagnetic field is

$$S = \int_a^b (-mc \, ds - \frac{e}{c}A_i \, dx^i).\tag{16.1}$$

Then they want to apply the least action principle and they immediately write

$$\delta S = - \int_a^b \left(mc \frac{dx^i d\delta x_i}{ds} + \frac{e}{c} A_i d\delta x^i + \frac{e}{c} \delta A_i dx^i\right).\tag{23.1b}$$

I really can't understand this step. I have only basic knowledge on calculus of variation, but from what I know, if I have a functional

$$I = \int f(x, y(x), y'(x)) \, dx$$

the "variation" of $$I$$ should be defined as

$$\delta I = \int \frac{\partial f}{\partial y}\delta y \, dx$$

but in calculating $$\delta \int mc \, ds$$ I have a constant function which multiplies a differential which depends on the varying quantities, which is different.

I can't see how this definition of "variation" connects with $$\delta S$$ and I can't get what $$d\delta x^k$$ means... I'm not searching for a mathematical rigorous proof, but just an explanation of what's happening there or some more sub-steps. I think the key is to treat $$ds$$ as a function of $$dt, dx, dy, dz$$ but I tried and I couldn't get that expression out. I've also tried to search elsewhere but I found texts taking electromagnetic tensor as a definition, or reporting the same step without any clarifications.

The variation means that instead of single trajectory $$x^*(t)$$ we consider all trajectories of the form $$x^*(t)+\eta \delta x (t)$$ where $$\delta x(t)$$ is any smooth function that is zero for boundary times.
The differential $$ds$$ can be expressed using functions $$x_i'(t)$$ and time differential $$dt$$. Then we can transform variation of the integral in the standard way Landau assumes.