X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fsrc%2Flsxid.c;h=a3064cd1c6053f6334c17be88f255e4d7ca6071f;hb=0f36b4df430d2619cc3f10647e1762e7493f43fc;hp=5388f1a4ba4a31b39b04b95dae89732c36dc9c7a;hpb=8b8d663cd844948ab38f43b94540a62ab533cabd;p=util-vserver.git diff --git a/util-vserver/src/lsxid.c b/util-vserver/src/lsxid.c index 5388f1a..a3064cd 100644 --- a/util-vserver/src/lsxid.c +++ b/util-vserver/src/lsxid.c @@ -80,24 +80,14 @@ fixupParams(struct Arguments UNUSED * args, int UNUSED argc) static xid_t getFileContext(char const *name, struct stat const *exp_st) { - int fd = open(name, O_RDONLY); xid_t res; + uint32_t mask = VC_IATTR_XID; - if (fd==-1) { - perror("open()"); - return VC_NOCTX; - } - - if (exp_st) - checkForRace(fd, name, exp_st); - - res = vc_X_get_filecontext(fd); - if (res==VC_NOCTX) - perror("vc_X_get_filecontext()"); - - close(fd); + if (vc_get_iattr_compat(name, exp_st->st_dev, exp_st->st_ino, + &res, 0, &mask, &exp_st->st_mode)==-1) + perror("vc_get_iattr_compat()"); - return res; + return (mask&VC_IATTR_XID) ? res : VC_NOCTX; } bool @@ -110,31 +100,24 @@ handleFile(char const *name, char const *display_name, memset(buf, ' ', sizeof buf); - if (!S_ISREG(exp_st->st_mode)) { - memcpy(buf, "-------", 7); + ctx = getFileContext(name, exp_st); + + if (ctx==VC_NOCTX) { + memcpy(buf, "!!ERR!!", 7); write(1, buf, sizeof buf); need_write = false; } - else { - ctx = getFileContext(name, exp_st); - - if (ctx==VC_NOCTX) { - memcpy(buf, "!!ERR!!", 7); - write(1, buf, sizeof buf); + else if (global_args->do_mapping) { + char const * vname = vc_getVserverByCtx(ctx, 0,0); + if (!vname) buf[0] = '\0'; + else { + size_t l = strlen(vname); + if (ldo_mapping) { - char const * vname = vc_getVserverByCtx(ctx, 0,0); - if (!vname) buf[0] = '\0'; - else { - size_t l = strlen(vname); - if (l