1 #!nfsh
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 # Print the attributes of a given file or directory.
29
30 if { $argc != 2 } {
31 puts "Usage: $argv0 <hostname> <pathname>"
32 exit
33 }
34
35 set host [ lindex $argv 0 ]
36 set path [ path2comp [lindex $argv 1] "/" ]
37
38 #connect -t udp -p 9999 $host
39 connect $host
40
41 # Generate a compound request that obtains the attributes for the path.
42 # Try to get all attributes
43
44 set al "supported_attrs type fh_expire_type change size link_support
45 symlink_support named_attr fsid unique_handles lease_time rdattr_error
46 acl aclsupport archive cansettime case_insensitive case_preserving
47 chown_restricted filehandle fileid files_avail files_free files_total
48 fs_locations hidden homogeneous maxfilesize maxlink maxname maxread
49 maxwrite mimetype mode no_trunc numlinks owner owner_group
50 quota_avail_hard quota_avail_soft quota_used rawdev
51 space_avail space_free space_total space_used system time_access
52 time_backup time_create time_delta time_metadata time_modify "
53 set aln [llength $al]
54
55 # "time_access_set & time_modify_set" are for Setattr only; INVAL for Getattr
56
57 set fh [get_fh $path]
58 if {$fh == ""} {
59 puts stderr "ERROR: path=($path) not found in server=($host)."
60 exit 1
61 }
62 set res [compound {Putfh $fh;
63 for {set i 0} {$i < $aln} {incr i 3} {
64 Getattr [lrange $al $i [expr $i + 2]] }
65 }]
66 if {$status != "OK"} {
67 puts "ERROR: compound{} return status=$status"
68 puts " Res: $res"
69 exit 2
70 }
71
72 # build the result list:
73 set all_attr_res ""
74 foreach attr_res [lrange $res 1 end] {
75 set all_attr_res "$all_attr_res [lindex $attr_res 2]"
76 }
77
78
79 # Print all values of returned attributes;
80 puts "All attributes for \[[lindex $argv 1]\] are:"
81 prn_attrs $all_attr_res
82
83 disconnect
84 exit 0