mirror of
https://github.com/siderolabs/talos.git
synced 2026-05-05 04:16:21 +02:00
feat: print uid/gid for the files in ls -l
This adds information about file ownership in the long listing which is crucial sometimes. Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
This commit is contained in:
parent
e6fa401b66
commit
dadaa65d54
@ -363,6 +363,10 @@ message FileInfo {
|
||||
string link = 8;
|
||||
// RelativeName is the name of the file or directory relative to the RootPath
|
||||
string relative_name = 9;
|
||||
// Owner uid
|
||||
uint32 uid = 10;
|
||||
// Owner gid
|
||||
uint32 gid = 11;
|
||||
}
|
||||
|
||||
// DiskUsageInfo describes a file or directory's information for du command
|
||||
|
||||
@ -127,7 +127,7 @@ var lsCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
|
||||
fmt.Fprintln(w, "NODE\tMODE\tSIZE(B)\tLASTMOD\tNAME")
|
||||
fmt.Fprintln(w, "NODE\tMODE\tUID\tGID\tSIZE(B)\tLASTMOD\tNAME")
|
||||
for {
|
||||
info, err := stream.Recv()
|
||||
if err != nil {
|
||||
@ -179,9 +179,11 @@ var lsCmd = &cobra.Command{
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n",
|
||||
fmt.Fprintf(w, "%s\t%s\t%d\t%d\t%s\t%s\t%s\n",
|
||||
node,
|
||||
os.FileMode(info.Mode).String(),
|
||||
info.Uid,
|
||||
info.Gid,
|
||||
size,
|
||||
timestampFormatted,
|
||||
display,
|
||||
|
||||
@ -779,6 +779,8 @@ func (s *Server) List(req *machine.ListRequest, obj machine.MachineService_ListS
|
||||
Modified: fi.FileInfo.ModTime().Unix(),
|
||||
IsDir: fi.FileInfo.IsDir(),
|
||||
Link: fi.Link,
|
||||
Uid: fi.FileInfo.Sys().(*syscall.Stat_t).Uid,
|
||||
Gid: fi.FileInfo.Sys().(*syscall.Stat_t).Gid,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -85,7 +85,7 @@ func (suite *DiskUsageSuite) TestSuccess() {
|
||||
|
||||
parts := splitLine(lines[1])
|
||||
var err error
|
||||
folderSize, err = strconv.ParseInt(parts[2], 10, 64)
|
||||
folderSize, err = strconv.ParseInt(parts[4], 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -2516,6 +2516,16 @@ func (m *FileInfo) MarshalToSizedBufferVT(dAtA []byte) (int, error) {
|
||||
i -= len(m.unknownFields)
|
||||
copy(dAtA[i:], m.unknownFields)
|
||||
}
|
||||
if m.Gid != 0 {
|
||||
i = encodeVarint(dAtA, i, uint64(m.Gid))
|
||||
i--
|
||||
dAtA[i] = 0x58
|
||||
}
|
||||
if m.Uid != 0 {
|
||||
i = encodeVarint(dAtA, i, uint64(m.Uid))
|
||||
i--
|
||||
dAtA[i] = 0x50
|
||||
}
|
||||
if len(m.RelativeName) > 0 {
|
||||
i -= len(m.RelativeName)
|
||||
copy(dAtA[i:], m.RelativeName)
|
||||
@ -8895,6 +8905,12 @@ func (m *FileInfo) SizeVT() (n int) {
|
||||
if l > 0 {
|
||||
n += 1 + l + sov(uint64(l))
|
||||
}
|
||||
if m.Uid != 0 {
|
||||
n += 1 + sov(uint64(m.Uid))
|
||||
}
|
||||
if m.Gid != 0 {
|
||||
n += 1 + sov(uint64(m.Gid))
|
||||
}
|
||||
if m.unknownFields != nil {
|
||||
n += len(m.unknownFields)
|
||||
}
|
||||
@ -16553,6 +16569,44 @@ func (m *FileInfo) UnmarshalVT(dAtA []byte) error {
|
||||
}
|
||||
m.RelativeName = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 10:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Uid", wireType)
|
||||
}
|
||||
m.Uid = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Uid |= uint32(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 11:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Gid", wireType)
|
||||
}
|
||||
m.Gid = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Gid |= uint32(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skip(dAtA[iNdEx:])
|
||||
|
||||
@ -1230,6 +1230,8 @@ TODO: unix timestamp or include proto's Date type |
|
||||
| error | [string](#string) | | Error describes any error encountered while trying to read the file information. |
|
||||
| link | [string](#string) | | Link is filled with symlink target |
|
||||
| relative_name | [string](#string) | | RelativeName is the name of the file or directory relative to the RootPath |
|
||||
| uid | [uint32](#uint32) | | Owner uid |
|
||||
| gid | [uint32](#uint32) | | Owner gid |
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user