For example, "file system" and "related". Is it "file system-related"? It will appear as if it is a compound of "file" and "system-related", won't it?
This is a very good question and is one that troubled me for a long time.
Here is what the Fowler brothers say in their Kings English:
In answer to your question, based on Fowler's advice (which I find practical and logical), I would write filesystem-related or file-system-related, e.g., 'Please remember that this is a filesystem-related job.'
You're looking at a compound compound modifier.
Generally, a compound modifier (a two-word phrase that is used as an adjective) is hyphenated when it appears before the noun it is modifying:
The hyphen is there to prevent confusion on which words are being modified. There may be more important reasons, but this is the more-important reason.
Each of the components of a compound adjective can itself be a compound word. It is common in this case to use an "en dash" to keep things well organized: