Skip to content

Commit

Permalink
Minor changes to struct headers // Defined commands target in Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
jivanpal committed Dec 2, 2020
1 parent 5c789b3 commit 7784935
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,26 @@ LDFLAGS=$(FLAGS)
SRCDIR=src
OUTDIR=out

### Target paths ###
PROGRAMS := $(wildcard $(SRCDIR)/*.c)
BINARIES := $(PROGRAMS:$(SRCDIR)/%.c=%)
### Source paths ###
HEADERS := $(shell find $(SRCDIR) -name '*.h')
SOURCES := $(shell find $(SRCDIR) -name '*.c')
CMD_SRCS := $(wildcard $(SRCDIR)/commands/*.c)
BIN_SRCS := $(wildcard $(SRCDIR)/*.c)

HEADERS := $(shell find src -name '*.h')
# Target paths
GCHS := $(HEADERS:$(SRCDIR)/%.h=$(OUTDIR)/%.gch)
SOURCES := $(shell find src -name '*.c')
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OUTDIR)/%.o)
COMMANDS := $(CMD_SRCS:$(SRCDIR)/commands/%.c=%)
BINARIES := $(BIN_SRCS:$(SRCDIR)/%.c=%)

### Targets ###

.PHONY: binaries
binaries: $(BINARIES)

.PHONY: commands
commands: $(COMMANDS)

.PHONY: headers
headers: $(GCHS)

Expand All @@ -32,6 +38,9 @@ $(BINARIES): %: $(OUTDIR)/%.o $(OBJECTS)
$(LD) $^ $(LDFLAGS) -o $@
@echo

# Make `<command_name>` an alias of `out/commands/<command_name>.o`
$(COMMANDS): %: $(OUTDIR)/commands/%.o

$(OBJECTS): $(OUTDIR)/%.o: $(SRCDIR)/%.c $(HEADERS)
@echo "OBJECTS +++ $< +++ $@"
@[ -d $(@D) ] || (mkdir -p $(@D) && echo "Created directory \`$(@D)\`.")
Expand Down
2 changes: 1 addition & 1 deletion src/apfs/struct/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "general.h" // for `uuid_t`
#include "object.h" // for `obj_phys_t`
#include "j.h" // for `j_key_t`
// #include "cryptotypes.h" // `j.h` suffices to include `cryptotypes.h`
#include "cryptotypes.h"

/** `j_crypto_key_t` **/

Expand Down
8 changes: 4 additions & 4 deletions src/apfs/struct/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "general.h" // for `uuid_t`
#include "object.h" // for `obj_phys_t`, `oid_t`, `xid_t`
#include "crypto.h"
#include "crypto.h" // for `wrapped_meta_crypto_state_t`

/** `apfs_modified_by_t` --- forward declared for `apfs_superblock_t` **/

Expand All @@ -27,10 +27,10 @@ typedef struct {
#define APFS_VOLNAME_LEN 256

typedef struct {
obj_phys_t apfs_o;
obj_phys_t apfs_o;

uint32_t apfs_magic;
uint32_t apfs_fs_index;
uint32_t apfs_magic;
uint32_t apfs_fs_index;

uint64_t apfs_features;
uint64_t apfs_readonly_compatible_features;
Expand Down
11 changes: 3 additions & 8 deletions src/apfs/struct/j.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ typedef struct {
int32_t nlink;
};

// TODO: define `cp_key_class_t`
cp_key_class_t default_protection_class;
uint32_t write_generation_counter;
uint32_t bsd_flags;
Expand All @@ -62,12 +61,7 @@ typedef struct {

typedef struct {
j_key_t hdr;
uint16_t name_len;
/*
* TODO: Above may be `uint32_t len_name_and_hash`?
* Spec contradicts itself; investigate this --
* Likely a typo inherited from `j_drec_hashed_key_t` definition.
*/
uint16_t name_len; // NOTE: Not `name_len_and_hash` as the spec erroneously says.
uint8_t name[0];
} __attribute__((packed)) j_drec_key_t;

Expand All @@ -76,7 +70,8 @@ typedef struct {
* `APFS_TYPE_DIR_REC`, then the record's key is an instance of `j_drec_key_t`.
* However, the type `j_drec_hashed_key_t` (seen below) is defined in the spec
* but not used anywhere in the spec; and upon closer inspection, the keys I
* have encountered in practice exclusively appear to be instances of this type.
* have encountered in practice exclusively appear to be instances of
* `j_drec_hased_key_t`.
*
* As such, either:
* (a) `j_drec_key_t` has been silently deprecated as of 2019-10-31 and replaced
Expand Down

0 comments on commit 7784935

Please sign in to comment.