I had a flashback of a story or novel I read where people live in the mouth of a giant. Does anyone know where this story came from?

All I can remember is that a guy was saved from being swallowed and that there's a whole community of people that live in this giant's mouth. They cause cavities to make caves to live in and put rope between his teeth and gums to keep from falling down his throat. This flashback is really weirding me out because wtf is this story, it's really weird. Does anyone know it?