Skip to content

Commit

Permalink
Merge pull request #59 from pcercuei/add-removable-flag
Browse files Browse the repository at this point in the history
Add "removable" flag to storages
  • Loading branch information
jfdelnero committed Apr 1, 2021
2 parents 7f7e5ee + e275776 commit fdf141b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions inc/mtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ typedef struct mtp_storage_
uint32_t flags;
}mtp_storage;

#define UMTP_STORAGE_REMOVABLE 0x00000004
#define UMTP_STORAGE_NOTMOUNTED 0x00000002
#define UMTP_STORAGE_READONLY 0x00000001
#define UMTP_STORAGE_READWRITE 0x00000000
Expand Down
5 changes: 5 additions & 0 deletions src/mtp_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ static int get_storage_params(mtp_ctx * context, char * line,int cmd)
{
flags |= UMTP_STORAGE_NOTMOUNTED;
}

if(test_flag(options, "removable"))
{
flags |= UMTP_STORAGE_REMOVABLE;
}
}

PRINT_MSG("Add storage %s - Root Path: %s - Flags: 0x%.8X", storagename, storagepath,flags);
Expand Down
8 changes: 7 additions & 1 deletion src/mtp_datasets.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,23 @@ int build_storageinfo_dataset(mtp_ctx * ctx,void * buffer, int maxsize,uint32_t
uint64_t freespace = 0x4000000000000000U;
uint64_t totalspace = 0x8000000000000000U;
uint32_t storage_flags;
uint16_t storage_type;

ofs = 0;

storage_description = mtp_get_storage_description(ctx,storageid);
storage_path = mtp_get_storage_root(ctx, storageid);
storage_flags = mtp_get_storage_flags(ctx, storageid);

if (storage_flags & UMTP_STORAGE_REMOVABLE)
storage_type = MTP_STORAGE_REMOVABLE_RAM;
else
storage_type = MTP_STORAGE_FIXED_RAM;

if(storage_description && storage_path)
{
PRINT_DEBUG("Add storageinfo for %s", storage_path);
ofs = poke16(buffer, ofs, maxsize, MTP_STORAGE_FIXED_RAM); // Storage Type
ofs = poke16(buffer, ofs, maxsize, storage_type); // Storage Type
ofs = poke16(buffer, ofs, maxsize, MTP_STORAGE_FILESYSTEM_HIERARCHICAL); // Filesystem Type

// Access Capability
Expand Down

0 comments on commit fdf141b

Please sign in to comment.