Skip to content

How Tagging Works

WXY edited this page Sep 23, 2021 · 3 revisions
  • Tags shall be stored on each file as extended attributes named user.tagids
    • On windows this is stored as an alternate stream with the same name
    • Containing a string of unsigned 16 bit integers (not encoded)
    • First id is a namespace identifier (more on this later)
  • A UTF8 file named .tagnames may exist at any directory as a way to translate the tag IDs and to allow instant renaming
    • This is not a directory extended attribute because not every system can safely store large attributes
    • The first two lines of the file shall serve as its header
      • The first shall serve as the file magic number
      • The second shall be a random hex number, serving as a namespace identifier to detect out of place files
    • The body of the file shall be a list of tag names
      • Delimited by new line characters
    • The file does not necessarily need to be in the opened directory
      • program shall bubble up the directory tree until it finds the file
      • the search ends when we arrive at the home of the user or a mount point
  • The application shall detect "out of place" files i.e. files whose namesapce IDs are foreign to the nearest parent
    • We don't store the path to the namespace because it can leak meta-data about the directory
    • Disregarding the security issue, storing the path doesn't mean the namespace file won't be moved, so it's not functionally better
  • Both tag and namespace IDs starts from 1 to prevent falsy values & serialization errors from silently creeping in
Clone this wiki locally