Texture splatting 3 or more textures
Assuming your mask is greyscale, in theory you can map each of the 255 intermediate shades of grey to an individual land-class. In reality, you probably want more separation between the values so that texture compression doesn't mess up your mask. So assign 0 to rock, 32 to dirt, 64 to grass, ... 255 to sand, etc

Your mask will look like this, then it's up to you to setup the node materials to interpret this mask.


The only downside of this approach is that you have very little control over the blending of these terrains. Using the example above, it would be impossible to blend between sand and rock, since these values are not adjacent to each other on the mask. So with a typical bilinear interpolation, you might get 'rings' of landclass like this:



You can do 2 things: use a noise overlay on the mask to break up the pattern so it looks less obvious, or use a depth based terrain blending technique.

The node for this will be very similar to this: Cycles shader multiplexer node?