Skip to content

Commit

Permalink
Add a compile time option to restrict file names to the Portable File…
Browse files Browse the repository at this point in the history
…name Character Set. Issue marbl#1153.
  • Loading branch information
brianwalenz committed Dec 11, 2018
1 parent 49f2f5d commit 4b17478
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,18 @@ ifeq (${OSTYPE}, SunOS)
endif
endif

# Some filesystems cannot use < or > in file names, but for reasons unknown
# (or, at least, reasons we're not going to admit to), files in the overlap
# store are named ####<###>. Enabling POSIX_FILE_NAMES Will change the
# names to ####.###.
#
# Be aware this will break object store compatibility.
#
ifeq ($(POSIX_FILE_NAMES), 1)
CXXFLAGS += -DPOSIX_FILE_NAMES
endif


# Set compiler and flags based on discovered hardware
#
# By default, debug symbols are included in all builds (even optimized).
Expand Down
11 changes: 11 additions & 0 deletions src/stores/ovStoreFile.C
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,18 @@ ovFile::createDataName(char *name,
uint32 sliceNum,
uint32 pieceNum) {

// Sigh.
//
// POSIX.1-2008 defines the Portable Filename Character Set as just
// A-Z a-z 0-9 . _ -
// which makes for very boring filenames. But, lo! There ARE filesystems
// that require the Portable Filename Character Set.

#ifdef POSIX_FILE_NAMES
snprintf(name, FILENAME_MAX, "%s/%04u.%03u", storeName, sliceNum, pieceNum);
#else
snprintf(name, FILENAME_MAX, "%s/%04u<%03u>", storeName, sliceNum, pieceNum);
#endif

return(name);
}
Expand Down

0 comments on commit 4b17478

Please sign in to comment.