Skip to content

Commit 7841b58

Browse files
committed
tool: show quota projid in "casync stat" data
1 parent f8299df commit 7841b58

File tree

7 files changed

+68
-0
lines changed

7 files changed

+68
-0
lines changed

src/cadecoder.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4928,6 +4928,25 @@ int ca_decoder_current_xattr(CaDecoder *d, CaIterate where, const char **ret_nam
49284928
return 0;
49294929
}
49304930

4931+
int ca_decoder_current_quota_projid(CaDecoder *d, uint32_t *ret) {
4932+
CaDecoderNode *n;
4933+
4934+
if (!d)
4935+
return -EINVAL;
4936+
if (!ret)
4937+
return -EINVAL;
4938+
4939+
n = ca_decoder_current_node(d);
4940+
if (!n)
4941+
return -EUNATCH;
4942+
4943+
if (!n->have_quota_projid)
4944+
return -ENODATA;
4945+
4946+
*ret = n->quota_projid;
4947+
return 0;
4948+
}
4949+
49314950
int ca_decoder_current_offset(CaDecoder *d, uint64_t *ret) {
49324951
CaDecoderNode *n;
49334952
mode_t mode;

src/cadecoder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ int ca_decoder_current_offset(CaDecoder *d, uint64_t *ret);
100100
int ca_decoder_current_chattr(CaDecoder *d, unsigned *ret);
101101
int ca_decoder_current_fat_attrs(CaDecoder *d, uint32_t *ret);
102102
int ca_decoder_current_xattr(CaDecoder *d, CaIterate where, const char **ret_name, const void **ret_value, size_t *ret_size);
103+
int ca_decoder_current_quota_projid(CaDecoder *d, uint32_t *ret);
103104

104105
/* Seeking to positions */
105106
int ca_decoder_seek_offset(CaDecoder *d, uint64_t offset);

src/caencoder.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3333,6 +3333,25 @@ int ca_encoder_current_xattr(CaEncoder *e, CaIterate where, const char **ret_nam
33333333
return 0;
33343334
}
33353335

3336+
int ca_encoder_current_quota_projid(CaEncoder *e, uint32_t *ret) {
3337+
CaEncoderNode *n;
3338+
3339+
if (!e)
3340+
return -EINVAL;
3341+
if (!ret)
3342+
return -EINVAL;
3343+
3344+
n = ca_encoder_current_node(e);
3345+
if (!n)
3346+
return -EUNATCH;
3347+
3348+
if (!n->quota_projid_valid)
3349+
return -ENODATA;
3350+
3351+
*ret = n->quota_projid;
3352+
return 0;
3353+
}
3354+
33363355
int ca_encoder_current_payload_offset(CaEncoder *e, uint64_t *ret) {
33373356
CaEncoderNode *n;
33383357

src/caencoder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ int ca_encoder_current_rdev(CaEncoder *e, dev_t *ret);
5454
int ca_encoder_current_chattr(CaEncoder *e, unsigned *ret);
5555
int ca_encoder_current_fat_attrs(CaEncoder *e, uint32_t *ret);
5656
int ca_encoder_current_xattr(CaEncoder *e, CaIterate where, const char **ret_name, const void **ret_value, size_t *ret_size);
57+
int ca_encoder_current_quota_projid(CaEncoder *e, uint32_t *ret);
5758

5859
int ca_encoder_current_payload_offset(CaEncoder *e, uint64_t *ret);
5960
int ca_encoder_current_archive_offset(CaEncoder *e, uint64_t *ret);

src/casync-tool.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,6 +1773,8 @@ static int list_one_file(const char *arg0, CaSync *s, bool *toplevel_shown) {
17731773
char ls_mode[LS_FORMAT_MODE_MAX], ls_flags[LS_FORMAT_CHATTR_MAX], ls_fat_attrs[LS_FORMAT_FAT_ATTRS_MAX];
17741774
uid_t uid = UID_INVALID;
17751775
gid_t gid = GID_INVALID;
1776+
uint32_t quota_projid;
1777+
bool has_quota_projid;
17761778
dev_t rdev = (dev_t) -1;
17771779
unsigned flags = (unsigned) -1;
17781780
uint32_t fat_attrs = (uint32_t) -1;
@@ -1795,6 +1797,8 @@ static int list_one_file(const char *arg0, CaSync *s, bool *toplevel_shown) {
17951797
(void) ca_sync_current_fat_attrs(s, &fat_attrs);
17961798
(void) ca_sync_current_archive_offset(s, &offset);
17971799

1800+
has_quota_projid = ca_sync_current_quota_projid(s, &quota_projid) >= 0;
1801+
17981802
if (mtree_escape(path, &escaped) < 0)
17991803
return log_oom();
18001804

@@ -1868,6 +1872,9 @@ static int list_one_file(const char *arg0, CaSync *s, bool *toplevel_shown) {
18681872
escaped = mfree(escaped);
18691873
}
18701874

1875+
if (has_quota_projid)
1876+
printf(" ProjID: %" PRIu32 "\n", quota_projid);
1877+
18711878
if (target) {
18721879
if (mtree_escape(target, &escaped) < 0)
18731880
return log_oom();

src/casync.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3726,6 +3726,26 @@ int ca_sync_current_xattr(CaSync *s, CaIterate where, const char **ret_name, con
37263726
return -ENOTTY;
37273727
}
37283728

3729+
int ca_sync_current_quota_projid(CaSync *s, uint32_t *ret) {
3730+
CaSeed *seed;
3731+
3732+
if (!s)
3733+
return -EINVAL;
3734+
if (!ret)
3735+
return -EINVAL;
3736+
3737+
seed = ca_sync_current_seed(s);
3738+
if (seed)
3739+
return -ENODATA;
3740+
3741+
if (s->direction == CA_SYNC_ENCODE && s->encoder)
3742+
return ca_encoder_current_quota_projid(s->encoder, ret);
3743+
if (s->direction == CA_SYNC_DECODE && s->decoder)
3744+
return ca_decoder_current_quota_projid(s->decoder, ret);
3745+
3746+
return -ENOTTY;
3747+
}
3748+
37293749
static int ca_sync_add_pollfd(CaRemote *rr, struct pollfd *pollfd) {
37303750
int r;
37313751

src/casync.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ int ca_sync_current_rdev(CaSync *sync, dev_t *ret);
108108
int ca_sync_current_chattr(CaSync *sync, unsigned *ret);
109109
int ca_sync_current_fat_attrs(CaSync *sync, uint32_t *ret);
110110
int ca_sync_current_xattr(CaSync *sync, CaIterate where, const char **ret_name, const void **ret_value, size_t *ret_size);
111+
int ca_sync_current_quota_projid(CaSync *s, uint32_t *ret);
111112

112113
int ca_sync_get_archive_size(CaSync *s, uint64_t *ret);
113114

0 commit comments

Comments
 (0)