Giving lfa flag "a" the same treatment as "i"

This commit is contained in:
2024-09-09 15:42:46 +02:00
parent 1ed76b7bdc
commit aa0d5d1309
5 changed files with 77 additions and 54 deletions

View File

@@ -940,15 +940,17 @@ int Linkitem_get_link_count(struct LinkiteM *item, int flag)
struct PermiteM {
char *disk_path;
struct stat stbuf;
int immutable; /* bit0= set chattr immutable bit
bit1= only set immutable bit
int chattr_flags; /* bit0= set chattr immutable bit
bit1= only set chattr bits
bit2= set chattr append-only bit
*/
struct PermiteM *next;
};
/* @param flag bit0= Linux chattr immutable bit is set
bit1= when popping only set immutable bit
bit1= when popping only set chattr bits
bit2= Linux chattr append-only bit is set
*/
int Permstack_push(struct PermiteM **o, char *disk_path, struct stat *stbuf,
int flag)
@@ -960,7 +962,7 @@ int Permstack_push(struct PermiteM **o, char *disk_path, struct stat *stbuf,
return(-1);
m->disk_path= NULL;
memcpy(&(m->stbuf), stbuf, sizeof(struct stat));
m->immutable= flag & 3;
m->chattr_flags= flag & 7;
m->next= *o;
m->disk_path= strdup(disk_path);
@@ -979,7 +981,7 @@ failed:;
/* @param flag bit0= minimal transfer: access permissions only
bit1= do not set timestamps
bit2= do not set chattr flag i "immutable"
bit2= do not set chattr flags
*/
int Permstack_pop(struct PermiteM **o, struct PermiteM *stopper,
struct XorrisO *xorriso, int flag)
@@ -1001,7 +1003,7 @@ int Permstack_pop(struct PermiteM **o, struct PermiteM *stopper,
}
for(m= *o; m!=stopper; m= m_next) {
if(!(m->immutable & 2)) {
if(!(m->chattr_flags & 2)) {
ret= chmod(m->disk_path, m->stbuf.st_mode);
if(ret==-1) {
if(xorriso!=NULL) {
@@ -1015,7 +1017,7 @@ int Permstack_pop(struct PermiteM **o, struct PermiteM *stopper,
}
}
if(!((flag & 1) || (m->immutable & 2))) {
if(!((flag & 1) || (m->chattr_flags & 2))) {
ret= chown(m->disk_path, m->stbuf.st_uid, m->stbuf.st_gid);
/* don't complain if it fails */
if(!(flag&2)) {
@@ -1032,9 +1034,10 @@ int Permstack_pop(struct PermiteM **o, struct PermiteM *stopper,
}
}
if((m->immutable & 1) && !(flag & 4)) {
if((m->chattr_flags & (1 | 4)) && !(flag & 4)) {
/* It seems tradition here to just complain but to go on to return 1 */
Xorriso_set_local_chattr_i(xorriso, m->disk_path, 0);
Xorriso_set_local_chattr_ia(xorriso, m->disk_path,
(m->chattr_flags & 1) | ((m->chattr_flags & 4) >> 1));
}
m_next= m->next;
@@ -1047,11 +1050,11 @@ int Permstack_pop(struct PermiteM **o, struct PermiteM *stopper,
/* Look for stack item with disk_path
@return 0= nothing found, 1= *stbuf and *immutable are valid
@return 0= nothing found, 1= *stbuf and *chattr_flags are valid
*/
int Permstack_peek(struct PermiteM **o, struct PermiteM *stopper,
struct XorrisO *xorriso,
char *disk_path, struct stat **stbuf, int *immutable,
char *disk_path, struct stat **stbuf, int *chattr_flags,
int flag)
{
struct PermiteM *m;
@@ -1061,7 +1064,7 @@ int Permstack_peek(struct PermiteM **o, struct PermiteM *stopper,
for(m= *o; m != NULL; m= m->next) {
if(strcmp(m->disk_path, disk_path) == 0) {
*stbuf= &(m->stbuf);
*immutable= m->immutable;
*chattr_flags= m->chattr_flags;
return(1);
}
if(m->next == stopper)