Changeset View
Changeset View
Standalone View
Standalone View
lib/libsysdecode/mkioctls
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | BEGIN { | ||||
print "#include <netinet6/ip6_mroute.h>" | print "#include <netinet6/ip6_mroute.h>" | ||||
print "#include <stdio.h>" | print "#include <stdio.h>" | ||||
print "#include <cam/cam.h>" | print "#include <cam/cam.h>" | ||||
print "#include <cam/scsi/scsi_pass.h>" | print "#include <cam/scsi/scsi_pass.h>" | ||||
print "#include <stdbool.h>" | print "#include <stdbool.h>" | ||||
print "#include <stddef.h>" | print "#include <stddef.h>" | ||||
print "#include <stdint.h>" | print "#include <stdint.h>" | ||||
print "#include <sysdecode.h>" | print "#include <sysdecode.h>" | ||||
print "#ifdef ZFS" | |||||
print "#define boolean_t int" | |||||
print "#define hrtime_t int" | |||||
darius-dons.net.au: Isn't hrtime_t a long long? (probably only an issue on 32 bit platforms) | |||||
yuripvAuthorUnsubmitted Done Inline Actionsit shouldn't really matter what type is specified as long as preprocessor groks this header without including the ones that provide real boolean_t and hrtime_t as that conflicts with other required headers here -- we are only interested in iocs enum and don't really use anything else (and the library was successfully built for lib32). yuripv: it shouldn't really matter what type is specified as long as preprocessor groks this header… | |||||
darius-dons.net.auUnsubmitted Not Done Inline ActionsOK makes sense (I thought it might cause alignment problems.) darius-dons.net.au: OK makes sense (I thought it might cause alignment problems.) | |||||
print "#include <sys/fs/zfs.h>" | |||||
print "#endif" | |||||
print "" | print "" | ||||
print ioctl_includes | print ioctl_includes | ||||
print "" | print "" | ||||
print "const char *" | print "const char *" | ||||
print "sysdecode_ioctlname(unsigned long val)" | print "sysdecode_ioctlname(unsigned long val)" | ||||
print "{" | print "{" | ||||
print "\tconst char *str = NULL;" | print "\tconst char *str = NULL;" | ||||
print "" | print "" | ||||
} | } | ||||
/^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ { | /^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ { | ||||
# find where the name starts | # find where the name starts | ||||
for (i = 1; i <= NF; i++) | for (i = 1; i <= NF; i++) | ||||
if ($i ~ /define/) | if ($i ~ /define/) | ||||
break; | break; | ||||
++i; | ++i; | ||||
# | # | ||||
printf("\t"); | printf("\t"); | ||||
if (n++ > 0) | if (n++ > 0) | ||||
printf("else "); | printf("else "); | ||||
printf("if (val == %s)\n", $i); | printf("if (val == %s)\n", $i); | ||||
printf("\t\tstr = \"%s\";\n", $i); | printf("\t\tstr = \"%s\";\n", $i); | ||||
} | } | ||||
END { | |||||
print "" | |||||
print "\treturn (str);" | |||||
print "}" | |||||
} | |||||
' | ' | ||||
cyUnsubmitted Not Done Inline ActionsIsn't this misplaced now? cy: Isn't this misplaced now? | |||||
yuripvAuthorUnsubmitted Done Inline ActionsNo, awk part now prints the function header and "dynamic" ioctls, then we continue with zfs ones, and the print the function ending: ... else if (val == WDIOC_SETSOFTTIMEOUTACT) str = "WDIOC_SETSOFTTIMEOUTACT"; else if (val == WDIOC_SETTIMEOUT) str = "WDIOC_SETTIMEOUT"; else if ((val & 0xffff) == ZFS_IOC_BOOKMARK + ('Z' << 8)) str = "ZFS_IOC_BOOKMARK"; else if ((val & 0xffff) == ZFS_IOC_CHANGE_KEY + ('Z' << 8)) str = "ZFS_IOC_CHANGE_KEY"; ... yuripv: No, awk part now prints the function header and "dynamic" ioctls, then we continue with zfs… | |||||
# ZFS is special | |||||
if [ "${MK_ZFS}" = "yes" ]; then | |||||
sed -nE 's/^ (ZFS_IOC_[A-Z0-9_]+).*$/\1/p' ${ZFSINC}/sys/fs/zfs.h | | |||||
sort -u | grep -vE 'ZFS_IOC_(FIRST|LAST)' | | |||||
while read ioc; do | |||||
printf "\telse if ((val & 0xffff) == $ioc + ('Z' << 8))\n" | |||||
printf "\t\tstr = \"$ioc\";\n" | |||||
done | |||||
fi | |||||
printf "\n" | |||||
printf "\treturn (str);\n" | |||||
printf "}\n" |
Isn't hrtime_t a long long? (probably only an issue on 32 bit platforms)