refactor: move wallpaper.cache to 0:/state

This commit is contained in:
daniel committed 2026-10-17 10:53:36 +02:00
1 parent 14c7099e3b
commit 3c2eefe7f4
3 files changed
+19 -5

No files matched your search

+13 -3
View File
@@ -12,9 +12,15 @@ namespace {
constexpr const char* kDefaultWallpaperPath = "0:/os/wallpapers/default.jpg";
// Screen-sized, already tinted pixels, so a re-login skips the JPEG decode and
// the rescale entirely. Kernel-protected (CAP_USER_ADMIN) because it is drawn
// on a screen that is about to take a password.
constexpr const char* kCachePath = "0:/config/wallpaper.cache";
// the rescale entirely. Kernel-protected (CAP_USER_ADMIN), along with its
// directory, because it is drawn on a screen that is about to take a password.
constexpr const char* kStateDir = "0:/state";
constexpr const char* kCacheDir = "0:/state/cache";
constexpr const char* kCachePath = "0:/state/cache/wallpaper.cache";
// Where the cache lived before it moved out of 0:/config. Deleted when the new
// one is first written so an upgraded install does not keep the stale copy.
constexpr const char* kLegacyCachePath = "0:/config/wallpaper.cache";
constexpr uint32_t kCacheMagic = 0x4350574DU; // "MWPC"
constexpr uint32_t kCacheVersion = 1;
@@ -137,6 +143,10 @@ void save_to_cache(const LoginState* ls, const char* srcPath,
header->overlayAlpha = kLoginOverlayAlpha;
montauk::strncpy(header->sourcePath, srcPath, sizeof(header->sourcePath));
montauk::fdelete(kLegacyCachePath);
montauk::fmkdir(kStateDir);
montauk::fmkdir(kCacheDir);
int fd = montauk::fcreate(kCachePath);
if (fd < 0) return; // read-only volume or no authority: not fatal
// One write, so the file is never briefly visible half-written and the