├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── blahaj.jpg ├── default.nix └── src ├── blahaj.h └── main.c /.gitignore: -------------------------------------------------------------------------------- 1 | /testmnt/ 2 | /build/ 3 | /.vscode/ 4 | /blahajfs -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Cynthia Revström 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | 3 | CFLAGS = -c $(shell pkg-config fuse --cflags) 4 | LDFLAGS = 5 | LIBS = $(shell pkg-config fuse --libs) 6 | 7 | BUILD := build/ 8 | SRC := src/ 9 | SRCS := $(wildcard $(SRC)*.c) 10 | OBJS := $(patsubst $(SRC)%.c,$(BUILD)%.o,$(SRCS)) 11 | 12 | MAIN := blahajfs 13 | 14 | all: $(MAIN) 15 | 16 | $(BUILD)%.o: $(SRC)%.c 17 | mkdir -p $(BUILD) 18 | $(CC) $(CFLAGS) -o $@ $< 19 | 20 | $(MAIN): $(OBJS) 21 | $(CC) $(LDFLAGS) -o $(MAIN) $(OBJS) $(LIBS) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # blahajfs - Every file is blåhaj 2 | 3 | ## Requirements 4 | 5 | - Every file is BLÅHAJ 6 | 7 | ## Time for initial development 8 | 2020-04-21 11:53 CET - 2020-04-21 12:51 CET 9 | 10 | ## Contributions 11 | 12 | - adisbladis: adding nix expression 13 | - vandry: Recognizing the experts in the Joint Photographic Experts Group. 14 | -------------------------------------------------------------------------------- /blahaj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitcynth/blahajfs/28352824335031b220de1d6900d89fed0c171d33/blahaj.jpg -------------------------------------------------------------------------------- /default.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import {} }: 2 | 3 | let 4 | 5 | inherit (pkgs) stdenv lib; 6 | 7 | in stdenv.mkDerivation { 8 | pname = "blahajfs"; 9 | version = "1337"; 10 | 11 | src = lib.cleanSource ./.; 12 | 13 | nativeBuildInputs = [ 14 | pkgs.pkg-config 15 | ]; 16 | 17 | buildInputs = [ 18 | pkgs.fuse 19 | ]; 20 | 21 | NIX_CFLAGS_COMPILE = "-D_FILE_OFFSET_BITS=64"; 22 | 23 | installPhase = '' 24 | runHook preinstall 25 | mkdir -p $out/bin 26 | install -D -m 755 blahajfs $out/bin/blahajfs 27 | runHook postInstall 28 | ''; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | #define FUSE_USE_VERSION 30 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "blahaj.h" 12 | 13 | char blahaj_text[] = "blahaj!\n"; 14 | 15 | static int is_jpeg(const char* path) { 16 | size_t l = strlen(path); 17 | if (l > 4 && (strcmp(path+l-5, ".jpeg") == 0)) return 1; 18 | if (l > 3 && (strcmp(path+l-4, ".jpg") == 0)) return 1; 19 | return 0; 20 | } 21 | 22 | static int do_getattr(const char* path, struct stat* st) { 23 | printf("[getattr] called, path: %s\n", path); 24 | 25 | st->st_uid = getuid(); 26 | st->st_gid = getgid(); 27 | st->st_atime = time(NULL); 28 | st->st_mtime = time(NULL); 29 | 30 | 31 | if (strcmp(path, "/") == 0) { 32 | st->st_mode = S_IFDIR | 0755; 33 | st->st_nlink = 2; 34 | } else { 35 | st->st_mode = S_IFREG | 0644; 36 | st->st_nlink = 1; 37 | if (is_jpeg(path)) { 38 | st->st_size = blahaj_jpeg_len; 39 | } else { 40 | st->st_size = strlen(blahaj_text); 41 | } 42 | } 43 | 44 | return 0; 45 | } 46 | 47 | static int do_readdir(const char* path, void* buffer, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info* fi) { 48 | printf("[readdir] called, path: %s\n", path); 49 | 50 | filler(buffer, ".", NULL, 0); 51 | filler(buffer, "..", NULL, 0); 52 | 53 | int i; 54 | for (i = 0; i < 10000; i++) { 55 | filler(buffer, "blahaj", NULL, 0); 56 | } 57 | 58 | return 0; 59 | } 60 | 61 | static int do_read(const char* path, char* buffer, size_t size, off_t offset, struct fuse_file_info* fi) { 62 | printf("[read] called, offset: %ld, path: %s\n", offset, path); 63 | 64 | if (is_jpeg(path)) { 65 | int sz = (size > (blahaj_jpeg_len - offset)) ? blahaj_jpeg_len - offset : size; 66 | memcpy(buffer, blahaj_jpeg + offset, sz); 67 | return sz; 68 | } else { 69 | int sz = (size > (strlen(blahaj_text) - offset)) ? strlen(blahaj_text) - offset : size; 70 | memcpy(buffer, blahaj_text + offset, sz); 71 | return sz; 72 | } 73 | 74 | return -1; 75 | } 76 | 77 | static struct fuse_operations operations = { 78 | .getattr = do_getattr, 79 | .readdir = do_readdir, 80 | .read = do_read, 81 | }; 82 | 83 | int main(int argc, char** argv) { 84 | printf("blahajfs - https://cynthia.re\n"); 85 | return fuse_main(argc, argv, &operations, NULL); 86 | } 87 | --------------------------------------------------------------------------------