Summary

Yosef Karo Translation:Shulchan Aruch — Yoreh Deah 286

Seif 2 A house/room for straw, wood, livestock — require. But if women bathe there, since they stand there naked, it is not proper regard of Heaven for a mezuza to be there. (Rema: Only these specifically. But an actual [living] room, even if man and woman sleep and have relations there — requires mezuzah (in Responsa Maharil and the same wrote the BY) And some are lenient and say wherever women lie is exempt from mezuzah (BY in the name of Semak, the Kol Bo, and Mordekhai Hilkhot Mezuza end.)
Source: Wikisource

Yosef Karo Translation:Shulchan Aruch — Yoreh Deah 286

But if the house opens to one of these, it requires.
(And some say a hallway [beith sha`ar] requires one even if the house does not open to it (Tur and the poskim in the name of R"Y) .
מרפסת שהיא דרך לעלות בה לעליות, ובית שער, והגינה -- פטורים. ואם בית פתוח לאחד מאלו -- חייבים.
ויש אומרים שבית שער חייב אפילו אין בית פתוח לו (טור והפוסקים בשם ר"י) . Seif 8 A gatehouse (hallway) that opens to a room and to a yard, needs two mezuzot: one where it open to the room and one where it opens to the yard.
Source: Wikisource

Get perspective with Kwize: daily news enlightened by great literature