Archive-xattr-Patch
All checks were successful
Source release / source-package (push) Successful in 41s
All checks were successful
Source release / source-package (push) Successful in 41s
This commit is contained in:
@@ -57,7 +57,7 @@ ELSE(ENABLE_INTERNAL_RIP_SAP)
|
||||
ENDIF(ENABLE_INTERNAL_RIP_SAP)
|
||||
|
||||
add_executable(nwserv nwserv.c net1.c tools.c ${EMUTLI} ${EMUTLI1} ${NWROUTE_0} )
|
||||
add_executable(nwconn nwconn.c net1.c tools.c connect.c namspace.c nwvolume.c nwfile.c unxfile.c nwqconn.c nameos2.c namedos.c nwfname.c nwshare.c extpipe.c nwattrib.c trustee.c ${EMUTLI} )
|
||||
add_executable(nwconn nwconn.c net1.c tools.c connect.c namspace.c nwvolume.c nwfile.c unxfile.c nwqconn.c nameos2.c namedos.c nwfname.c nwshare.c extpipe.c nwattrib.c trustee.c nwarchive.c ${EMUTLI} )
|
||||
add_executable(ncpserv ncpserv.c net1.c tools.c ${EMUTLI} )
|
||||
add_executable(nwclient nwclient.c net1.c tools.c ${EMUTLI} )
|
||||
add_executable(nwbind nwbind.c net1.c tools.c nwdbm.c nwcrypt.c unxlog.c sema.c nwqueue.c unxfile.c ${EMUTLI} )
|
||||
@@ -73,7 +73,7 @@ add_executable(ftrustee ftrustee.c tools.c nwfname.c unxfile.c nwvolume.c nwattr
|
||||
##############
|
||||
|
||||
target_link_libraries(nwserv ${CRYPT_LIBRARIES} )
|
||||
target_link_libraries(nwconn ${CRYPT_LIBRARIES} )
|
||||
target_link_libraries(nwconn ${CRYPT_LIBRARIES} ${XATTR_LIBRARIES} )
|
||||
target_link_libraries(ncpserv ${CRYPT_LIBRARIES} )
|
||||
target_link_libraries(nwclient ${CRYPT_LIBRARIES} )
|
||||
target_link_libraries(nwbind ${CRYPT_LIBRARIES} ${GDBM_LIBRARIES} )
|
||||
|
||||
@@ -54,6 +54,7 @@ static int act_umode_file=0;
|
||||
#include "nwvolume.h"
|
||||
#include "nwshare.h"
|
||||
#include "nwattrib.h"
|
||||
#include "nwarchive.h"
|
||||
#include "trustee.h"
|
||||
#include "nwfile.h"
|
||||
#include "nwconn.h"
|
||||
@@ -1277,11 +1278,16 @@ static time_t nw_2_un_time_parts(uint16 xdate, uint16 xtime)
|
||||
return(mktime(&s_tm));
|
||||
}
|
||||
|
||||
#define DM_ARCHIVE_DATE 0x0020UL
|
||||
#define DM_ARCHIVE_TIME 0x0040UL
|
||||
#define DM_ARCHIVER_ID 0x0080UL
|
||||
#define DM_MODIFY_DATE 0x0100UL
|
||||
#define DM_MODIFY_TIME 0x0200UL
|
||||
#define DM_LAST_ACCESS_DATE 0x0800UL
|
||||
#define DM_NCP22_25_TIME_BITS \
|
||||
(DM_MODIFY_DATE | DM_MODIFY_TIME | DM_LAST_ACCESS_DATE)
|
||||
#define DM_NCP22_25_ARCHIVE_BITS \
|
||||
(DM_ARCHIVE_DATE | DM_ARCHIVE_TIME | DM_ARCHIVER_ID)
|
||||
|
||||
static int set_ncp22_25_times(int volume, char *unixname, struct stat *stb,
|
||||
NW_SET_DIR_INFO *f, uint32 change_mask,
|
||||
@@ -1342,6 +1348,40 @@ static int set_ncp22_25_times(int volume, char *unixname, struct stat *stb,
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int set_ncp22_25_archive_info(char *unixname,
|
||||
NW_SET_DIR_INFO *f,
|
||||
uint32 change_mask,
|
||||
int is_dir)
|
||||
{
|
||||
uint16 adate = 0;
|
||||
uint16 atime = 0;
|
||||
uint32 aid = 0;
|
||||
|
||||
if (!(change_mask & DM_NCP22_25_ARCHIVE_BITS))
|
||||
return(0);
|
||||
|
||||
if (is_dir) {
|
||||
if (change_mask & DM_ARCHIVE_DATE)
|
||||
adate = (uint16)GET_16(f->u.d.archived.date);
|
||||
if (change_mask & DM_ARCHIVE_TIME)
|
||||
atime = (uint16)GET_16(f->u.d.archived.time);
|
||||
if (change_mask & DM_ARCHIVER_ID)
|
||||
aid = GET_BE32(f->u.d.archived.id);
|
||||
} else {
|
||||
if (change_mask & DM_ARCHIVE_DATE)
|
||||
adate = (uint16)GET_16(f->u.f.archived.date);
|
||||
if (change_mask & DM_ARCHIVE_TIME)
|
||||
atime = (uint16)GET_16(f->u.f.archived.time);
|
||||
if (change_mask & DM_ARCHIVER_ID)
|
||||
aid = GET_BE32(f->u.f.archived.id);
|
||||
}
|
||||
|
||||
return(mars_nwe_set_archive_info(unixname,
|
||||
!!(change_mask & DM_ARCHIVE_DATE), adate,
|
||||
!!(change_mask & DM_ARCHIVE_TIME), atime,
|
||||
!!(change_mask & DM_ARCHIVER_ID), aid));
|
||||
}
|
||||
|
||||
static int get_file_attrib(NW_FILE_INFO *f, char *unixname, struct stat *stb,
|
||||
NW_PATH *nwpath)
|
||||
{
|
||||
@@ -2861,6 +2901,17 @@ void get_dos_file_attrib(NW_DOS_FILE_INFO *f,
|
||||
un_time_2_nw(stb->st_mtime, f->created.time, 0);
|
||||
U32_TO_BE32(nw_owner, f->created.id);
|
||||
|
||||
{
|
||||
uint16 archive_date = 0;
|
||||
uint16 archive_time = 0;
|
||||
uint32 archiver_id = 0;
|
||||
mars_nwe_get_archive_info(unixname, &archive_date, &archive_time,
|
||||
&archiver_id, NULL);
|
||||
U16_TO_16(archive_date, f->archived.date);
|
||||
U16_TO_16(archive_time, f->archived.time);
|
||||
U32_TO_BE32(archiver_id, f->archived.id);
|
||||
}
|
||||
|
||||
un_date_2_nw(stb->st_mtime, f->updated.date, 0);
|
||||
un_time_2_nw(stb->st_mtime, f->updated.time, 0);
|
||||
U32_TO_BE32(nw_owner, f->updated.id);
|
||||
@@ -2888,6 +2939,16 @@ void get_dos_dir_attrib(NW_DOS_DIR_INFO *f,
|
||||
un_date_2_nw(stb->st_mtime, f->created.date,0);
|
||||
un_time_2_nw(stb->st_mtime, f->created.time,0);
|
||||
U32_TO_BE32(get_file_owner(stb), f->created.id);
|
||||
{
|
||||
uint16 archive_date = 0;
|
||||
uint16 archive_time = 0;
|
||||
uint32 archiver_id = 0;
|
||||
mars_nwe_get_archive_info(unixname, &archive_date, &archive_time,
|
||||
&archiver_id, NULL);
|
||||
U16_TO_16(archive_date, f->archived.date);
|
||||
U16_TO_16(archive_time, f->archived.time);
|
||||
U32_TO_BE32(archiver_id, f->archived.id);
|
||||
}
|
||||
un_date_2_nw(stb->st_mtime, f->modify_date, 0);
|
||||
un_time_2_nw(stb->st_mtime, f->modify_time, 0);
|
||||
U32_TO_BE32(MAX_U32, f->max_space);
|
||||
@@ -2995,6 +3056,10 @@ int nw_set_a_directory_entry(int dirhandle,
|
||||
else if (change_mask & DM_NCP22_25_TIME_BITS)
|
||||
s_stat(unixname, &stbuff, NULL);
|
||||
}
|
||||
if (!completition) {
|
||||
completition=set_ncp22_25_archive_info(unixname, f, change_mask,
|
||||
S_ISDIR(stbuff.st_mode));
|
||||
}
|
||||
if (S_ISDIR(stbuff.st_mode)) {
|
||||
if (change_mask & 0x1000) {
|
||||
int result=tru_set_inherited_mask(nwpath.volume, unixname,
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "nwvolume.h"
|
||||
#include "connect.h"
|
||||
#include "nwattrib.h"
|
||||
#include "nwarchive.h"
|
||||
#include "trustee.h"
|
||||
#include "nwconn.h"
|
||||
#include "nwfile.h"
|
||||
@@ -1115,11 +1116,16 @@ static int build_dir_info(DIR_BASE_ENTRY *dbe,
|
||||
} else p+=10;
|
||||
|
||||
if (infomask & INFO_MSK_ARCHIVE_INFO) {
|
||||
un_time_2_nw(0, p, 0);
|
||||
uint16 archive_date = 0;
|
||||
uint16 archive_time = 0;
|
||||
uint32 archiver_id = 0;
|
||||
mars_nwe_get_archive_info(unixname, &archive_date, &archive_time,
|
||||
&archiver_id, NULL);
|
||||
U16_TO_16(archive_time, p);
|
||||
p +=2;
|
||||
un_date_2_nw(0, p, 0);
|
||||
U16_TO_16(archive_date, p);
|
||||
p +=2;
|
||||
U32_TO_BE32(0, p); /* HI-LOW */
|
||||
U32_TO_BE32(archiver_id, p); /* HI-LOW */
|
||||
p +=4;
|
||||
} else p+=8;
|
||||
|
||||
|
||||
126
src/nwarchive.c
Normal file
126
src/nwarchive.c
Normal file
@@ -0,0 +1,126 @@
|
||||
/* nwarchive.c - mars_nwe private archive metadata helpers */
|
||||
#include "net.h"
|
||||
#include "nwarchive.h"
|
||||
|
||||
#if XATTR_SUPPORT
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/xattr.h>
|
||||
#endif
|
||||
|
||||
#define MARS_NWE_ARCHIVE_XATTR "user.mars_nwe.archive"
|
||||
#define MARS_NWE_ARCHIVE_VERSION 1
|
||||
|
||||
typedef struct {
|
||||
uint8 version;
|
||||
uint8 flags;
|
||||
uint8 archive_date[2];
|
||||
uint8 archive_time[2];
|
||||
uint8 archiver_id[4];
|
||||
} MARS_NWE_ARCHIVE_XATTR_DATA;
|
||||
|
||||
static void init_archive_data(MARS_NWE_ARCHIVE_XATTR_DATA *d)
|
||||
{
|
||||
memset(d, 0, sizeof(*d));
|
||||
d->version = MARS_NWE_ARCHIVE_VERSION;
|
||||
}
|
||||
|
||||
static void read_archive_data(MARS_NWE_ARCHIVE_XATTR_DATA *d,
|
||||
uint16 *archive_date,
|
||||
uint16 *archive_time,
|
||||
uint32 *archiver_id,
|
||||
uint8 *flags)
|
||||
{
|
||||
if (flags)
|
||||
*flags = d->flags;
|
||||
if (archive_date)
|
||||
*archive_date = (d->flags & MARS_NWE_ARCHIVE_HAS_DATE)
|
||||
? (uint16)GET_16(d->archive_date) : 0;
|
||||
if (archive_time)
|
||||
*archive_time = (d->flags & MARS_NWE_ARCHIVE_HAS_TIME)
|
||||
? (uint16)GET_16(d->archive_time) : 0;
|
||||
if (archiver_id)
|
||||
*archiver_id = (d->flags & MARS_NWE_ARCHIVE_HAS_ARCHIVER)
|
||||
? GET_BE32(d->archiver_id) : 0;
|
||||
}
|
||||
|
||||
#if XATTR_SUPPORT
|
||||
static int get_archive_data(char *unixname, MARS_NWE_ARCHIVE_XATTR_DATA *d)
|
||||
{
|
||||
ssize_t len;
|
||||
|
||||
init_archive_data(d);
|
||||
if (!unixname || !*unixname)
|
||||
return(-1);
|
||||
|
||||
len = getxattr(unixname, MARS_NWE_ARCHIVE_XATTR, d, sizeof(*d));
|
||||
if (len != sizeof(*d) || d->version != MARS_NWE_ARCHIVE_VERSION) {
|
||||
init_archive_data(d);
|
||||
return(-1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void mars_nwe_get_archive_info(char *unixname,
|
||||
uint16 *archive_date,
|
||||
uint16 *archive_time,
|
||||
uint32 *archiver_id,
|
||||
uint8 *flags)
|
||||
{
|
||||
MARS_NWE_ARCHIVE_XATTR_DATA d;
|
||||
|
||||
#if XATTR_SUPPORT
|
||||
(void)get_archive_data(unixname, &d);
|
||||
#else
|
||||
(void)unixname;
|
||||
init_archive_data(&d);
|
||||
#endif
|
||||
read_archive_data(&d, archive_date, archive_time, archiver_id, flags);
|
||||
}
|
||||
|
||||
int mars_nwe_set_archive_info(char *unixname,
|
||||
int set_date, uint16 archive_date,
|
||||
int set_time, uint16 archive_time,
|
||||
int set_archiver, uint32 archiver_id)
|
||||
{
|
||||
#if XATTR_SUPPORT
|
||||
MARS_NWE_ARCHIVE_XATTR_DATA d;
|
||||
|
||||
(void)get_archive_data(unixname, &d);
|
||||
|
||||
if (set_date) {
|
||||
U16_TO_16(archive_date, d.archive_date);
|
||||
d.flags |= MARS_NWE_ARCHIVE_HAS_DATE;
|
||||
}
|
||||
if (set_time) {
|
||||
U16_TO_16(archive_time, d.archive_time);
|
||||
d.flags |= MARS_NWE_ARCHIVE_HAS_TIME;
|
||||
}
|
||||
if (set_archiver) {
|
||||
U32_TO_BE32(archiver_id, d.archiver_id);
|
||||
d.flags |= MARS_NWE_ARCHIVE_HAS_ARCHIVER;
|
||||
}
|
||||
|
||||
if (!unixname || !*unixname)
|
||||
return(0);
|
||||
|
||||
if (setxattr(unixname, MARS_NWE_ARCHIVE_XATTR, &d, sizeof(d), 0)) {
|
||||
int err = errno;
|
||||
/* Compatibility rule: NetWare archive metadata has no POSIX field.
|
||||
* If Linux xattrs are unavailable or rejected, keep the NCP call
|
||||
* successful and only log that the extra metadata was not stored.
|
||||
*/
|
||||
XDPRINTF((5,0,"mars_nwe archive xattr ignored for %s errno=%d", unixname, err));
|
||||
}
|
||||
#else
|
||||
(void)unixname;
|
||||
(void)set_date;
|
||||
(void)archive_date;
|
||||
(void)set_time;
|
||||
(void)archive_time;
|
||||
(void)set_archiver;
|
||||
(void)archiver_id;
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
Reference in New Issue
Block a user