diff options
| author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2019-07-08 11:54:30 +0000 |
|---|---|---|
| committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2019-07-08 11:54:30 +0000 |
| commit | 374965e669006070cff81f276f2e13f54c6d9d51 (patch) | |
| tree | c1d4b02e6e03da4d07e6cb1aeb72d38fdf8eca30 | |
| parent | b69647d3aacd223817db151e369b34ec2471cf28 (diff) | |
| parent | c8d9a41c357577f316e58fb2603f85c598f01afb (diff) | |
| download | illumos-joyent-374965e669006070cff81f276f2e13f54c6d9d51.tar.gz | |
[illumos-gate merge]
commit c8d9a41c357577f316e58fb2603f85c598f01afb
11243 Unused headers under usr/src/uts/sun4u/sys
commit 2dda0e7f85eecc34a1f266469e66651eab1fa7ce
11242 Unused files in usr/src/cmd/logins
commit 6da5c920d0507dbc9e0e4416dcb9457827560df9
11241 usr/src/lib/libpkg/THIRDPARTYLICENSE.descrip is unused
commit 5abf55fdc38fe5c2d8881a37a662d372c23fd0aa
11240 usr/src/pkg/proto_list_ihv_i386 is unused
commit 57884e4a5db25b4d70c3565a0e07980fd7820c1e
11302 csh: NULL pointer errors
commit 4c719f3bd8ab1791d6763012560603c65390008c
11301 cpio: NULL pointer errors
commit ee0bd0a5a4b4a9cdbe27d56415fe460db258a9ef
11331 A typo in usr/src/man/man1/ls.1
commit 3fa8bc2d19bd24fbc2061549c236b6f7573471e8
11325 SES-3 element index handling incorrect
commit 3d4dea7f235476fb40c0a6d84dcedfd04740f96b
11299 csplit: NULL pointer errors
commit d95bfcb7b300250d00a64080d6da927b04ac4697
11298 consadm: NULL pointer errors
commit 0f063ce817df80cc8fb489abe02246d3d750d2fd
11297 chmod: NULL pointer errors
commit 95c745183e701047fab8e4753d4e8bc1dd1323e7
11296 cmd-inet: NULL pointer errors
commit 89b213ac9ac098a69d51b5e8693bd6b8d51864a8
11314 Provide psm_get_ipivect even on single CPU systems
commit 619456cb54d66ca9736dc29a93b6bb375f41db14
11321 eeprom: NULL pointer errors
commit eeec397864011c5afca614fe1353754d7a9d852f
11320 diskinfo: NULL pointer errors
commit 5f8fc372c68f2e0f1544c42850078877e5e2da3a
11318 svc: NULL pointer errors
commit ff8e166f73f3bfaeac25d65662c6469130892500
11312 dladm: NULL pointer errors
commit 1376f37367e2b1424b82940f492f2ed488f1b843
11311 devctl: NULL pointer errors
commit e4fb8a5fd5bb5a5d316430c6ac8f6d33704fcf5d
11295 lp: NULL pointer errors
commit 07c94cbf80ccbba93ea61425c2074f6bfd608a19
11294 abi: NULL pointer errors
commit beb02e13b243c53c69d40b808b9ce43bafe55b88
11293 cfgadm: NULL pointer errors
commit 8d499c80c8e6e058669db8815577bc1d4dca9af0
11022 Offload Data Transfer (ODX) support
commit 252bc4b276969afed9d61561c1a53f4cad070a6b
11021 more SMB2 ioctls
commit 55f0a249fd3511728b02627190771a4ce4ddf20e
11020 want SMB2 ioctl FSCTL_SRV_COPYCHUNK
commit 98e973578ca69ba3ce659c761190cbf3558d359c
11292 allocate: NULL pointer errors
commit 82be58ff71c54701f4bfbbb526b4ea3d8f899c22
11289 backup: NULL pointer errors
commit 09f57adea580808a172a5b3e84bf41dc7e0cee6d
11291 bnu: NULL pointer errors
commit 6473113318cb70acc95fbd8ac12c39566c7b9ee1
11285 audio: NULL pointer errors
commit 23b5da0c3a749777311c1644e6ed463cc072104c
11288 bootadm: NULL pointer errors
commit b04056ece904a6664d34ccc4015b5373e959983e
11287 acct: NULL pointer errors
commit 5f2732295e86666b0e9cf16ad42da252d29d0e40
11286 bart: NULL pointer errors
commit 1c124bccd08a671182130ddf2af8e454734b3897
10255 SES temperature thresholds 20 degrees too hot
commit 6a6cfa5d0723a95a9ad915bdb8ca2c9731449041
11267 Add rust demangling support
commit 773dbec304e9344130c5ae4aa5fc8db5419ff779
11268 Add custom allocators to libcustr
commit 09cb6b0fb8744ab06f86a15ad49eb1f39c6fcbf1
11280 custr in belt but not braces, bungles vsnprintf() buffer length
commit ff168298deb08c70659ec1a8645952dee5150368
11165 libshare: NULL pointer errors
commit f810c7e5159aec14e1937d86287a006e755d3d99
11164 libkmf: NULL pointer errors
commit 67d74cc3e7c9d9461311136a0b2069813a3fd927
11102 rtld: NULL pointer errors
commit f39d86306993aa102221c6e62702f1de6cc3f56c
11116 libgen: NULL pointer errors
commit b168296d3fe15e5a2f992bf6af96993c6756ff3a
11155 brand: NULL pointer errors
commit 6f6dd2ca9f4a235a0b2ab596d23cbbfd44d684f6
11113 libgss: NULL pointer errors
commit c75682cd39b9b3d382ce1b01fef06a84ca7ea0a9
11133 libproc: NULL pointer errors
commit 6e6545bfaed3bab9ce836ee82d1abd8f2edba89a
11169 nsswitch: NULL pointer errors
commit f5f1a62e51e5e35359add22ba492c3e3a8f12654
11146 libmapid: NULL pointer errors
commit 6afa3d1d6776a3db46447deaa893bd35c9b53c0a
11147 libinetsvc: NULL pointer errrors
commit c3e74f84d7edf7b5144c2401d7fefd666a92e6c0
11122 libc_db: NULL pointer errors
Conflicts:
usr/src/lib/libdemangle/common/rust.c
usr/src/test/util-tests/tests/demangle/Makefile
170 files changed, 3310 insertions, 1109 deletions
diff --git a/usr/src/cmd/abi/appcert/static_prof/static_prof.c b/usr/src/cmd/abi/appcert/static_prof/static_prof.c index 7d2d71c20f..83bd3c5fcc 100644 --- a/usr/src/cmd/abi/appcert/static_prof/static_prof.c +++ b/usr/src/cmd/abi/appcert/static_prof/static_prof.c @@ -331,7 +331,7 @@ obj_init(obj_list * c) "File <<%s>> : Already opened.\n", c->obj->ename); } - c->obj->fd = NULL; + c->obj->fd = 0; return (FAIL); } /* diff --git a/usr/src/cmd/abi/spectrans/spec2map/bucket.c b/usr/src/cmd/abi/spectrans/spec2map/bucket.c index 5a031a1706..77f2374775 100644 --- a/usr/src/cmd/abi/spectrans/spec2map/bucket.c +++ b/usr/src/cmd/abi/spectrans/spec2map/bucket.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <malloc.h> #include <stdlib.h> @@ -724,7 +722,7 @@ checksum(const char *p) { int sum; - for (sum = 0; *p != NULL; ++p) { + for (sum = 0; *p != '\0'; ++p) { if (sum & 01) sum = (sum >> 1) + 0x8000; else diff --git a/usr/src/cmd/abi/spectrans/spec2trace/bindings.c b/usr/src/cmd/abi/spectrans/spec2trace/bindings.c index 7c6f7d74de..95d937230c 100644 --- a/usr/src/cmd/abi/spectrans/spec2trace/bindings.c +++ b/usr/src/cmd/abi/spectrans/spec2trace/bindings.c @@ -24,8 +24,6 @@ * All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <string.h> #include "parser.h" @@ -169,7 +167,7 @@ generate_a_binding(char *name, char *value) char *q; errlog(BEGIN, "generate_a_binding() {"); - if (*value == NULL) { + if (*value == '\0') { errlog(FATAL, "programmer error: asked to generate an " "empty binding"); } @@ -191,7 +189,7 @@ generate_a_binding(char *name, char *value) /* Walk across line, emitting tokens and transformed tokens */ - for (; *p != NULL; p = q) { + for (; *p != '\0'; p = q) { p = skipb(p); q = nextsep(p); @@ -254,7 +252,7 @@ strpqcmp(char *v1, char *p, char *q) errlog(BEGIN, "strpqcmp() {"); saved = *q; - *q = NULL; + *q = '\0'; rc = (strcmp(v1, p)); *q = saved; errlog(END, "}"); @@ -271,7 +269,7 @@ strpqprint(char *p, char *q, FILE *fp) errlog(BEGIN, "strpqprint() {"); saved = *q; - *q = NULL; + *q = '\0'; (void) fputs(p, fp); *q = saved; errlog(END, "}"); diff --git a/usr/src/cmd/abi/spectrans/spec2trace/db.c b/usr/src/cmd/abi/spectrans/spec2trace/db.c index 6540bb6a37..df1090b960 100644 --- a/usr/src/cmd/abi/spectrans/spec2trace/db.c +++ b/usr/src/cmd/abi/spectrans/spec2trace/db.c @@ -24,8 +24,6 @@ * All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * db.c -- the tiny database for trace. Only stores * global things: see symtab for per-function data. @@ -74,7 +72,7 @@ db_set_current_library(char const *p) errlog(BEGIN, "db_set_current_library() {"); (void) strncpy(Database.Current_Library, p, sizeof (Database.Current_Library)); - Database.Current_Library[sizeof (Database.Current_Library) - 1] = NULL; + Database.Current_Library[sizeof (Database.Current_Library) - 1] = '\0'; errlog(END, "}"); } @@ -187,7 +185,7 @@ db_get_output_file(void) char *p, *q; errlog(BEGIN, "db_get_output_file() {"); - if (*Database.Output_File != NULL) { + if (*Database.Output_File != '\0') { /* It was set with the -o option */ errlog(VERBOSE, "output file from -o = '%s'\n", Database.Output_File); diff --git a/usr/src/cmd/abi/spectrans/spec2trace/interceptor.c b/usr/src/cmd/abi/spectrans/spec2trace/interceptor.c index e95765926a..7c8280715b 100644 --- a/usr/src/cmd/abi/spectrans/spec2trace/interceptor.c +++ b/usr/src/cmd/abi/spectrans/spec2trace/interceptor.c @@ -24,8 +24,6 @@ * All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * interceptor.c -- a functional decomposition of generate.c, * the code generator for apptrace @@ -168,7 +166,7 @@ generate_i_declarations(char *errname, int voidfunc, char *ret_str) { errlog(BEGIN, "generate_i_declarations() {"); - if (*errname != NULL) { + if (*errname != '\0') { /* Create locals for errno-type variable, */ (void) fprintf(Bodyfp, " int saved_errvar = %s;\n", errname); @@ -230,7 +228,7 @@ generate_i_call( errlog(BEGIN, "generate_i_call() {"); /* Zero the error variable. */ - if (*error_name != NULL) { + if (*error_name != '\0') { (void) fprintf(Bodyfp, " %s = 0;\n", error_name); } @@ -246,7 +244,7 @@ generate_i_call( } /* Then set the local copy of the error variable. */ - if (*error_name != NULL) { + if (*error_name != '\0') { (void) fprintf(Bodyfp, " functions_errvar = %s;\n", error_name); } @@ -387,7 +385,7 @@ generate_i_closedown(char *error_name, int void_func) (void) fprintf(Bodyfp, " abiunlock(&omask);\n"); - if (*error_name != NULL) { + if (*error_name != '\0') { /* Restore error variables. */ (void) fprintf(Bodyfp, " %s = (functions_errvar == 0)? " diff --git a/usr/src/cmd/abi/spectrans/spec2trace/printfuncs.c b/usr/src/cmd/abi/spectrans/spec2trace/printfuncs.c index 22dea8d903..e42a59763e 100644 --- a/usr/src/cmd/abi/spectrans/spec2trace/printfuncs.c +++ b/usr/src/cmd/abi/spectrans/spec2trace/printfuncs.c @@ -24,8 +24,6 @@ * All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -60,7 +58,7 @@ generate_printf(ENTRY *f) (void) fprintf(Bodyfp, " fprintf(ABISTREAM, \""); p = &arglist[0]; l = (int)sizeof (arglist); - *p = NULL; + *p = '\0'; for (e = symtab_get_first_arg(); e != NULL; e = symtab_get_next_arg()) { errlog(TRACING, "arglist = '%s'", arglist); @@ -72,7 +70,7 @@ generate_printf(ENTRY *f) if (p != &arglist[0]) { (void) fprintf(Bodyfp, ", "); } - if (*(name = name_of(e)) == NULL) { + if (*(name = name_of(e)) == '\0') { /* It's a varargs indicator instead */ (void) fprintf(Bodyfp, "..."); } else { @@ -80,7 +78,7 @@ generate_printf(ENTRY *f) n = prepare_printf_part(e, name, p, l); l -= n; p += n; - *(p+1) = NULL; + *(p+1) = '\0'; } } @@ -156,7 +154,7 @@ generate_printfunc_calls(ENTRY *f) if (is_void(e)) { break; } - if (*(name = name_of(e)) == NULL) { + if (*(name = name_of(e)) == '\0') { (void) fprintf(Bodyfp, " fputs(\" ...\\n\", " "ABISTREAM);\n"); } @@ -231,7 +229,7 @@ generate_print_definitions(FILE *fp) print_type != NULL; print_type = db_get_next_print_type()) { c_type = strchr(print_type, ','); /* Safe by construction. */ - *c_type++ = NULL; + *c_type++ = '\0'; errlog(TRACING, "print_type=%s\n", print_type); pf_str_name = space_to_uscore(print_type); @@ -268,7 +266,7 @@ generate_print_declarations(FILE *fp) errlog(TRACING, "print_type, c_type=%s\n", print_type); c_type = strchr(print_type, ','); /* Safe by construction. */ - *c_type++ = NULL; + *c_type++ = '\0'; pf_str_name = space_to_uscore(print_type); diff --git a/usr/src/cmd/abi/spectrans/spec2trace/symtab.c b/usr/src/cmd/abi/spectrans/spec2trace/symtab.c index 9eba8969bb..7f19ed48ba 100644 --- a/usr/src/cmd/abi/spectrans/spec2trace/symtab.c +++ b/usr/src/cmd/abi/spectrans/spec2trace/symtab.c @@ -24,8 +24,6 @@ * All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <string.h> #include <limits.h> @@ -147,10 +145,10 @@ symtab_clear_function(void) errlog(BEGIN, "symtab_clear_function() {"); Symtab.Function = free_entry(Symtab.Function); Symtab.Args = free_entry_table(Symtab.Args); - Symtab.Prototype[0] = NULL; - Symtab.Formals[0] = NULL; - Symtab.Actuals[0] = NULL; - Symtab.Cast[0] = NULL; + Symtab.Prototype[0] = '\0'; + Symtab.Formals[0] = '\0'; + Symtab.Actuals[0] = '\0'; + Symtab.Cast[0] = '\0'; errlog(END, "}"); } @@ -224,7 +222,7 @@ symtab_set_prototype(char *p) errlog(BEGIN, "symtab_set_prototype(void) {"); (void) strncpy(Symtab.Prototype, p, sizeof (Symtab.Prototype)); - Symtab.Prototype[sizeof (Symtab.Prototype)-1] = NULL; + Symtab.Prototype[sizeof (Symtab.Prototype)-1] = '\0'; errlog(END, "}"); } @@ -241,7 +239,7 @@ symtab_set_formals(char *p) errlog(BEGIN, "symtab_set_formals() {"); errlog(VERBOSE, "p = %s", p); (void) strncpy(Symtab.Formals, p, sizeof (Symtab.Formals)); - Symtab.Formals[sizeof (Symtab.Formals)-1] = NULL; + Symtab.Formals[sizeof (Symtab.Formals)-1] = '\0'; errlog(END, "}"); } @@ -258,7 +256,7 @@ symtab_set_actuals(char *p) errlog(BEGIN, "symtab_set_actuals() {"); errlog(END, "}"); errlog(VERBOSE, "p = %s", p); (void) strncpy(Symtab.Actuals, p, sizeof (Symtab.Actuals)); - Symtab.Actuals[sizeof (Symtab.Actuals)-1] = NULL; + Symtab.Actuals[sizeof (Symtab.Actuals)-1] = '\0'; } char * @@ -273,7 +271,7 @@ symtab_set_cast(char *p) { errlog(BEGIN, "symtab_set_cast() {"); errlog(END, "}"); (void) strncpy(Symtab.Cast, p, sizeof (Symtab.Cast)); - Symtab.Cast[sizeof (Symtab.Cast)-1] = NULL; + Symtab.Cast[sizeof (Symtab.Cast)-1] = '\0'; } char * @@ -289,7 +287,7 @@ symtab_set_filename(const char *p) { errlog(BEGIN, "symtab_set_filename() {"); errlog(END, "}"); (void) strncpy(Symtab.Filename, p, sizeof (Symtab.Filename)); - Symtab.Filename[sizeof (Symtab.Filename)-1] = NULL; + Symtab.Filename[sizeof (Symtab.Filename)-1] = '\0'; } char * @@ -686,14 +684,14 @@ type_of(ENTRY *e) if (e != NULL && (e->e_kind == PRIMITIVE || e->e_kind == VARARG)) { p = e->e_type; q = &buffer[0]; - while (*p != NULL) { + while (*p != '\0') { if (*p == '%') { p += 2; } else { *q++ = *p++; } } - *q = NULL; + *q = '\0'; return (strtrim(&buffer[0])); } else @@ -715,7 +713,7 @@ levels_of(ENTRY *e) if (e != NULL && (e->e_kind == PRIMITIVE || e->e_kind == VARARG)) return (e->e_levels); else - return (NULL); + return (0); } char * diff --git a/usr/src/cmd/abi/spectrans/spec2trace/trace.c b/usr/src/cmd/abi/spectrans/spec2trace/trace.c index a9fab97c02..1a80ad1512 100644 --- a/usr/src/cmd/abi/spectrans/spec2trace/trace.c +++ b/usr/src/cmd/abi/spectrans/spec2trace/trace.c @@ -24,8 +24,6 @@ * All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * * trace.c -- a simple translator from spec source to c source for @@ -628,8 +626,8 @@ to_basetype(char *str) int levels = 0; assert(strlen(str) < MAXLINE, "string exceeded MAXLINE"); - buffer[0] = NULL; - for (; *p != NULL; p++) { + buffer[0] = '\0'; + for (; *p != '\0'; p++) { switch (*p) { case ' ': /* Convert spaces to single ' '. */ if (*(q-1) != ' ') @@ -652,12 +650,12 @@ to_basetype(char *str) *q++ = *p; break; } - *q = NULL; + *q = '\0'; } assert(q < &buffer[MAXLINE], "q fell off end of buffer"); q--; while (*q == ' ') { - *q-- = NULL; + *q-- = '\0'; } assert(strlen(buffer) < MAXLINE, "buffer length exceeded MAXLINE"); (void) strcpy(str, buffer); @@ -675,12 +673,12 @@ to_actual(void) static char buffer[MAXLINE+1]; int n; - *buffer = NULL; + *buffer = '\0'; if ((p = symtab_get_first_arg()) != NULL) { n = MAXLINE - snprintf(buffer, MAXLINE, "%s", name_of(p)); for (p = symtab_get_next_arg(); p != NULL; p = symtab_get_next_arg()) { - if (*name_of(p) != NULL) + if (*name_of(p) != '\0') n -= snprintf(strend(buffer), n, ", %s", name_of(p)); } @@ -698,7 +696,7 @@ strpqcpy(char *target, char *p, char *q) char saved; saved = *q; - *q = NULL; + *q = '\0'; (void) strcpy(target, p); *q = saved; return (target); diff --git a/usr/src/cmd/abi/spectrans/spec2trace/util.c b/usr/src/cmd/abi/spectrans/spec2trace/util.c index 55eb115f7a..549eba1f40 100644 --- a/usr/src/cmd/abi/spectrans/spec2trace/util.c +++ b/usr/src/cmd/abi/spectrans/spec2trace/util.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <string.h> #include <ctype.h> @@ -52,16 +50,16 @@ strnormalize(char *str) { char *p; - if (str == NULL || *str == NULL) + if (str == NULL || *str == '\0') return (str); - for (p = str; *p != NULL; p++) { + for (p = str; *p != '\0'; p++) { if (isspace(*p)) { *p = ' '; } } p--; while (p >= str && (isspace(*p) || *p == ';')) - *p-- = NULL; + *p-- = '\0'; /* ERA - remove leading spaces */ while (isspace(*str)) @@ -75,11 +73,11 @@ strtrim(char *str) { char *p; - for (p = str; *p != NULL; p++) + for (p = str; *p != '\0'; p++) continue; p--; while (p >= str && isspace(*p)) - *p-- = NULL; + *p-- = '\0'; return (str); } @@ -92,7 +90,7 @@ strlower(char *str) { char *p; - for (p = str; *p != NULL; p++) { + for (p = str; *p != '\0'; p++) { *p = tolower(*p); } return (str); @@ -144,7 +142,7 @@ in_string_set(char *p, char *set) break; } save = *q; - *q = NULL; + *q = '\0'; if (strcmp(p, set) == 0) { *q = save; errlog(VERBOSE, "return YES"); @@ -262,14 +260,14 @@ objectname(char *name) static char basename[MAXLINE]; p = strrchr(name, '/'); - while (p != NULL && *(p+1) == NULL) { + while (p != NULL && *(p+1) == '\0') { /* The / was at the end of the name. */ - *p = NULL; + *p = '\0'; p = strrchr(name, '/'); } (void) strlcpy(basename, p? p+1: name, MAXLINE); if ((p = strstr(basename, ".c")) != NULL) { - *p = NULL; + *p = '\0'; } return (strcat(basename, ".o")); } @@ -362,7 +360,7 @@ in_string_table(table_t *t, char *value) } for (i = 0; i <= t->used; i++) { if (strncmp(value, t->elements[i], len) == 0 && - (t->elements[i][len] == NULL || + (t->elements[i][len] == '\0' || t->elements[i][len] == ',')) return (1); } diff --git a/usr/src/cmd/acct/acctwtmp.c b/usr/src/cmd/acct/acctwtmp.c index ef80ecb189..948f485f52 100644 --- a/usr/src/cmd/acct/acctwtmp.c +++ b/usr/src/cmd/acct/acctwtmp.c @@ -20,13 +20,12 @@ * CDDL HEADER END */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" /* * acctwtmp reason /var/adm/wtmpx * writes utmpx.h record (with current time) to specific file @@ -49,10 +48,10 @@ main(int argc, char **argv) if (argc < 3) (void) fprintf(stderr, "Usage: %s reason wtmpx_file\n", - argv[0]), exit(1); + argv[0]), exit(1); (void) strncpy(wb.ut_line, argv[1], sizeof (wb.ut_line)); - wb.ut_line[11] = NULL; + wb.ut_line[11] = '\0'; wb.ut_type = ACCOUNTING; time(&wb.ut_xtime); utmpxname(argv[2]); diff --git a/usr/src/cmd/allocate/allocate3.c b/usr/src/cmd/allocate/allocate3.c index 9da5745e0c..7c81ad0f46 100644 --- a/usr/src/cmd/allocate/allocate3.c +++ b/usr/src/cmd/allocate/allocate3.c @@ -812,13 +812,12 @@ mk_revoke(int optflag, char *file) continue; } (void) close(fp); - if (strcmp(info.pr_fname, "vold") == NULL) { + if (strcmp(info.pr_fname, "vold") == 0) { dprintf("%d matched vold name\n", fuserpid); continue; } - if (strcmp(info.pr_fname, "deallocate") - == NULL) { + if (strcmp(info.pr_fname, "deallocate") == 0) { dprintf("%d matched deallocate name\n", fuserpid); continue; @@ -1147,7 +1146,7 @@ out: int _allocate_dev(int optflag, uid_t uid, devalloc_t *da, char *zonename, - int *lock_fd) + int *lock_fd) { int i; int bytes = 0; @@ -1156,8 +1155,8 @@ _allocate_dev(int optflag, uid_t uid, devalloc_t *da, char *zonename, int dealloc_optflag = 0; char *fname = NULL; char file_name[MAXPATHLEN]; - devmap_t *dm; - struct stat stat_buf; + devmap_t *dm; + struct stat stat_buf; struct state_file sf; struct zone_path zpath; diff --git a/usr/src/cmd/allocate/mkdevalloc.c b/usr/src/cmd/allocate/mkdevalloc.c index 508f5961c4..d9dfaccbc9 100644 --- a/usr/src/cmd/allocate/mkdevalloc.c +++ b/usr/src/cmd/allocate/mkdevalloc.c @@ -319,7 +319,7 @@ dotape() while (dep = readdir(dirp)) { /* skip . .. etc... */ - if (strncmp(dep->d_name, ".", 1) == NULL) + if (strncmp(dep->d_name, ".", 1) == 0) continue; /* if array full, then expand it */ @@ -520,7 +520,7 @@ doaudio() while (dep = readdir(dirp)) { /* skip . .. etc... */ - if (strncmp(dep->d_name, ".", 1) == NULL) + if (strncmp(dep->d_name, ".", 1) == 0) continue; /* if array full, then expand it */ @@ -903,7 +903,7 @@ docd() while (dep = readdir(dirp)) { /* skip . .. etc... */ - if (strncmp(dep->d_name, ".", 1) == NULL) + if (strncmp(dep->d_name, ".", 1) == 0) continue; /* get device # (disk #) */ @@ -954,7 +954,7 @@ found: while (dep = readdir(dirp)) { /* skip . .. etc... */ - if (strncmp(dep->d_name, ".", 1) == NULL) + if (strncmp(dep->d_name, ".", 1) == 0) continue; /* get device # (disk #) */ @@ -1111,7 +1111,7 @@ dormdisk(int cd_count) checked = 0; removable = 0; /* skip . .. etc... */ - if (strncmp(dep->d_name, ".", 1) == NULL) + if (strncmp(dep->d_name, ".", 1) == 0) continue; /* get device # (disk #) */ diff --git a/usr/src/cmd/audio/audioplay/audioplay.c b/usr/src/cmd/audio/audioplay/audioplay.c index ad225bb55e..272b61f5ca 100644 --- a/usr/src/cmd/audio/audioplay/audioplay.c +++ b/usr/src/cmd/audio/audioplay/audioplay.c @@ -249,7 +249,8 @@ open_audio(void) /* Play a list of audio files. */ int -main(int argc, char **argv) { +main(int argc, char **argv) +{ int errorStatus = 0; int i; int c; @@ -511,8 +512,8 @@ main(int argc, char **argv) { /* Skip the file header and set the proper size */ cnt = lseek(ifd, 0, SEEK_CUR); if (cnt < 0) { - perror("lseek"); - exit(1); + perror("lseek"); + exit(1); } inbuf = (unsigned char *) mapaddr + cnt; len = cnt = st.st_size - cnt; @@ -730,8 +731,8 @@ main(int argc, char **argv) { demux(3, cnt / File_hdr.channels); for (c = 0; - c < File_hdr.channels; - c++) { + c < File_hdr.channels; + c++) { err = g723_decode( in_ch_data[c], cnt / @@ -920,8 +921,8 @@ parse_unsigned(char *str, unsigned *dst, char *flag) static int path_open(char *fname, int flags, mode_t mode, char *path) { - char fullpath[MAXPATHLEN]; /* full path of file */ - char *buf; /* malloc off the tmp buff */ + char fullpath[MAXPATHLEN]; /* full path of file */ + char *buf; /* malloc off the tmp buff */ char *cp; struct stat st; @@ -963,7 +964,7 @@ path_open(char *fname, int flags, mode_t mode, char *path) for (path = buf; path && *path; ) { if (cp = strchr(path, ':')) { - *cp++ = NULL; /* now pts to next path element */ + *cp++ = '\0'; /* now pts to next path element */ } /* the safest way to create the path string :-) */ diff --git a/usr/src/cmd/audio/audiorecord/audiorecord.c b/usr/src/cmd/audio/audiorecord/audiorecord.c index 6195ffe351..954c882e9b 100644 --- a/usr/src/cmd/audio/audiorecord/audiorecord.c +++ b/usr/src/cmd/audio/audiorecord/audiorecord.c @@ -73,7 +73,7 @@ static char *Stdout; /* XXX - the input buffer size should depend on sample_rate */ #define AUDIO_BUFSIZ (1024 * 64) static unsigned char buf[AUDIO_BUFSIZ]; -static char swapBuf[AUDIO_BUFSIZ]; /* for byte swapping */ +static char swapBuf[AUDIO_BUFSIZ]; /* for byte swapping */ #define MAX_GAIN (100) /* maximum gain */ @@ -183,7 +183,7 @@ main(int argc, char **argv) int err; int file_type; int ofd; - int swapBytes = FALSE; + int swapBytes = FALSE; double vol; struct stat st; struct pollfd pfd; @@ -774,7 +774,7 @@ parse_sample_rate(char *s, unsigned *rate) */ for (cp = s; *cp && (isdigit(*cp) || (*cp == '.')); cp++) /* NOP */; - if (*cp != NULL) { + if (*cp != '\0') { if ((*cp == 'k') || (*cp == 'K')) { drate *= 1000.0; } else if ((*cp != 'h') && (*cp != 'H')) { diff --git a/usr/src/cmd/backup/restore/utilities.c b/usr/src/cmd/backup/restore/utilities.c index 7cfa8b1ec4..db232c545d 100644 --- a/usr/src/cmd/backup/restore/utilities.c +++ b/usr/src/cmd/backup/restore/utilities.c @@ -114,7 +114,7 @@ renameit(char *fp, char *tp) tofd = fromfd; if ((pathend = strrchr(from, '/')) != NULL) { strncpy(tobuf, from, pathend - from + 1); - tobuf[pathend - from + 1] = NULL; + tobuf[pathend - from + 1] = '\0'; strlcat(tobuf, tp, sizeof (tobuf)); to = tobuf; } else { @@ -154,8 +154,8 @@ newnode(struct entry *np) if (fchdir(dfd) < 0) { int saverr = errno; (void) fprintf(stderr, - gettext("Warning: cannot create %s: %s"), - cp, strerror(saverr)); + gettext("Warning: cannot create %s: %s"), + cp, strerror(saverr)); (void) fflush(stderr); (void) close(dfd); return; @@ -200,8 +200,8 @@ removenode(struct entry *ep) if (fchdir(dfd) < 0) { int saverr = errno; (void) fprintf(stderr, - gettext("Warning: cannot remove %s: %s"), - cp, strerror(saverr)); + gettext("Warning: cannot remove %s: %s"), + cp, strerror(saverr)); (void) fflush(stderr); (void) close(dfd); return; @@ -210,7 +210,7 @@ removenode(struct entry *ep) if (rmdir(cp) < 0) { /* NOTE: could use unlinkat (..,REMOVEDIR) */ int saverr = errno; (void) fprintf(stderr, gettext("Warning: %s: %s\n"), - cp, strerror(saverr)); + cp, strerror(saverr)); (void) fflush(stderr); } else { vprintf(stdout, gettext("Remove node %s\n"), cp); @@ -240,7 +240,7 @@ removeleaf(struct entry *ep) if (unlinkat(dfd, cp, 0) < 0) { int saverr = errno; (void) fprintf(stderr, gettext("Warning: %s: %s\n"), - cp, strerror(saverr)); + cp, strerror(saverr)); (void) fflush(stderr); } else { vprintf(stdout, gettext("Remove leaf %s\n"), cp); @@ -266,8 +266,8 @@ lf_linkit(char *existing, char *new, int type) resolve(existing, &dfd, &name); if (dfd == -1) { (void) fprintf(stderr, gettext( - "Warning: cannot restore %s link %s->%s\n"), - (type == SYMLINK ? "symbolic" : "hard"), new, existing); + "Warning: cannot restore %s link %s->%s\n"), + (type == SYMLINK ? "symbolic" : "hard"), new, existing); result = FAIL; goto out; } @@ -380,7 +380,7 @@ badentry(struct entry *ep, char *msg) (void) fprintf(stderr, gettext("bad entry: %s\n"), msg); (void) fprintf(stderr, gettext("name: %s\n"), myname(ep)); (void) fprintf(stderr, gettext("parent name %s\n"), - myname(ep->e_parent)); + myname(ep->e_parent)); if (ep->e_sibling != NIL) (void) fprintf(stderr, gettext("sibling name: %s\n"), myname(ep->e_sibling)); @@ -429,7 +429,7 @@ flagvalues(struct entry *ep) (void) strlcat(flagbuf, gettext("|XATTR"), sizeof (flagbuf)); if (ep->e_flags & XATTRROOT) (void) strlcat(flagbuf, gettext("|XATTRROOT"), - sizeof (flagbuf)); + sizeof (flagbuf)); return (&flagbuf[1]); } @@ -463,7 +463,7 @@ reply(char *question) while (c != '\n' && getc(terminal) != '\n') { if (ferror(terminal)) { (void) fprintf(stderr, gettext( - "Error reading response\n")); + "Error reading response\n")); (void) fflush(stderr); return (FAIL); } @@ -521,6 +521,7 @@ panic(va_dcl) abort(); done(1); } +} #endif /* @@ -602,7 +603,7 @@ safe_open(int dfd, const char *filename, int mode, int perms) O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_LARGEFILE, perms)) < 0) { if (errno == EEXIST) { if (fstatat(dfd, filename, &pre_lstat, - AT_SYMLINK_NOFOLLOW) < 0) { + AT_SYMLINK_NOFOLLOW) < 0) { saverr = errno; (void) close(fd); errno = saverr; @@ -632,7 +633,7 @@ safe_open(int dfd, const char *filename, int mode, int perms) } if (fstatat(fd, NULL, &post_lstat, - AT_SYMLINK_NOFOLLOW) < 0) { + AT_SYMLINK_NOFOLLOW) < 0) { saverr = errno; (void) close(fd); errno = saverr; @@ -793,10 +794,10 @@ mkentry(char *name, ino_t ino, struct arglist *ap) if (ap->base == NULL) { ap->nent = 20; ap->base = (struct afile *)calloc((unsigned)ap->nent, - sizeof (*(ap->base))); + sizeof (*(ap->base))); if (ap->base == NULL) { (void) fprintf(stderr, - gettext("%s: out of memory\n"), ap->cmd); + gettext("%s: out of memory\n"), ap->cmd); return (FAIL); } } @@ -811,7 +812,7 @@ mkentry(char *name, ino_t ino, struct arglist *ap) (size_t)(2 * ap->nent * (size_t)sizeof (*(ap->base)))); if (ap->base == NULL) { (void) fprintf(stderr, - gettext("%s: out of memory\n"), ap->cmd); + gettext("%s: out of memory\n"), ap->cmd); return (FAIL); } ap->head = ap->base; @@ -860,7 +861,7 @@ expand(char *as, int rflg, struct arglist *ap) char slash; char *rs; char c; - wchar_t w_fname[PATH_MAX+1]; + wchar_t w_fname[PATH_MAX+1]; wchar_t w_pname[PATH_MAX+1]; /* @@ -1102,8 +1103,9 @@ resolve(char *path, int *fd, char **rpath) *rpath = path; path = *rpath + strlen(*rpath) +1; while (*path != '\0' && - (*fd = openat64(tfd, *rpath, O_RDONLY)) > 0) { - if (tfd != AT_FDCWD) (void) close(tfd); + (*fd = openat64(tfd, *rpath, O_RDONLY)) > 0) { + if (tfd != AT_FDCWD) + (void) close(tfd); tfd = *fd; *rpath = path; path = *rpath + strlen(*rpath) +1; @@ -1113,8 +1115,8 @@ resolve(char *path, int *fd, char **rpath) if (*fd < 0 || (*fd = openat64(tfd, ".", O_RDONLY|O_XATTR)) < 0) { int saverr = errno; (void) fprintf(stderr, - gettext("Warning: cannot fully resolve %s: %s"), - path, strerror(saverr)); + gettext("Warning: cannot fully resolve %s: %s"), + path, strerror(saverr)); (void) fflush(stderr); } if (tfd != AT_FDCWD) (void) close(tfd); @@ -1146,6 +1148,6 @@ complexcpy(char *s1, char *s2, int max) if (nullseen == 0) *--s1 = '\0'; fprintf(stderr, - gettext("Warning: unterminated source string in complexcpy\n")); + gettext("Warning: unterminated source string in complexcpy\n")); return (max-1); } diff --git a/usr/src/cmd/bart/compare.c b/usr/src/cmd/bart/compare.c index 254d4507eb..f92b23944e 100644 --- a/usr/src/cmd/bart/compare.c +++ b/usr/src/cmd/bart/compare.c @@ -23,7 +23,6 @@ * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" #include <unistd.h> #include "bart.h" @@ -52,7 +51,7 @@ bart_compare(int argc, char **argv) char *control_fname, *test_fname; int c; FILE *rules_fd = NULL; - uint_t glob_flags; + uint_t glob_flags; boolean_t prog_fmt = B_FALSE; init_default_flags(&glob_flags); @@ -100,13 +99,13 @@ bart_compare(int argc, char **argv) static int compare_manifests(FILE *rulesfile, char *control, char *test, -boolean_t prog_fmt, uint_t flags) + boolean_t prog_fmt, uint_t flags) { FILE *control_fd, *test_fd; char *control_line, *test_line, control_buf[BUF_SIZE], - test_buf[BUF_SIZE], control_fname[PATH_MAX], - control_type[TYPE_SIZE], test_fname[PATH_MAX], - test_type[TYPE_SIZE]; + test_buf[BUF_SIZE], control_fname[PATH_MAX], + control_type[TYPE_SIZE], test_fname[PATH_MAX], + test_type[TYPE_SIZE]; int control_pos, test_pos, ret, fname_cmp, return_status; return_status = EXIT; @@ -227,8 +226,8 @@ boolean_t prog_fmt, uint_t flags) static void parse_line(char *line, char *fname, char *type, char *size, char *mode, -char *acl, char *mtime, char *uid, char *gid, char *contents, char *devnode, -char *dest) + char *acl, char *mtime, char *uid, char *gid, char *contents, char *devnode, + char *dest) { int pos, line_len; @@ -246,7 +245,7 @@ char *dest) /* Reset these fields... */ - *contents = NULL; + *contents = '\0'; *devnode = '\0'; *dest = '\0'; @@ -341,17 +340,17 @@ evaluate_differences(char *control_line, char *test_line, boolean_t prog_fmt, int flags) { char ctrl_fname[PATH_MAX], test_fname[PATH_MAX], - ctrl_type[TYPE_SIZE], test_type[TYPE_SIZE], - ctrl_size[MISC_SIZE], ctrl_mode[MISC_SIZE], - ctrl_acl[ACL_SIZE], ctrl_mtime[MISC_SIZE], - ctrl_uid[MISC_SIZE], ctrl_gid[MISC_SIZE], - ctrl_dest[PATH_MAX], ctrl_contents[PATH_MAX], - ctrl_devnode[PATH_MAX], test_size[MISC_SIZE], - test_mode[MISC_SIZE], test_acl[ACL_SIZE], - test_mtime[MISC_SIZE], test_uid[MISC_SIZE], - test_gid[MISC_SIZE], test_dest[PATH_MAX], - test_contents[PATH_MAX], test_devnode[PATH_MAX], - *tag; + ctrl_type[TYPE_SIZE], test_type[TYPE_SIZE], + ctrl_size[MISC_SIZE], ctrl_mode[MISC_SIZE], + ctrl_acl[ACL_SIZE], ctrl_mtime[MISC_SIZE], + ctrl_uid[MISC_SIZE], ctrl_gid[MISC_SIZE], + ctrl_dest[PATH_MAX], ctrl_contents[PATH_MAX], + ctrl_devnode[PATH_MAX], test_size[MISC_SIZE], + test_mode[MISC_SIZE], test_acl[ACL_SIZE], + test_mtime[MISC_SIZE], test_uid[MISC_SIZE], + test_gid[MISC_SIZE], test_dest[PATH_MAX], + test_contents[PATH_MAX], test_devnode[PATH_MAX], + *tag; int ret_val; struct rule *rule_ptr; diff --git a/usr/src/cmd/bnu/getprm.c b/usr/src/cmd/bnu/getprm.c index 5169e7950e..dd5dea00ce 100644 --- a/usr/src/cmd/bnu/getprm.c +++ b/usr/src/cmd/bnu/getprm.c @@ -28,8 +28,6 @@ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "uucp.h" #define LQUOTE '(' @@ -235,7 +233,7 @@ char *arg, *sys, *fwd, *file; if (cl != (cr = wcsrchr(n, (wchar_t)'!'))) { /* more than one ! */ wcsncpy(tmpbuf, cl+1, cr-cl-1); - tmpbuf[cr-cl-1] = NULL; + tmpbuf[cr-cl-1] = '\0'; (void) wcstombs(fwd, tmpbuf, MAXFULLNAME); } } else { diff --git a/usr/src/cmd/bnu/gio.c b/usr/src/cmd/bnu/gio.c index c09bfdca36..a6b0dbb5fd 100644 --- a/usr/src/cmd/bnu/gio.c +++ b/usr/src/cmd/bnu/gio.c @@ -28,8 +28,6 @@ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "uucp.h" #include "pk.h" @@ -72,7 +70,7 @@ gturnon() if (Debug > 4) pkdebug = 1; Pk = pkopen(Ifn, Ofn); - if ((int) Pk == NULL) + if (Pk == NULL) return(FAIL); return(0); } diff --git a/usr/src/cmd/bnu/interface.c b/usr/src/cmd/bnu/interface.c index ba1c9f9381..2f8c9578cc 100644 --- a/usr/src/cmd/bnu/interface.c +++ b/usr/src/cmd/bnu/interface.c @@ -302,19 +302,19 @@ unsigned nbytes; } if (info.tsdu <= 0 || nbytes <= info.tsdu) - return (t_snd(fd, buf, nbytes, NULL)); + return (t_snd(fd, buf, nbytes, 0)); /* if get here, then there is a limit on transmit size */ /* (info.tsdu > 0) and buf exceeds it */ i = ret = 0; while (nbytes >= info.tsdu) { - if ((ret = t_snd(fd, &buf[i], info.tsdu, NULL)) != info.tsdu) + if ((ret = t_snd(fd, &buf[i], info.tsdu, 0)) != info.tsdu) return ((ret >= 0 ? (i + ret) : ret)); i += info.tsdu; nbytes -= info.tsdu; } if (nbytes != 0) { - if ((ret = t_snd(fd, &buf[i], nbytes, NULL)) != nbytes) + if ((ret = t_snd(fd, &buf[i], nbytes, 0)) != nbytes) return ((ssize_t)(ret >= 0 ? (i + ret) : ret)); i += nbytes; } diff --git a/usr/src/cmd/bnu/sysfiles.c b/usr/src/cmd/bnu/sysfiles.c index db147774d0..959e0c9e56 100644 --- a/usr/src/cmd/bnu/sysfiles.c +++ b/usr/src/cmd/bnu/sysfiles.c @@ -480,7 +480,7 @@ char *buf; ASSERT(len >= BUFSIZ, "BUFFER TOO SMALL", "getsysline", 0); for(;;) { - while (getaline(fsystems, buf) != NULL) + while (getaline(fsystems, buf) != 0) if ((*buf != '#') && (*buf != ' ') && (*buf != '\t') && (*buf != '\n')) { (void) _uu_resetlocale(LC_ALL, prev); diff --git a/usr/src/cmd/bnu/uudecode.c b/usr/src/cmd/bnu/uudecode.c index 5af8d3ac55..eb90dc6a77 100644 --- a/usr/src/cmd/bnu/uudecode.c +++ b/usr/src/cmd/bnu/uudecode.c @@ -25,8 +25,6 @@ /* Copyright 2004 Sun Microsystems, Inc. All rights reserved. */ /* Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * uudecode [-o outfile | -p] [input] * @@ -356,7 +354,7 @@ decode(FILE *in, FILE *out, int base64) while ((fgets(inbuf, sizeof (inbuf), in)) != NULL) { /* process an input line */ iptr = inbuf; - while ((curchr = *(iptr++)) != NULL) { + while ((curchr = *(iptr++)) != '\0') { /* decode chars */ if (curchr == '=') /* if end */ endseen++; diff --git a/usr/src/cmd/bnu/uustat.c b/usr/src/cmd/bnu/uustat.c index 992f68c5da..78cbf945a5 100644 --- a/usr/src/cmd/bnu/uustat.c +++ b/usr/src/cmd/bnu/uustat.c @@ -447,7 +447,7 @@ char **envp; /* Make sure the overflow entry is null since it may be incorrect */ M[UUSTAT_TBL].mach[0] = NULLCHAR; if (Summary) { - for((sortcnt = 0, m = &M[0]);*(m->mach) != NULL;(sortcnt++,m++)) + for((sortcnt = 0, m = &M[0]);*(m->mach) != '\0';(sortcnt++,m++)) ; qsort((char *)M, (unsigned int)sortcnt, sizeof(struct m), machcmp); for (m = M; m->mach[0] != NULLCHAR; m++) diff --git a/usr/src/cmd/boot/bootadm/bootadm.c b/usr/src/cmd/boot/bootadm/bootadm.c index f0de13c1ed..62cbd6ef8c 100644 --- a/usr/src/cmd/boot/bootadm/bootadm.c +++ b/usr/src/cmd/boot/bootadm/bootadm.c @@ -1034,13 +1034,13 @@ list_setting(menu_t *mp, char *which, char *setting) assert(which); assert(setting); - if (*which != NULL) { + if (*which != '\0') { /* * If "which" is not a number, assume it's a setting we want * to look for and so set up the routine to look for "which" * in the default entry. */ - while (*p != NULL) + while (*p != '\0') if (!(isdigit((int)*p++))) { setting = which; which = mp->curdefault->arg; @@ -1061,10 +1061,10 @@ list_setting(menu_t *mp, char *which, char *setting) return (BAM_ERROR); } - found = (*setting == NULL); + found = (*setting == '\0'); for (lp = ent->start; lp != NULL; lp = lp->next) { - if ((*setting == NULL) && (lp->flags != BAM_COMMENT)) + if ((*setting == '\0') && (lp->flags != BAM_COMMENT)) bam_print("%s\n", lp->line); else if (lp->cmd != NULL && strcmp(setting, lp->cmd) == 0) { bam_print("%s\n", lp->arg); diff --git a/usr/src/cmd/boot/bootadm/bootadm_hyper.c b/usr/src/cmd/boot/bootadm/bootadm_hyper.c index 66e0051eae..f88960383e 100644 --- a/usr/src/cmd/boot/bootadm/bootadm_hyper.c +++ b/usr/src/cmd/boot/bootadm/bootadm_hyper.c @@ -35,8 +35,8 @@ #include "bootadm.h" -#define HYPER_KERNEL_DIR "/platform/i86xpv/kernel" -#define METAL_KERNEL_DIR "/platform/i86pc/kernel" +#define HYPER_KERNEL_DIR "/platform/i86xpv/kernel" +#define METAL_KERNEL_DIR "/platform/i86pc/kernel" #define BOOTRC_FILE "/boot/solaris/bootenv.rc" #define ZFS_BOOTSTR "$ZFS-BOOTFS" @@ -72,7 +72,7 @@ append_str(char *orig, char *str, char *delim) if ((str == NULL) || (delim == NULL)) return (NULL); - if ((orig == NULL) || (*orig == NULL)) { + if ((orig == NULL) || (*orig == '\0')) { /* * Return a pointer to a copy of the path so a caller can * always rely upon being able to free() a returned pointer. @@ -147,26 +147,26 @@ get_token(char **token, char *str, char *delim) *token = NULL; - if ((str == NULL) || (*str == NULL)) + if ((str == NULL) || (*str == '\0')) return (NULL); do { if ((*str == '\'') || (*str == '"')) { char quote = *str++; - while ((*str != NULL) && (*str != quote)) + while ((*str != '\0') && (*str != quote)) str++; /* no matching quote found in string */ - if (*str++ == NULL) + if (*str++ == '\0') return (NULL); } /* look for a character from the delimiter string */ - for (dp = delim; ((*dp != NULL) && (*dp != *str)); dp++) + for (dp = delim; ((*dp != '\0') && (*dp != *str)); dp++) ; - if (*dp != NULL) { + if (*dp != '\0') { len = str - start + 1; /* found a delimiter, so create a token string */ @@ -183,7 +183,7 @@ get_token(char **token, char *str, char *delim) return (str); } - } while (*str++ != NULL); + } while (*str++ != '\0'); /* if we hit the end of the string, the token is the whole string */ *token = s_strdup(start); @@ -338,7 +338,7 @@ cvt_metal_option(char *optstr) namlen = value - optstr; - if (*++value == NULL) + if (*++value == '\0') return (1); if (strncmp(optstr, "console", namlen) == 0) { @@ -395,7 +395,7 @@ cvt_hyper_option(char *optstr) namlen = value - optstr; - if (*++value == NULL) + if (*++value == '\0') return (1); /* @@ -681,7 +681,7 @@ parse_bootenvrc(char *osroot) int port = 0; /* we're only interested in parsing "setprop" directives. */ - if (strncmp(line, "setprop", 7) != NULL) + if (strncmp(line, "setprop", 7) != 0) continue; /* eat initial "setprop" */ @@ -913,7 +913,7 @@ cvt_to_hyper(menu_t *mp, char *osroot, char *extra_args) } } - if ((extra_args != NULL) && (*extra_args != NULL)) { + if ((extra_args != NULL) && (*extra_args != '\0')) { newstr = append_str(kern_bargs, extra_args, " "); free(kern_bargs); kern_bargs = newstr; @@ -925,7 +925,7 @@ cvt_to_hyper(menu_t *mp, char *osroot, char *extra_args) kernel = alloca(len); if (kern_bargs != NULL) { - if (*kern_bargs != NULL) + if (*kern_bargs != '\0') (void) snprintf(kernel, len, "%s%s %s", osroot, XEN_MENU, kern_bargs); @@ -1003,7 +1003,7 @@ abort: if (ret != BAM_NOCHANGE) bam_error(_("error converting GRUB menu entry on %s for use " "with the hypervisor.\nAborting.\n"), - ((*osroot == NULL) ? "/" : osroot)); + ((*osroot == '\0') ? "/" : osroot)); return (ret); } diff --git a/usr/src/cmd/cfgadm/cfgadm.c b/usr/src/cmd/cfgadm/cfgadm.c index 1ef642871d..fd660c7298 100644 --- a/usr/src/cmd/cfgadm/cfgadm.c +++ b/usr/src/cmd/cfgadm/cfgadm.c @@ -201,7 +201,7 @@ main( char *subopts; char *subvalue; char *const *ap_args = NULL; - cfga_cmd_t sc_opt = NULL; + cfga_cmd_t sc_opt = 0; struct cfga_confirm confirm; struct cfga_msg message; int ret = CFGA_ERROR; diff --git a/usr/src/cmd/chmod/chmod.c b/usr/src/cmd/chmod/chmod.c index 8e9b1ecbbe..897b5d8d20 100644 --- a/usr/src/cmd/chmod/chmod.c +++ b/usr/src/cmd/chmod/chmod.c @@ -553,7 +553,7 @@ parseargs(int ac, char *av[]) /* process the arguments */ for (i = mac = 0; - (av[i] != (char *)NULL) && (av[i][0] != (char)NULL); + (av[i] != NULL) && (av[i][0] != '\0'); i++) { if (!fflag && av[i][0] == '-') { /* diff --git a/usr/src/cmd/cmd-inet/sbin/ifparse/ifparse.c b/usr/src/cmd/cmd-inet/sbin/ifparse/ifparse.c index d73722cc55..caf7987fc7 100644 --- a/usr/src/cmd/cmd-inet/sbin/ifparse/ifparse.c +++ b/usr/src/cmd/cmd-inet/sbin/ifparse/ifparse.c @@ -435,7 +435,7 @@ ifparse(int argc, char *argv[], struct afswtch *afp) return (0); if (strcmp(*argv, "auto-dhcp") == 0 || strcmp(*argv, "dhcp") == 0) { - if ((parsemode & PARSEFIXED) != NULL) { + if ((parsemode & PARSEFIXED) != 0) { while (argc) { (void) fputs(*argv++, stdout); if (--argc != 0) diff --git a/usr/src/cmd/cmd-inet/usr.bin/ftp/ftp.c b/usr/src/cmd/cmd-inet/usr.bin/ftp/ftp.c index f92dcc6759..f7007286a8 100644 --- a/usr/src/cmd/cmd-inet/usr.bin/ftp/ftp.c +++ b/usr/src/cmd/cmd-inet/usr.bin/ftp/ftp.c @@ -37,8 +37,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ftp_var.h" #include <arpa/nameser.h> #include <sys/types.h> @@ -1524,7 +1522,7 @@ initconn(void) "parsing failure.\n"); goto bad; } - *(c2 - 1) = NULL; + *(c2 - 1) = '\0'; /* Delimiter is the next char in the reply string */ delm = *(++c); while (*c == delm) { diff --git a/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c b/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c index 475e915b2e..223e582072 100644 --- a/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c +++ b/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c @@ -3517,7 +3517,7 @@ dhcp_walk_interfaces(int af, boolean_t printed_one) if (ioctl(sock_fd, SIOCGLIFCONF, &lifc) == -1) { (void) close(sock_fd); free(lifc.lifc_buf); - return (NULL); + return (B_FALSE); } n_ifs = lifc.lifc_len / sizeof (struct lifreq); diff --git a/usr/src/cmd/cmd-inet/usr.bin/netstat/unix.c b/usr/src/cmd/cmd-inet/usr.bin/netstat/unix.c index 175310a9a6..1a6364c00f 100644 --- a/usr/src/cmd/cmd-inet/usr.bin/netstat/unix.c +++ b/usr/src/cmd/cmd-inet/usr.bin/netstat/unix.c @@ -235,7 +235,7 @@ nextstr(char *pas) { char *next; - for (next = &pas[strlen(pas) + 1]; *next == NULL; ) { + for (next = &pas[strlen(pas) + 1]; *next == '\0'; ) { next++; } diff --git a/usr/src/cmd/cmd-inet/usr.bin/telnet/enc_des.c b/usr/src/cmd/cmd-inet/usr.bin/telnet/enc_des.c index aa4621d53c..cafcbebb13 100644 --- a/usr/src/cmd/cmd-inet/usr.bin/telnet/enc_des.c +++ b/usr/src/cmd/cmd-inet/usr.bin/telnet/enc_des.c @@ -3,8 +3,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * usr/src/cmd/cmd-inet/usr.bin/telnet/enc_des.c */ @@ -126,7 +124,7 @@ ecb_encrypt(struct stinfo *stp, Block in, Block out) /* this is a kerberos enctype, not a telopt enctype */ dout.enctype = ENCTYPE_UNKNOWN; - code = krb5_c_encrypt(telnet_context, &stp->str_key, NULL, NULL, + code = krb5_c_encrypt(telnet_context, &stp->str_key, 0, NULL, &din, &dout); if (code) (void) fprintf(stderr, gettext( diff --git a/usr/src/cmd/cmd-inet/usr.bin/telnet/encrypt.c b/usr/src/cmd/cmd-inet/usr.bin/telnet/encrypt.c index 05d6127211..02bd4a08fa 100644 --- a/usr/src/cmd/cmd-inet/usr.bin/telnet/encrypt.c +++ b/usr/src/cmd/cmd-inet/usr.bin/telnet/encrypt.c @@ -3,8 +3,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * usr/src/cmd/cmd-inet/usr.bin/telnet/encrypt.c */ @@ -142,7 +140,7 @@ findencryption(int type) if (!(I_SUPPORT_ENCRYPT & remote_supports_decrypt & typemask(type))) return (NULL); - for (; (ep->type != NULL) && (ep->type != type); ep++); + for (; (ep->type != 0) && (ep->type != type); ep++); return (ep->type ? ep : NULL); } diff --git a/usr/src/cmd/cmd-inet/usr.bin/telnet/kerberos5.c b/usr/src/cmd/cmd-inet/usr.bin/telnet/kerberos5.c index ea62472061..b4a5c41074 100644 --- a/usr/src/cmd/cmd-inet/usr.bin/telnet/kerberos5.c +++ b/usr/src/cmd/cmd-inet/usr.bin/telnet/kerberos5.c @@ -3,8 +3,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * usr/src/cmd/cmd-inet/usr.bin/telnet/kerberos5.c * @@ -255,7 +253,7 @@ kerberos5_send(Authenticator *ap) } if ((retval = krb5_cc_get_principal(telnet_context, ccache, - &creds.client)) != NULL) { + &creds.client)) != 0) { if (auth_debug_mode) { (void) printf(gettext( "telnet: Kerberos V5: failure on principal " @@ -378,7 +376,7 @@ kerberos5_send(Authenticator *ap) } if ((auth_sendname((uchar_t *)UserNameRequested, - strlen(UserNameRequested))) == NULL) { + strlen(UserNameRequested))) == 0) { if (auth_debug_mode) (void) printf(gettext( "telnet: Not enough room for user name\r\n")); diff --git a/usr/src/cmd/cmd-inet/usr.bin/telnet/telnet.c b/usr/src/cmd/cmd-inet/usr.bin/telnet/telnet.c index 9c0cac01c7..9bfbdf832f 100644 --- a/usr/src/cmd/cmd-inet/usr.bin/telnet/telnet.c +++ b/usr/src/cmd/cmd-inet/usr.bin/telnet/telnet.c @@ -3,8 +3,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Copyright (c) 1988, 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -662,7 +660,7 @@ mklist(buf, name) *argv = 0; argvp = argv+1; n = 0; - for (cp = cp2 = buf; (c = *cp) != NULL; cp++) { + for (cp = cp2 = buf; (c = *cp) != '\0'; cp++) { if (c == '|' || c == ':') { *cp++ = '\0'; /* @@ -1673,7 +1671,7 @@ env_opt_add(ep) else *opt_replyp++ = ENV_USERVAR; for (;;) { - while ((c = *ep++) != NULL) { + while ((c = *ep++) != '\0') { switch (c&0xff) { case IAC: *opt_replyp++ = IAC; diff --git a/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_rules.c b/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_rules.c index 63adcf3dd9..538d1ea09b 100644 --- a/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_rules.c +++ b/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_rules.c @@ -1094,7 +1094,7 @@ ilbd_ip_to_str(uint16_t ipversion, struct in6_addr *addr, char *valstr) IP_COPY_IMPL_2_CLI(addr, &ipaddr); addrptr = (ipversion == AF_INET) ? (void *)&ipaddr.ia_v4 : (void *)&ipaddr.ia_v6; - if (inet_ntop(ipversion, (void *)addrptr, valstr, vallen == NULL)) + if (inet_ntop(ipversion, (void *)addrptr, valstr, vallen) == NULL) logerr("ilbd_ip_to_str: inet_ntop failed"); return; diff --git a/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_scf.c b/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_scf.c index 290a7b2cb6..b1e9bc911c 100644 --- a/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_scf.c +++ b/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilbd_scf.c @@ -419,7 +419,7 @@ ilbd_get_svr_field(char *valstr, struct in6_addr *sgs_addr, ip_ver = atoi(ipverstr); addrptr = (ip_ver == AF_INET) ? (void *)&temp_ip.ia_v4 : (void *)&temp_ip.ia_v6; - if (inet_pton(ip_ver, ipaddr, addrptr) == NULL) { + if (inet_pton(ip_ver, ipaddr, addrptr) == 0) { logerr("ilbd_get_svr_field: inet_pton failed"); return; } diff --git a/usr/src/cmd/cmd-inet/usr.lib/inetd/config.c b/usr/src/cmd/cmd-inet/usr.lib/inetd/config.c index 1d84b01853..d183eb5961 100644 --- a/usr/src/cmd/cmd-inet/usr.lib/inetd/config.c +++ b/usr/src/cmd/cmd-inet/usr.lib/inetd/config.c @@ -48,9 +48,9 @@ /* supported method properties and their attributes */ static inetd_prop_t method_props[] = { -{PR_EXEC_NAME, "", INET_TYPE_STRING, B_FALSE, IVE_UNSET, NULL, B_FALSE}, -{PR_ARG0_NAME, "", INET_TYPE_STRING, B_TRUE, IVE_UNSET, NULL, B_FALSE}, -{SCF_PROPERTY_TIMEOUT, "", INET_TYPE_COUNT, B_TRUE, IVE_UNSET, NULL, B_FALSE}, +{PR_EXEC_NAME, "", INET_TYPE_STRING, B_FALSE, IVE_UNSET, 0, B_FALSE}, +{PR_ARG0_NAME, "", INET_TYPE_STRING, B_TRUE, IVE_UNSET, 0, B_FALSE}, +{SCF_PROPERTY_TIMEOUT, "", INET_TYPE_COUNT, B_TRUE, IVE_UNSET, 0, B_FALSE}, {NULL}, }; diff --git a/usr/src/cmd/cmd-inet/usr.sbin/hostconfig.c b/usr/src/cmd/cmd-inet/usr.sbin/hostconfig.c index 92eb0c81bb..8c6f7d25c2 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/hostconfig.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/hostconfig.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -312,9 +310,7 @@ add_default_route(router_addr) int -bpanswer(res, nb) - struct bp_whoami_res *res; - struct netbuf *nb; +bpanswer(struct bp_whoami_res *res, struct netbuf *nb) { struct in_addr router_addr; static int set; @@ -379,7 +375,7 @@ bpanswer(res, nb) } if (multiple) - return (NULL); + return (0); /* our job is done */ exit(0); diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ilbadm/ilbadm_subr.c b/usr/src/cmd/cmd-inet/usr.sbin/ilbadm/ilbadm_subr.c index 201023cea9..c69c3c8e89 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/ilbadm/ilbadm_subr.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/ilbadm/ilbadm_subr.c @@ -54,14 +54,14 @@ ilbadm_val_type_t algo_types[] = { {(int)ILB_ALG_HASH_IP, "hash-ip", "hip"}, {(int)ILB_ALG_HASH_IP_SPORT, "hash-ip-port", "hipp"}, {(int)ILB_ALG_HASH_IP_VIP, "hash-ip-vip", "hipv"}, - {ILBD_BAD_VAL, NULL, NULL} + {ILBD_BAD_VAL, 0, 0} }; ilbadm_val_type_t topo_types[] = { {(int)ILB_TOPO_DSR, "DSR", "d"}, {(int)ILB_TOPO_NAT, "NAT", "n"}, {(int)ILB_TOPO_HALF_NAT, "HALF-NAT", "h"}, - {ILBD_BAD_VAL, NULL, NULL} + {ILBD_BAD_VAL, 0, 0} }; void @@ -916,7 +916,7 @@ i_store_val(char *val, void *store, ilbadm_key_code_t keyword) rc = ILBADM_INVAL_SYNTAX; break; } - *close = NULL; + *close = '\0'; } rc = i_match_onehost(val, vip, &at); /* re-assemble string as we found it */ diff --git a/usr/src/cmd/cmd-inet/usr.sbin/in.rarpd.c b/usr/src/cmd/cmd-inet/usr.sbin/in.rarpd.c index 81039c3e86..6907abc8d4 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/in.rarpd.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/in.rarpd.c @@ -271,7 +271,7 @@ main(int argc, char *argv[]) /* * Start delayed processing thread. */ - (void) thr_create(NULL, NULL, (void *(*)(void *))do_delay_write, NULL, + (void) thr_create(NULL, 0, (void *(*)(void *))do_delay_write, NULL, THR_NEW_LWP, NULL); /* @@ -279,7 +279,7 @@ main(int argc, char *argv[]) */ for (rdev = rarpdev_head; rdev != NULL; rdev = rdev->next) { if (rdev->dh_rarp != NULL) { - (void) thr_create(NULL, NULL, + (void) thr_create(NULL, 0, (void *(*)(void *))do_rarp, (void *)rdev, THR_NEW_LWP, NULL); } diff --git a/usr/src/cmd/cmd-inet/usr.sbin/in.telnetd.c b/usr/src/cmd/cmd-inet/usr.sbin/in.telnetd.c index 181e6cbabe..afeb5a5c55 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/in.telnetd.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/in.telnetd.c @@ -922,7 +922,7 @@ auth_is(uchar_t *data, int cnt) return; } - while (aptr->AuthName != NULL && + while (aptr->AuthName != 0 && (aptr->AuthName != data[0] || aptr->AuthHow != data[1])) aptr++; @@ -1117,7 +1117,7 @@ encrypt_is(uchar_t *data, int cnt) break; default: iv_status = CFB64_IV_BAD; - encr_data.decrypt.type = NULL; + encr_data.decrypt.type = 0; if (enc_debug) (void) fprintf(stderr, "\t(encrypt_is) Can't find type (%d) " diff --git a/usr/src/cmd/cmd-inet/usr.sbin/inetadm/inetadm.c b/usr/src/cmd/cmd-inet/usr.sbin/inetadm/inetadm.c index 66ecf99d37..d8e7c0878f 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/inetadm/inetadm.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/inetadm/inetadm.c @@ -810,8 +810,8 @@ modify_inst_props_cb(void *data, scf_walkinfo_t *wip) switch (mod[j].ip_type) { case INET_TYPE_INTEGER: - if (uu_strtoint(value, &new_int, sizeof (new_int), NULL, - NULL, NULL) == -1) + if (uu_strtoint(value, &new_int, sizeof (new_int), 0, + 0, 0) == -1) uu_die(gettext("Error: \"%s\" is not a valid " "integer value.\n"), value); @@ -938,8 +938,8 @@ modify_defaults(int argc, char *argv[]) switch (mod[j].ip_type) { case INET_TYPE_INTEGER: - if (uu_strtoint(value, &new_int, sizeof (new_int), NULL, - NULL, NULL) == -1) + if (uu_strtoint(value, &new_int, sizeof (new_int), 0, + 0, 0) == -1) uu_die(gettext("Error: \"%s\" is not a valid " "integer value.\n"), value); diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipqosconf/ipqosconf.c b/usr/src/cmd/cmd-inet/usr.sbin/ipqosconf/ipqosconf.c index 914c6f05db..d41ee24918 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/ipqosconf/ipqosconf.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/ipqosconf/ipqosconf.c @@ -3096,7 +3096,7 @@ int ifindex) /* truncate any logical suffix */ if ((cp = strchr(lr->lifr_name, '@')) != NULL) { - *cp = NULL; + *cp = '\0'; } /* print interface name */ @@ -4265,8 +4265,8 @@ int *upper) *upper = (int)strtol(cp, &end2, 10); SKIPWS(end); SKIPWS(end2); - if ((range_st == end) || (*end != NULL) || - (cp == end) || (*end2 != NULL)) { + if ((range_st == end) || (*end != '\0') || + (cp == end) || (*end2 != '\0')) { IPQOSCDBG0(L0, "Failed reading a-b\n"); return (IPQOS_CONF_ERR); } @@ -4275,7 +4275,7 @@ int *upper) *lower = *upper = (int)strtol(range_st, &end, 10); SKIPWS(end); - if ((range_st == end) || (*end != NULL)) { + if ((range_st == end) || (*end != '\0')) { IPQOSCDBG0(L0, "Failed reading a\n"); return (IPQOS_CONF_ERR); } @@ -4405,7 +4405,7 @@ str_val_nd_t *enum_nvs) } else { value = (int)strtol(svalue, &end, 10); SKIPWS(end); - if ((svalue == end) || (*end != NULL)) { + if ((svalue == end) || (*end != '\0')) { IPQOSCDBG0(L0, "Invalid value\n"); goto array_err; } @@ -4971,7 +4971,7 @@ read_enum_nvs(char *line, char *module_name) goto fail; } bcopy(start, name, len); - name[len] = NULL; + name[len] = '\0'; IPQOSCDBG1(L0, "Stored name: %s\n", name); /* read assignment */ @@ -5190,7 +5190,7 @@ char *module) token = strtok(info_str, ","); *size = (uint32_t)strtol(token, &end, 10); SKIPWS(end); - if ((end == token) || (*end != NULL)) { + if ((end == token) || (*end != '\0')) { IPQOSCDBG0(L0, "Invalid size\n"); goto fail; } @@ -9326,7 +9326,7 @@ char *dstpath) /* not pwd or root */ } else { - *pathend = NULL; + *pathend = '\0'; tmppath = malloc(strlen(dstpath) + strlen("/ipqosconf.tmp") + 1); if (tmppath == NULL) { diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ikeadm.c b/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ikeadm.c index 60f3ed937c..e6257c6184 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ikeadm.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ikeadm.c @@ -735,7 +735,7 @@ static keywdtab_t idtypes[] = { {SADB_X_IDENTTYPE_ADDR_RANGE, "rangev4"}, {SADB_X_IDENTTYPE_ADDR_RANGE, "rangev6"}, {SADB_X_IDENTTYPE_KEY_ID, "keyid"}, - {NULL, 0} + {0, NULL} }; static int @@ -903,7 +903,7 @@ static keywdtab_t psfldtypes[] = { {PSFLD_REMIDTYPE, "remoteidtype"}, {PSFLD_MODE, "ike_mode"}, {PSFLD_KEY, "key"}, - {NULL, 0} + {0, NULL} }; static int @@ -929,7 +929,7 @@ static keywdtab_t ikemodes[] = { {IKE_XCHG_IDENTITY_PROTECT, "main"}, {IKE_XCHG_AGGRESSIVE, "aggressive"}, {IKE_XCHG_IP_AND_AGGR, "both"}, - {NULL, 0} + {0, NULL} }; static int @@ -3348,7 +3348,7 @@ parseit(int argc, char **argv, char *notused, boolean_t notused_either) case IKE_SVC_DUMP_AUTHALGS: case IKE_SVC_DUMP_PS: case IKE_SVC_DUMP_CERTCACHE: - if (argc != NULL) { + if (argc != 0) { print_dump_help(); break; } diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ipsecconf.c b/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ipsecconf.c index fbd72b9a40..e8203530b4 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ipsecconf.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ipsecconf.c @@ -3026,7 +3026,7 @@ parse_address(int type, char *addr_str) ptr = strchr(addr_str, '/'); if (ptr != NULL) { has_mask = B_TRUE; - *ptr++ = NULL; + *ptr++ = '\0'; prefix_len = in_getprefixlen(ptr); if (prefix_len < 0) { @@ -3740,14 +3740,14 @@ scan: /* Truncate at the beginning of a comment */ cp = strchr(buf, '#'); if (cp != NULL) - *cp = NULL; + *cp = '\0'; /* Skip any whitespace */ - while (*buf != NULL && isspace(*buf)) + while (*buf != '\0' && isspace(*buf)) buf++; /* Empty line */ - if (*buf == NULL) + if (*buf == '\0') continue; /* @@ -3772,15 +3772,15 @@ scan: tmp_buf = buf; /* Skip until next whitespace or CURL_BEGIN */ - while (*buf != NULL && !isspace(*buf) && + while (*buf != '\0' && !isspace(*buf) && *buf != CURL_BEGIN) buf++; - if (*buf != NULL) { + if (*buf != '\0') { if (tmp_buf == buf) /* No action token */ goto error; if (*buf == CURL_BEGIN) { - *buf = NULL; + *buf = '\0'; /* Allocate an extra byte for the null also */ if ((*action = malloc(strlen(tmp_buf) + 1)) == NULL) { @@ -3791,7 +3791,7 @@ scan: *buf = CURL_BEGIN; } else { /* We have hit a space */ - *buf++ = NULL; + *buf++ = '\0'; /* Allocate an extra byte for the null also */ if ((*action = malloc(strlen(tmp_buf) + 1)) == NULL) { @@ -3804,7 +3804,7 @@ scan: * Copy the rest of the line into the * leftover buffer. */ - if (*buf != NULL) { + if (*buf != '\0') { (void) strlcpy(lo_buf, buf, sizeof (lo_buf)); *leftover = lo_buf; } else { @@ -3873,14 +3873,14 @@ scan: /* Truncate at the beginning of a comment */ cp = strchr(buf, '#'); if (cp != NULL) - *cp = NULL; + *cp = '\0'; /* Skip any whitespace */ - while (*buf != NULL && isspace(*buf)) + while (*buf != '\0' && isspace(*buf)) buf++; /* Empty line */ - if (*buf == NULL) + if (*buf == '\0') continue; /* * Store the command for error reporting @@ -3920,15 +3920,15 @@ scan: * Arguments are separated by white spaces or * newlines. Scan till you see a CURL_END. */ - while (*buf != NULL) { + while (*buf != '\0') { if (*buf == CURL_END) { ret: - *buf++ = NULL; + *buf++ = '\0'; /* * Copy the rest of the line into the * leftover buffer if any. */ - if (*buf != NULL) { + if (*buf != '\0') { (void) strlcpy(lo_buf, buf, sizeof (lo_buf)); *leftover = lo_buf; @@ -3941,14 +3941,14 @@ ret: * Skip any trailing whitespace until we see a * non white-space character. */ - while (*buf != NULL && isspace(*buf)) + while (*buf != '\0' && isspace(*buf)) buf++; if (*buf == CURL_END) goto ret; /* Scan the next line as this buffer is empty */ - if (*buf == NULL) + if (*buf == '\0') break; if (i >= MAXARGS) { @@ -3965,7 +3965,7 @@ ret: * Real scan of the argument takes place here. * Skip past till space or CURL_END. */ - while (*buf != NULL && !isspace(*buf) && + while (*buf != '\0' && !isspace(*buf) && *buf != CURL_END) { buf++; } @@ -3973,9 +3973,9 @@ ret: * Either a space or we have hit the CURL_END or * the real end. */ - if (*buf != NULL) { + if (*buf != '\0') { if (*buf == CURL_END) { - *buf++ = NULL; + *buf++ = '\0'; if ((argvec[i] = malloc(strlen(tmp_buf) + 1)) == NULL) { warn("malloc"); @@ -3993,7 +3993,7 @@ ret: * Copy the rest of the line into the * leftover buffer. */ - if (*buf != NULL) { + if (*buf != '\0') { (void) strlcpy(lo_buf, buf, sizeof (lo_buf)); *leftover = lo_buf; @@ -4002,7 +4002,7 @@ ret: } return (PARSE_SUCCESS); } else { - *buf++ = NULL; + *buf++ = '\0'; } } /* @@ -4151,7 +4151,7 @@ parse_one(FILE *fp, act_prop_t *act_props) if (leftover != NULL) { /* Accomodate spaces at the end */ - while (*leftover != NULL) { + while (*leftover != '\0') { if (*leftover == BACK_SLASH) { warnx(gettext("Invalid line " "continuation character.")); diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ipseckey.c b/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ipseckey.c index 14cb3eb28d..9667fa4047 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ipseckey.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ipseckey.c @@ -541,8 +541,8 @@ static struct toktable { {"nat_rport", TOK_NATRPORT, NEXTNUM}, {"encap", TOK_ENCAP, NEXTNUMSTR}, - {"outbound", TOK_FLAG_OUTBOUND, NULL}, - {"inbound", TOK_FLAG_INBOUND, NULL}, + {"outbound", TOK_FLAG_OUTBOUND, 0}, + {"inbound", TOK_FLAG_INBOUND, 0}, {"reserved_bits", TOK_RESERVED, NEXTNUM}, {"replay_value", TOK_REPLAY_VALUE, NEXTNUM}, diff --git a/usr/src/cmd/cmd-inet/usr.sbin/kssl/kssladm/kssladm_create.c b/usr/src/cmd/cmd-inet/usr.sbin/kssl/kssladm/kssladm_create.c index aed788596e..7f3233154f 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/kssl/kssladm/kssladm_create.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/kssl/kssladm/kssladm_create.c @@ -108,14 +108,14 @@ kmf_to_kssl(int nxkey, KMF_RAW_KEY_DATA *rsa, int ncerts, {CKA_ID, NULL, 0} }; kssl_object_attribute_t kssl_tmpl_attrs[MAX_ATTR_CNT] = { - {SUN_CKA_MODULUS, NULL, 0}, - {SUN_CKA_PUBLIC_EXPONENT, NULL, 0}, - {SUN_CKA_PRIVATE_EXPONENT, NULL, 0}, - {SUN_CKA_PRIME_1, NULL, 0}, - {SUN_CKA_PRIME_2, NULL, 0}, - {SUN_CKA_EXPONENT_1, NULL, 0}, - {SUN_CKA_EXPONENT_2, NULL, 0}, - {SUN_CKA_COEFFICIENT, NULL, 0} + {SUN_CKA_MODULUS, 0, 0}, + {SUN_CKA_PUBLIC_EXPONENT, 0, 0}, + {SUN_CKA_PRIVATE_EXPONENT, 0, 0}, + {SUN_CKA_PRIME_1, 0, 0}, + {SUN_CKA_PRIME_2, 0, 0}, + {SUN_CKA_EXPONENT_1, 0, 0}, + {SUN_CKA_EXPONENT_2, 0, 0}, + {SUN_CKA_COEFFICIENT, 0, 0} }; KMF_BIGINT priv_key_bignums[MAX_ATTR_CNT]; int attr_cnt; diff --git a/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/nwamcfg.c b/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/nwamcfg.c index 690377cc2d..263f3f62b2 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/nwamcfg.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/nwamcfg.c @@ -603,7 +603,7 @@ CPL_MATCH_FN(cmd_cpl_fn) return (add_stuff(cpl, line, ncp_scope_cmds, word_end)); } /* should never get here */ - return (NULL); + return (0); } const char * diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/nfs4_xdr.c b/usr/src/cmd/cmd-inet/usr.sbin/snoop/nfs4_xdr.c index 88e2ff0d9f..801611ff9b 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/nfs4_xdr.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/nfs4_xdr.c @@ -1991,7 +1991,7 @@ xdr_entry4(register XDR *xdrs, entry4 *objp) objp->nextentry = (entry4 *)mem_alloc(sizeof (entry4)); if (objp->nextentry == NULL) - return (NULL); + return (FALSE); bzero(objp->nextentry, sizeof (entry4)); objp = objp->nextentry; diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_ether.c b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_ether.c index 029ed66116..f084365faf 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_ether.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_ether.c @@ -100,7 +100,7 @@ interface_t INTERFACES[] = { { DL_6TO4, 0, 9, 1, IPPROTO_ENCAP, IPPROTO_IPV6, ipv4_header_len, interpret_iptun, B_FALSE }, - { (uint_t)-1, 0, 0, 0, 0, NULL, NULL, B_FALSE } + { (uint_t)-1, 0, 0, 0, 0, 0, NULL, B_FALSE } }; /* externals */ diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rport.c b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rport.c index 8e474fe470..77e9d97766 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rport.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rport.c @@ -167,7 +167,7 @@ reservedport(int proto, int port) switch (proto) { case IPPROTO_TCP: pt = pt_tcp; break; case IPPROTO_UDP: pt = pt_udp; break; - default: return (NULL); + default: return (0); } for (p = pt; p->pt_num; p++) { if (port == p->pt_num) diff --git a/usr/src/cmd/cmd-inet/usr.sbin/soconfig.c b/usr/src/cmd/cmd-inet/usr.sbin/soconfig.c index a9315cb218..6f990db460 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/soconfig.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/soconfig.c @@ -268,27 +268,27 @@ split_line(char *line, char *argvec[], int maxargvec) /* Truncate at the beginning of a comment */ cp = strchr(line, '#'); if (cp != NULL) - *cp = NULL; + *cp = '\0'; /* CONSTCOND */ while (1) { /* Skip any whitespace */ - while (isspace(*line) && *line != NULL) + while (isspace(*line)) line++; if (i >= maxargvec) return (i); argvec[i] = line; - if (*line == NULL) + if (*line == '\0') return (i); i++; /* Skip until next whitespace */ - while (!isspace(*line) && *line != NULL) + while (!isspace(*line) && *line != '\0') line++; - if (*line != NULL) { + if (*line != '\0') { /* Break off argument */ - *line++ = NULL; + *line++ = '\0'; } } /* NOTREACHED */ diff --git a/usr/src/cmd/consadm/consadm.c b/usr/src/cmd/consadm/consadm.c index d31d7f13d6..cd8eb54394 100644 --- a/usr/src/cmd/consadm/consadm.c +++ b/usr/src/cmd/consadm/consadm.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "utils.h" #include <locale.h> #include <poll.h> @@ -394,7 +392,7 @@ addtolist(char *dev) buf[0] == SPACE || buf[0] == TAB) continue; len = strlen(buf); - buf[len - 1] = NULL; /* Clear carriage return */ + buf[len - 1] = '\0'; /* Clear carriage return */ if (pathcmp(dev, buf) == 0) { /* they match so use name passed in. */ (void) fprintf(nfp, "%s\n", dev); @@ -457,7 +455,7 @@ removefromlist(char *dev) value[0] == SPACE || value[0] == TAB) continue; len = strlen(value); - value[len - 1] = NULL; /* Clear carriage return */ + value[len - 1] = '\0'; /* Clear carriage return */ if (pathcmp(dev, value) == 0) { /* they match so don't write it */ continue; diff --git a/usr/src/cmd/cpio/cpio.c b/usr/src/cmd/cpio/cpio.c index 1816bddeb3..3de636654c 100644 --- a/usr/src/cmd/cpio/cpio.c +++ b/usr/src/cmd/cpio/cpio.c @@ -88,7 +88,7 @@ typedef ulong_t u_off_t; #define XATTRHDR ".hdr" #define NAMELEN 32 -#define TYPELEN 16 +#define TYPELEN 16 #define PERMLEN 4 #define FILE_COPIED 1 @@ -352,17 +352,17 @@ typedef struct sl_remap { dev_t dev; /* device */ int inode_count; /* # inodes seen on dev */ - struct sl_remap *next; /* next in the chain */ + struct sl_remap *next; /* next in the chain */ } sl_remap_t; /* forward declarations */ -static sl_info_t *sl_info_alloc(void); -static sl_info_t *sl_insert(dev_t, ino_t, int); +static sl_info_t *sl_info_alloc(void); +static sl_info_t *sl_insert(dev_t, ino_t, int); static ulong_t sl_numlinks(dev_t, ino_t, int); static void sl_preview_synonyms(void); static void sl_remember_tgt(const struct stat *, int, int); -static sl_info_t *sl_search(dev_t, ino_t, int); +static sl_info_t *sl_search(dev_t, ino_t, int); static sl_info_t *sl_devhash_lookup(dev_t); static void sl_devhash_insert(dev_t, sl_info_t *); @@ -652,7 +652,7 @@ typedef enum { static struct xattr_hdr *xattrhead; static struct xattr_buf *xattrp; static struct xattr_buf *xattr_linkp; -static int xattrbadhead; /* is extended attribute header bad? */ +static int xattrbadhead; /* is extended attribute header bad? */ static int append_secattr(char **, int *, acl_t *); @@ -1295,7 +1295,7 @@ ckopts(long mask) if (mask & OCH) { t_p = Hdr_p; - while (*t_p != NULL) { + while (*t_p != '\0') { if (isupper(*t_p)) { *t_p = 'a' + (*t_p - 'A'); } @@ -1892,7 +1892,7 @@ creat_spec(int dirfd) curdir = strrchr(nam_p, '.'); - if (curdir != NULL && curdir[1] == NULL) { + if (curdir != NULL && curdir[1] == '\0') { lastslash = strrchr(nam_p, '/'); if (lastslash != NULL) { @@ -2607,10 +2607,10 @@ errout: * Strip off the sparse file information that is prepended to * the compressed sparse file. The information is in the following * format: - * <prepended info size><SP><orig file size><SP><holes info> + * <prepended info size><SP><orig file size><SP><holes info> * where prepended info size is long right justified in 10 bytes. * Holesdata consists of the series of offset pairs: - * <data offset><SP><hole offset><SP><data offset><SP><hole offset>... + * <data offset><SP><hole offset><SP><data offset><SP><hole offset>... * prepended info size and original file size have been read in gethdr(). * We read the rest of holes information here in this function. */ @@ -4070,13 +4070,13 @@ retry_open_attr(int pdirfd, int cwd, char *fullname, char *pattr, char *name, * it will be set to 0. * * Possible return values: - * ATTR_OK Successfully opened and, if needed, changed into the + * ATTR_OK Successfully opened and, if needed, changed into the * attribute directory containing attrname. * ATTR_SKIP The command line specifications don't enable the * processing of the attribute type. - * ATTR_CHDIR_ERR An error occurred while trying to change into an + * ATTR_CHDIR_ERR An error occurred while trying to change into an * attribute directory. - * ATTR_OPEN_ERR An error occurred while trying to open an + * ATTR_OPEN_ERR An error occurred while trying to open an * attribute directory. * ATTR_XATTR_ERR The underlying file system doesn't support extended * attributes. @@ -4673,7 +4673,7 @@ gethdr(void) return (0); else { preptr = &prebuf[0]; - if (*preptr != NULL) { + if (*preptr != '\0') { k = strlen(&prebuf[0]); if (k < PRESIZ) { (void) strcpy(&fullnam[0], &prebuf[0]); @@ -8026,10 +8026,9 @@ is_floppy(int fd) * existing secinfo. */ static int -append_secattr( - char **secinfo, /* existing security info */ - int *secinfo_len, /* length of existing security info */ - acl_t *aclp) /* new attribute data pointer */ +append_secattr(char **secinfo, /* existing security info */ + int *secinfo_len, /* length of existing security info */ + acl_t *aclp) /* new attribute data pointer */ { char *new_secinfo; char *attrtext; @@ -8265,7 +8264,7 @@ xattrs_out(int (*func)()) #if defined(_PC_SATTR_ENABLED) if (SysAtflag) { int filefd; - nvlist_t *slist = NULL; + nvlist_t *slist = NULL; /* * Determine if there are non-transient system @@ -8552,7 +8551,7 @@ prepare_xattr_hdr( { char *bufhead; /* ptr to full buffer */ char *aptr; - struct xattr_hdr *hptr; /* ptr to header in bufhead */ + struct xattr_hdr *hptr; /* ptr to header in bufhead */ struct xattr_buf *tptr; /* ptr to pathing pieces */ int totalen; /* total buffer length */ int len; /* length returned to user */ @@ -9313,7 +9312,7 @@ preview_attrs(char *s, char *attrparent) #if defined(_PC_SATTR_ENABLED) if (SysAtflag) { int filefd; - nvlist_t *slist = NULL; + nvlist_t *slist = NULL; /* Determine if there are non-transient system attributes. */ errno = 0; diff --git a/usr/src/cmd/csh/sh.glob.c b/usr/src/cmd/csh/sh.glob.c index a45e21f936..db0122c0c6 100644 --- a/usr/src/cmd/csh/sh.glob.c +++ b/usr/src/cmd/csh/sh.glob.c @@ -4,7 +4,7 @@ */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. @@ -12,8 +12,6 @@ * specifies the terms and conditions for redistribution. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "sh.h" #include "sh.tconst.h" #include <dirent.h> @@ -130,7 +128,7 @@ collect(tchar *as) printf("acollect done\n"); #endif } else if (noglob || eq(as, S_LBRA /* "{" */) || - eq(as, S_BRABRA /* "{}" */)) { + eq(as, S_BRABRA /* "{}" */)) { Gcat(as, S_ /* "" */); sort(); } else @@ -193,7 +191,7 @@ expand(tchar *as) (void) strcpy_(gpath, gpath + 1); } else (void) strcpy_(gpath, - value(S_home /* "home" */)); + value(S_home /* "home" */)); gpathp = strend(gpath); } } @@ -241,7 +239,7 @@ matchdir_(tchar *pattern) * BSD's opendir would open "." if argument is NULL, but not S5 */ - if (*gpath == NULL) + if (*gpath == '\0') dirp = opendir_(S_DOT /* "." */); else dirp = opendir_(gpath); @@ -635,7 +633,7 @@ tglob(tchar **t) if (*p == '~') gflag |= 2; else if (*p == '{' && (p[1] == '\0' || - p[1] == '}' && p[2] == '\0')) + p[1] == '}' && p[2] == '\0')) continue; while (c = *p++) if (isglob(c)) diff --git a/usr/src/cmd/csplit/csplit.c b/usr/src/cmd/csplit/csplit.c index 456780b9a3..21c0e0be49 100644 --- a/usr/src/cmd/csplit/csplit.c +++ b/usr/src/cmd/csplit/csplit.c @@ -24,7 +24,7 @@ */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Copyright (c) 2018, Joyent, Inc. @@ -114,7 +114,7 @@ main(int argc, char **argv) break; case 'n': /* POSIX.2 */ - for (ptr = optarg; *ptr != NULL; ptr++) + for (ptr = optarg; *ptr != '\0'; ptr++) if (!isdigit((int)*ptr)) fatal("-n num\n", NULL); fiwidth = atoi(optarg); @@ -225,7 +225,7 @@ asc_to_ll(char *str, long long *plc) } break; } - for (; *str != NULL; str++) + for (; *str != '\0'; str++) if (*str >= '0' && *str <= '9') *plc = *plc * 10 + *str - '0'; else @@ -362,7 +362,7 @@ getfile() if (create) { if (fptr == 0) - for (fptr = file; *fptr != NULL; fptr++) + for (fptr = file; *fptr != '\0'; fptr++) continue; (void) sprintf(fptr, "%.*d", fiwidth, ctr++); @@ -458,7 +458,7 @@ num_arg(char *arg, int md) ptr = rep; for (++arg; *arg != '}'; arg += len) { - if (*arg == NULL) + if (*arg == '\0') fatal("%s: missing '}'\n", targ); if ((len = mblen(arg, MB_LEN_MAX)) <= 0) len = 1; @@ -467,7 +467,7 @@ num_arg(char *arg, int md) (void) memcpy(ptr, arg, len); ptr += len; } - *ptr = NULL; + *ptr = '\0'; if ((asc_to_ll(rep, &repeat) == ERR) || repeat < 0L) fatal("Illegal repeat count: %s\n", targ); if (md == LINMODE) { @@ -506,7 +506,7 @@ re_arg(char *string) if (*ptr == '\\') ++ptr; - if (*ptr == NULL) + if (*ptr == '\0') fatal("%s: missing delimiter\n", targ); if ((len = mblen(ptr, MB_LEN_MAX)) <= 0) @@ -520,7 +520,7 @@ re_arg(char *string) * to be '/' or '%'. */ - *ptr = NULL; + *ptr = '\0'; if (asc_to_ll(++ptr, &offset) == ERR) fatal("%s: illegal offset\n", string); diff --git a/usr/src/cmd/devctl/devctl.c b/usr/src/cmd/devctl/devctl.c index 15b76da9ac..530996dd03 100644 --- a/usr/src/cmd/devctl/devctl.c +++ b/usr/src/cmd/devctl/devctl.c @@ -32,17 +32,17 @@ * usage: devctl [-v] command [device/bus pathname] * * Commands: - * list - list all controllers exporting the devctl interface + * list - list all controllers exporting the devctl interface * online - online a device * offline - offline a device - * remove - remove a device from the device tree - * quiesce - quiesce the bus + * remove - remove a device from the device tree + * quiesce - quiesce the bus * unquiesce - resume bus activity * configure - configure a bus's child devices * unconfigure - unconfigure a bus's child devices * bus-reset - reset a bus * dev-reset - reset a device - * bus-getstate - return the current state of the bus + * bus-getstate - return the current state of the bus * dev-getstate - return the current state of the device * bus-devcreate - create a new device, bus specific * dev-raisepower - power up a device via pm_raise_power() (pm) @@ -181,7 +181,7 @@ int main(int argc, char *argv[]) { int c; - int rv; + int rv; int pathlen; struct cmds *dcmd; devctl_hdl_t dcp; @@ -548,7 +548,7 @@ run_list_ctlrs(void) progname); exit(-1); } - (void) di_walk_minor(dinode, DDI_NT_NEXUS, NULL, 0, &nexif); + (void) di_walk_minor(dinode, DDI_NT_NEXUS, 0, NULL, &nexif); di_fini(dinode); exit(0); } diff --git a/usr/src/cmd/diskinfo/diskinfo.c b/usr/src/cmd/diskinfo/diskinfo.c index 36376827fc..ca09fe027e 100644 --- a/usr/src/cmd/diskinfo/diskinfo.c +++ b/usr/src/cmd/diskinfo/diskinfo.c @@ -264,7 +264,7 @@ enumerate_disks(di_opts_t *opts) topo_strerror(err)); } - for (i = 0; media != NULL && media[i] != NULL; i++) { + for (i = 0; media != NULL && media[i] != 0; i++) { if ((disk = dm_get_associated_descriptors(media[i], DM_DRIVE, &err)) == NULL) { continue; diff --git a/usr/src/cmd/dladm/dladm.c b/usr/src/cmd/dladm/dladm.c index 97fc010fa2..2de38a993c 100644 --- a/usr/src/cmd/dladm/dladm.c +++ b/usr/src/cmd/dladm/dladm.c @@ -450,7 +450,7 @@ static const struct option lopts[] = { {"bw-limit", required_argument, 0, 'b'}, {"mac-address", required_argument, 0, 'm'}, {"slot", required_argument, 0, 'n'}, - { 0, 0, 0, 0 } + { NULL, 0, NULL, 0 } }; static const struct option show_lopts[] = { @@ -463,7 +463,7 @@ static const struct option show_lopts[] = { {"output", required_argument, 0, 'o'}, {"persistent", no_argument, 0, 'P'}, {"lacp", no_argument, 0, 'L'}, - { 0, 0, 0, 0 } + { NULL, 0, NULL, 0 } }; static const struct option iptun_lopts[] = { @@ -474,7 +474,7 @@ static const struct option iptun_lopts[] = { {"parsable", no_argument, 0, 'p'}, {"parseable", no_argument, 0, 'p'}, {"persistent", no_argument, 0, 'P'}, - { 0, 0, 0, 0 } + { NULL, 0, NULL, 0 } }; static char * const iptun_addropts[] = { @@ -502,7 +502,7 @@ static const struct option prop_longopts[] = { {"parsable", no_argument, 0, 'c' }, {"parseable", no_argument, 0, 'c' }, {"persistent", no_argument, 0, 'P' }, - { 0, 0, 0, 0 } + { NULL, 0, NULL, 0 } }; static const struct option wifi_longopts[] = { @@ -522,7 +522,7 @@ static const struct option wifi_longopts[] = { {"root-dir", required_argument, 0, 'R' }, {"persistent", no_argument, 0, 'P' }, {"file", required_argument, 0, 'f' }, - { 0, 0, 0, 0 } + { NULL, 0, NULL, 0 } }; static const struct option showeth_lopts[] = { @@ -530,7 +530,7 @@ static const struct option showeth_lopts[] = { {"parseable", no_argument, 0, 'p' }, {"extended", no_argument, 0, 'x' }, {"output", required_argument, 0, 'o' }, - { 0, 0, 0, 0 } + { NULL, 0, NULL, 0 } }; static const struct option vnic_lopts[] = { @@ -544,7 +544,7 @@ static const struct option vnic_lopts[] = { {"mac-prefix", required_argument, 0, 'r' }, {"vrid", required_argument, 0, 'V' }, {"address-family", required_argument, 0, 'A' }, - { 0, 0, 0, 0 } + { NULL, 0, NULL, 0 } }; static const struct option part_lopts[] = { @@ -554,7 +554,7 @@ static const struct option part_lopts[] = { {"force", no_argument, 0, 'f' }, {"root-dir", required_argument, 0, 'R' }, {"prop", required_argument, 0, 'p' }, - { 0, 0, 0, 0 } + { NULL, 0, NULL, 0 } }; static const struct option show_part_lopts[] = { @@ -563,13 +563,13 @@ static const struct option show_part_lopts[] = { {"link", required_argument, 0, 'l' }, {"persistent", no_argument, 0, 'P' }, {"output", required_argument, 0, 'o' }, - { 0, 0, 0, 0 } + { NULL, 0, NULL, 0 } }; static const struct option etherstub_lopts[] = { {"temporary", no_argument, 0, 't' }, {"root-dir", required_argument, 0, 'R' }, - { 0, 0, 0, 0 } + { NULL, 0, NULL, 0 } }; static const struct option usage_opts[] = { @@ -577,7 +577,7 @@ static const struct option usage_opts[] = { {"format", required_argument, 0, 'F' }, {"start", required_argument, 0, 's' }, {"stop", required_argument, 0, 'e' }, - { 0, 0, 0, 0 } + { NULL, 0, NULL, 0 } }; static const struct option simnet_lopts[] = { @@ -585,7 +585,7 @@ static const struct option simnet_lopts[] = { {"root-dir", required_argument, 0, 'R' }, {"media", required_argument, 0, 'm' }, {"peer", required_argument, 0, 'p' }, - { 0, 0, 0, 0 } + { NULL, 0, NULL, 0 } }; static const struct option bridge_lopts[] = { @@ -597,7 +597,7 @@ static const struct option bridge_lopts[] = { { "link", required_argument, 0, 'l' }, { "max-age", required_argument, 0, 'm' }, { "priority", required_argument, 0, 'p' }, - { NULL, NULL, 0, 0 } + { NULL, 0, NULL, 0 } }; static const struct option bridge_show_lopts[] = { @@ -609,7 +609,7 @@ static const struct option bridge_show_lopts[] = { { "parseable", no_argument, 0, 'p' }, { "statistics", no_argument, 0, 's' }, { "trill", no_argument, 0, 't' }, - { 0, 0, 0, 0 } + { NULL, 0, NULL, 0 } }; /* @@ -862,7 +862,7 @@ static const ofmt_field_t phys_fields[] = { offsetof(link_fields_buf_t, link_phys_device), print_default_cb}, { "FLAGS", 7, offsetof(link_fields_buf_t, link_flags), print_default_cb}, -{ NULL, 0, NULL, 0}} +{ NULL, 0, 0, NULL}} ; /* @@ -6348,7 +6348,7 @@ parse_wlan_keys(char *str, dladm_wlan_key_t **keys, uint_t *key_countp) char *field, *token, *lasts = NULL, c; token = str; - while ((c = *token++) != NULL) { + while ((c = *token++) != '\0') { if (c == ',') nfields++; } @@ -7553,7 +7553,7 @@ do_delete_secobj(int argc, char **argv, const char *use) die("secure object name required"); token = argv[optind]; - while ((c = *token++) != NULL) { + while ((c = *token++) != '\0') { if (c == ',') nfields++; } @@ -7706,7 +7706,7 @@ do_show_secobj(int argc, char **argv, const char *use) token = argv[optind]; if (token == NULL) die("secure object name required"); - while ((c = *token++) != NULL) { + while ((c = *token++) != '\0') { if (c == ',') obj_fields++; } diff --git a/usr/src/cmd/eeprom/i386/benv.c b/usr/src/cmd/eeprom/i386/benv.c index 11613cc5ce..0e3a89f0b7 100644 --- a/usr/src/cmd/eeprom/i386/benv.c +++ b/usr/src/cmd/eeprom/i386/benv.c @@ -360,7 +360,7 @@ add_comm(benv_des_t *bd, char *base, char *last, char **next, int *line) nl = 0; } } - *(p - 1) = NULL; + *(p - 1) = '\0'; add_bent(bd->elist, base, NULL, NULL, NULL); *next = p; *line += lines; diff --git a/usr/src/cmd/logins/Makefile b/usr/src/cmd/logins/Makefile index d9df94c5b9..865f2163bd 100644 --- a/usr/src/cmd/logins/Makefile +++ b/usr/src/cmd/logins/Makefile @@ -21,11 +21,10 @@ # # # Copyright (c) 1990 by Sun Microsystems, Inc. +# Copyright 2019 Peter Tribble. # -PROG= logins -PKGINFO= pkginfo -TXTS= $(PKGINFO) +PROG= logins include ../Makefile.cmd TEXT_DOMAIN= SUNW_OST_ADMIN @@ -37,7 +36,7 @@ FILEMODE= 0750 .KEEP_STATE: -all: $(PROG) $(TXTS) +all: $(PROG) install: all $(ROOTPROG) diff --git a/usr/src/cmd/logins/logins.xcl b/usr/src/cmd/logins/logins.xcl deleted file mode 100644 index f2e56d8dea..0000000000 --- a/usr/src/cmd/logins/logins.xcl +++ /dev/null @@ -1,21 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# diff --git a/usr/src/cmd/logins/pkginfo b/usr/src/cmd/logins/pkginfo deleted file mode 100644 index c5683498ef..0000000000 --- a/usr/src/cmd/logins/pkginfo +++ /dev/null @@ -1,33 +0,0 @@ -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright 1992 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# -# This is the package info file for -# the user command "logins" in the user administration display facility. -# -# -PKG="cfg" -NAME="Configuration Display" -VERSION="0.0" -CATEGORY="system" diff --git a/usr/src/cmd/lp/cmd/lpsched/disp1.c b/usr/src/cmd/lp/cmd/lpsched/disp1.c index b3f96ccd21..a1c2dc5ccf 100644 --- a/usr/src/cmd/lp/cmd/lpsched/disp1.c +++ b/usr/src/cmd/lp/cmd/lpsched/disp1.c @@ -1161,7 +1161,7 @@ s_pass_peer_connection(char *m, MESG *md) (void) getmessage(m, S_PASS_PEER_CONNECTION); syslog(LOG_DEBUG, "s_pass_peer_connection()"); - memset(&recv_fd, NULL, sizeof (recv_fd)); + memset(&recv_fd, 0, sizeof (recv_fd)); if (ioctl(md->readfd, I_RECVFD, &recv_fd) == 0) { int fd = recv_fd.fd; diff --git a/usr/src/cmd/lp/cmd/lpsched/exec.c b/usr/src/cmd/lp/cmd/lpsched/exec.c index 521a55eaa1..dd9c939d78 100644 --- a/usr/src/cmd/lp/cmd/lpsched/exec.c +++ b/usr/src/cmd/lp/cmd/lpsched/exec.c @@ -111,7 +111,7 @@ void clean_string(char *ptr) wchar_t wc; size_t len; - for (cp = ptr; *cp != NULL; ) { + for (cp = ptr; *cp != '\0'; ) { if ((len = mbtowc(&wc, cp, MB_CUR_MAX)) == -1) { cp++; continue; @@ -735,7 +735,7 @@ exec(int type, ...) } else if (strcmp(clean_title, "") != 0) { char *ct_p; - for (ct_p = clean_title; *ct_p != NULL; ct_p++) { + for (ct_p = clean_title; *ct_p != '\0'; ct_p++) { if (*ct_p == '"') *ct_p = ' '; } diff --git a/usr/src/cmd/lp/cmd/lpsched/files.c b/usr/src/cmd/lp/cmd/lpsched/files.c index 00f2ac85be..a608e2ad82 100644 --- a/usr/src/cmd/lp/cmd/lpsched/files.c +++ b/usr/src/cmd/lp/cmd/lpsched/files.c @@ -27,8 +27,6 @@ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lpsched.h" #include <syslog.h> #include <strings.h> @@ -172,7 +170,7 @@ void rmfiles ( RSTATUS * rp, int log_it ) /* funcdef */ p = strdup(rp->req_file); /* remove host/id file */ if (q = strrchr(p, '-')) { - *q = NULL; + *q = '\0'; path = makepath(Lp_Tmp, p, NULL); (void) Unlink(path); Free(path); diff --git a/usr/src/cmd/lp/cmd/lpsched/fncs.c b/usr/src/cmd/lp/cmd/lpsched/fncs.c index 66f8311fa7..c73b159b96 100644 --- a/usr/src/cmd/lp/cmd/lpsched/fncs.c +++ b/usr/src/cmd/lp/cmd/lpsched/fncs.c @@ -898,7 +898,7 @@ void GetRequestFiles(REQUEST *req, char *buffer, int length) } else if (req->file_list) strlcpy(buf, *req->file_list, sizeof (buf)); - if (*buf == NULL || !strncmp(buf, SPOOLDIR, sizeof(SPOOLDIR)-1)) + if (*buf == '\0' || !strncmp(buf, SPOOLDIR, sizeof(SPOOLDIR)-1)) strcpy(buf, "<File name not available>"); if (strlen(buf) > (size_t) 24) { diff --git a/usr/src/cmd/lp/cmd/lpsched/lpfsck.c b/usr/src/cmd/lp/cmd/lpsched/lpfsck.c index 3175ae2d17..8b569227d3 100644 --- a/usr/src/cmd/lp/cmd/lpsched/lpfsck.c +++ b/usr/src/cmd/lp/cmd/lpsched/lpfsck.c @@ -27,8 +27,6 @@ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "stdarg.h" #include "stdlib.h" #include "fcntl.h" @@ -323,7 +321,7 @@ va_makepath (va_list *pap, char **ret) char buf[MAXPATHLEN]; int buflen; - memset(buf, NULL, sizeof (buf)); + memset(buf, 0, sizeof (buf)); while ((component = va_arg((*pap), char *)) != NULL) { if (strlcat(buf, component, sizeof (buf)) >= sizeof (buf) || strlcat(buf, "/", sizeof (buf)) >= sizeof (buf)) { diff --git a/usr/src/cmd/lp/filter/postscript/postprint/postprint.c b/usr/src/cmd/lp/filter/postscript/postprint/postprint.c index 49fe4bb3df..8306342860 100644 --- a/usr/src/cmd/lp/filter/postscript/postprint/postprint.c +++ b/usr/src/cmd/lp/filter/postscript/postprint/postprint.c @@ -27,8 +27,6 @@ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * * postprint - PostScript translator for ASCII files. @@ -107,6 +105,7 @@ #include <ctype.h> #include <fcntl.h> #include <unistd.h> +#include <string.h> #include "comments.h" /* PostScript file structuring comments */ #include "gen.h" /* general purpose definitions */ diff --git a/usr/src/cmd/lp/filter/postscript/postreverse/postreverse.c b/usr/src/cmd/lp/filter/postscript/postreverse/postreverse.c index 72de24d3cd..4b4ab335d8 100644 --- a/usr/src/cmd/lp/filter/postscript/postreverse/postreverse.c +++ b/usr/src/cmd/lp/filter/postscript/postreverse/postreverse.c @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <stdlib.h> #include <sys/types.h> @@ -254,7 +252,7 @@ ParsePageList(char *list) char *s1 = page, *s2; if (s2 = strchr(page, '-')) { - *s2++ = NULL; + *s2++ = '\0'; start = atoi(s1); end = atoi(s2); if (end < start) { diff --git a/usr/src/cmd/lp/lib/lp/files.c b/usr/src/cmd/lp/lib/lp/files.c index d85484f547..45b9f10869 100644 --- a/usr/src/cmd/lp/lib/lp/files.c +++ b/usr/src/cmd/lp/lib/lp/files.c @@ -28,7 +28,6 @@ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */ #include "stdio.h" @@ -96,7 +95,7 @@ fdgets(char *buf, int len, int fd) char tmp; int count = 0; - memset(buf, NULL, len); + memset(buf, 0, len); while ((count < len) && (Read(fd, &tmp, 1) > 0)) if ((buf[count++] = tmp) == '\n') break; diff --git a/usr/src/cmd/lp/lib/papi/job.c b/usr/src/cmd/lp/lib/papi/job.c index aafce80d0c..d4b0bc078f 100644 --- a/usr/src/cmd/lp/lib/papi/job.c +++ b/usr/src/cmd/lp/lib/papi/job.c @@ -971,7 +971,7 @@ papiJobQuery(papi_service_t handle, char *printer, int32_t job_id, return (PAPI_DEVICE_ERROR); } - if ((request_id == NULL) || (request_id[0] == NULL)) + if ((request_id == NULL) || (request_id[0] == '\0')) return (PAPI_NOT_FOUND); if ((*job = j = calloc(1, sizeof (*j))) == NULL) diff --git a/usr/src/cmd/lp/lib/papi/lpsched-jobs.c b/usr/src/cmd/lp/lib/papi/lpsched-jobs.c index 0713de64c2..3232b89667 100644 --- a/usr/src/cmd/lp/lib/papi/lpsched-jobs.c +++ b/usr/src/cmd/lp/lib/papi/lpsched-jobs.c @@ -103,7 +103,7 @@ job_attributes_to_lpsched_request(papi_service_t svc, REQUEST *r, papiAttributeListGetLPString(attributes, "form", &r->form); /* set the page range */ - memset(tmp, NULL, sizeof (tmp)); + memset(tmp, 0, sizeof (tmp)); tmp[0] = papiAttributeListFind(attributes, "page-ranges"); if (tmp[0] != NULL) { char buf[BUFSIZ]; @@ -369,11 +369,11 @@ lpsched_request_outcome_to_attributes(papi_attribute_t ***attributes, static void lpsched_user_to_job_attributes(papi_attribute_t ***list, char *user) { - if ((list != NULL) && (user != NULL) && (user[0] != NULL)) { + if ((list != NULL) && (user != NULL) && (user[0] != '\0')) { char *host = strrchr(user, '@'); if (host != NULL) { - *host = NULL; + *host = '\0'; papiAttributeListAddString(list, PAPI_ATTR_REPLACE, "job-originating-user-name", user); papiAttributeListAddString(list, PAPI_ATTR_REPLACE, diff --git a/usr/src/cmd/lp/lib/papi/lpsched-misc.c b/usr/src/cmd/lp/lib/papi/lpsched-misc.c index ce45d1aa5c..6675bdd213 100644 --- a/usr/src/cmd/lp/lib/papi/lpsched-misc.c +++ b/usr/src/cmd/lp/lib/papi/lpsched-misc.c @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /*LINTLIBRARY*/ #include <stdio.h> @@ -41,7 +39,7 @@ papiAttributeListAddLPString(papi_attribute_t ***list, int flags, char *name, papi_status_t result = PAPI_BAD_ARGUMENT; if ((list != NULL) && (name != NULL) && (value != NULL) && - (value[0] != NULL)) + (value[0] != '\0')) result = papiAttributeListAddString(list, flags, name, value); return (result); } @@ -119,7 +117,7 @@ printer_name_from_uri_id(char *uri, int32_t id) result = ""; } - if ((result[0] == NULL) && (id != -1)) { + if ((result[0] == '\0') && (id != -1)) { char path[32]; snprintf(path, sizeof (path), "%d-0", id); diff --git a/usr/src/cmd/lp/lib/papi/ppd.c b/usr/src/cmd/lp/lib/papi/ppd.c index 57d42c8841..26fcced189 100644 --- a/usr/src/cmd/lp/lib/papi/ppd.c +++ b/usr/src/cmd/lp/lib/papi/ppd.c @@ -54,7 +54,7 @@ process_line(char *line, char **key, char **value, char **comment) * or * *key value/comment: data */ - *ptr++ = NULL; + *ptr++ = '\0'; while (isspace(*ptr) != 0) ptr++; @@ -64,7 +64,7 @@ process_line(char *line, char **key, char **value, char **comment) * line is in the form: * *key value/comment: data */ - *ptr++ = NULL; + *ptr++ = '\0'; while (*ptr == ' ') ptr++; } @@ -75,7 +75,7 @@ process_line(char *line, char **key, char **value, char **comment) *value = ptr; if ((ptr = strchr(ptr, '/')) != NULL) { - *ptr++ = NULL; + *ptr++ = '\0'; *comment = ptr; } } @@ -107,7 +107,7 @@ PPDFileToAttributesList(papi_attribute_t ***attributes, char *filename) continue; if ((text = strrchr(line, '\n')) != NULL) - *text = NULL; + *text = '\0'; process_line(line, &key, &value, &text); diff --git a/usr/src/cmd/lp/model/netpr/netpr.c b/usr/src/cmd/lp/model/netpr/netpr.c index 9516781fad..243200a4cf 100644 --- a/usr/src/cmd/lp/model/netpr/netpr.c +++ b/usr/src/cmd/lp/model/netpr/netpr.c @@ -89,7 +89,7 @@ net_open(char *host, int timeout) return (-1); } - (void) memset((char *)&sin, NULL, sizeof (sin)); + (void) memset((char *)&sin, 0, sizeof (sin)); if ((hp = getipnodebyname(host, AF_INET6, AI_DEFAULT, &error_num)) == NULL) { syslog(LOG_DEBUG|LOG_ERR, "unknown host %s " diff --git a/usr/src/cmd/sgs/pvs/common/pvs.c b/usr/src/cmd/sgs/pvs/common/pvs.c index 4c353b887c..5a53021e09 100644 --- a/usr/src/cmd/sgs/pvs/common/pvs.c +++ b/usr/src/cmd/sgs/pvs/common/pvs.c @@ -22,6 +22,7 @@ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright 2019 Joyent, Inc. */ /* @@ -91,7 +92,7 @@ typedef struct gver_desc { /* Versym related data used by gvers_syms() */ typedef struct { - GElf_Versym *vsd_vsp; /* ptr to versym data */ + GElf_Versym *vsd_vsp; /* ptr to versym data */ Elf_Data *vsd_sym_data; /* ptr to symtab data */ Word vsd_symn; /* # of symbols in symtab */ const char *vsd_strs; /* string table data */ @@ -710,7 +711,7 @@ gvers_find(const char *name, unsigned long hash, APlist *lst) * * exit: * Return the corresponding GVer_desc struct. If the - * descriptor does not already exist, it is created. + * descriptor does not already exist, it is created. * On error, a fatal error is issued and the process exits. */ static GVer_desc * @@ -766,7 +767,7 @@ static void gvers_derefer(GVer_desc *vdp, int weak) { Aliste idx; - GVer_desc *_vdp; + GVer_desc *_vdp; /* * If the head of the list was a weak then we only clear out @@ -874,7 +875,7 @@ gvers_def(Cache *cache, Cache *def, const Gver_sym_data *vsdata, if (nflag) { for (APLIST_TRAVERSE(verdefs, idx1, vdp)) { Aliste idx2; - GVer_desc *_vdp; + GVer_desc *_vdp; int type = vdp->vd_flags & VER_FLG_WEAK; for (APLIST_TRAVERSE(vdp->vd_deps, idx2, _vdp)) @@ -895,7 +896,7 @@ gvers_def(Cache *cache, Cache *def, const Gver_sym_data *vsdata, */ for (APLIST_TRAVERSE(verdefs, idx1, vdp)) { Aliste idx2; - GVer_desc *_vdp; + GVer_desc *_vdp; int count; if (!match(NULL, vdp->vd_name, vdp->vd_ndx)) @@ -1006,13 +1007,13 @@ main(int argc, char **argv, char **envp) Elf *elf; Elf_Scn *scn; Elf_Data *data; - GElf_Ehdr ehdr; + GElf_Ehdr ehdr; int nfile, var; char *names; Cache *cache, *_cache; Cache *_cache_def, *_cache_need, *_cache_sym, *_cache_loc; int error = 0; - Gver_sym_data vsdata_s; + Gver_sym_data vsdata_s; const Gver_sym_data *vsdata = NULL; /* diff --git a/usr/src/cmd/sgs/rtld/common/analyze.c b/usr/src/cmd/sgs/rtld/common/analyze.c index 3cae1036ae..c9e66b1293 100644 --- a/usr/src/cmd/sgs/rtld/common/analyze.c +++ b/usr/src/cmd/sgs/rtld/common/analyze.c @@ -712,9 +712,9 @@ _is_so_matched(const char *name, const char *str, int path) * path names can be supplied as dependencies, e.g. dlopen("../libx.so.1"). * * - a PATHNAME() - this is the fully resolved path name of the object. This - * name will differ from NAME() for all dynamic executables, and may differ + * name will differ from NAME() for all dynamic executables, and may differ * from the NAME() of dependencies, if the dependency is not a full path - * name, or the dependency resolves to a symbolic link. + * name, or the dependency resolves to a symbolic link. * * - an ALIAS() name - these are alternative names by which the object has * been found, ie. when dependencies are loaded through a variety of @@ -1544,7 +1544,7 @@ find_file(Lm_list *lml, Rt_map *clmp, uint_t flags, Fdesc *fdp, Rej_desc *rej, * If we found a directory search for the file. */ if (dobj->co_id != 0) { - if (*strhash == NULL) + if (*strhash == 0) *strhash = (Word)elf_hash(oname); fobj = elf_config_ent(oname, *strhash, dobj->co_id, &aname); @@ -2432,7 +2432,7 @@ load_finish(Lm_list *lml, const char *name, Rt_map *clmp, int nmode, for (APLIST_TRAVERSE(lmalp, idx2, dlmp1)) { Aliste idx3; - Bnd_desc *bdp; + Bnd_desc *bdp; /* * Add any dependencies of this dependency to the @@ -2608,7 +2608,7 @@ load_one(Lm_list *lml, Aliste lmco, Alist *palp, Rt_map *clmp, int mode, { Rej_desc rej = { 0 }; Aliste idx; - Pdesc *pdp; + Pdesc *pdp; const char *name; for (ALIST_TRAVERSE(palp, idx, pdp)) { @@ -2779,7 +2779,7 @@ lookup_sym_interpose(Slookup *slp, Sresult *srp, uint_t *binfo, int *in_nfavl) } if ((lml->lm_flags & LML_FLG_INTRPOSE) == 0) - return (NULL); + return (0); /* * Traverse the list of known interposers to determine whether any @@ -3191,7 +3191,7 @@ _lookup_sym(Slookup *slp, Sresult *srp, uint_t *binfo, int *in_nfavl) lml = LIST(lmp); if ((sl.sl_flags & LKUP_WEAK) || (lml->lm_lazy == 0)) - return (NULL); + return (0); DBG_CALL(Dbg_syms_lazy_rescan(lml, name)); diff --git a/usr/src/cmd/sgs/rtld/common/cap.c b/usr/src/cmd/sgs/rtld/common/cap.c index 9aa82022be..47abbc78bc 100644 --- a/usr/src/cmd/sgs/rtld/common/cap.c +++ b/usr/src/cmd/sgs/rtld/common/cap.c @@ -362,7 +362,7 @@ cap_check(Cap *cptr, char *strs, int alt, Fdesc *fdp, Rej_desc *rej) return (1); } -#define HWAVL_RECORDED(n) pnavl_recorded(&capavl, n, NULL, NULL) +#define HWAVL_RECORDED(n) pnavl_recorded(&capavl, n, 0, NULL) /* * Determine whether a link-map should use alternative system capabilities. diff --git a/usr/src/cmd/sgs/rtld/common/config_elf.c b/usr/src/cmd/sgs/rtld/common/config_elf.c index b0b0977cab..e2de5eeff3 100644 --- a/usr/src/cmd/sgs/rtld/common/config_elf.c +++ b/usr/src/cmd/sgs/rtld/common/config_elf.c @@ -116,7 +116,7 @@ elf_config_validate(Addr addr, Rtc_head *head, Rt_map *lmp) * RTC_OBJ_NOEXIST directories. */ filetbl = (Rtc_file *)(dirtbl->cd_file + addr); - if (filetbl->cf_obj == NULL) + if (filetbl->cf_obj == 0) continue; /* @@ -332,7 +332,7 @@ elf_config(Rt_map *lmp, int aout) } #endif if (expand_paths(lmp, str, &elf_def_dirs, AL_CNT_SEARCH, - (LA_SER_DEFAULT | LA_SER_CONFIG), PD_TKN_CAP) != NULL) + (LA_SER_DEFAULT | LA_SER_CONFIG), PD_TKN_CAP) != 0) features |= CONF_EDLIBPATH; } if (head->ch_eslibpath) { @@ -350,20 +350,20 @@ elf_config(Rt_map *lmp, int aout) } #endif if (expand_paths(lmp, str, &elf_sec_dirs, AL_CNT_SEARCH, - (LA_SER_SECURE | LA_SER_CONFIG), PD_TKN_CAP) != NULL) + (LA_SER_SECURE | LA_SER_CONFIG), PD_TKN_CAP) != 0) features |= CONF_ESLIBPATH; } #if defined(__sparc) && !defined(_ELF64) if (head->ch_adlibpath) { str = (const char *)(head->ch_adlibpath + addr); if (expand_paths(lmp, str, &aout_def_dirs, AL_CNT_SEARCH, - (LA_SER_DEFAULT | LA_SER_CONFIG), PD_TKN_CAP) != NULL) + (LA_SER_DEFAULT | LA_SER_CONFIG), PD_TKN_CAP) != 0) features |= CONF_ADLIBPATH; } if (head->ch_aslibpath) { str = (const char *)(head->ch_aslibpath + addr); if (expand_paths(lmp, str, &aout_sec_dirs, AL_CNT_SEARCH, - (LA_SER_SECURE | LA_SER_CONFIG), PD_TKN_CAP) != NULL) + (LA_SER_SECURE | LA_SER_CONFIG), PD_TKN_CAP) != 0) features |= CONF_ASLIBPATH; } #endif diff --git a/usr/src/cmd/sgs/rtld/common/dlfcns.c b/usr/src/cmd/sgs/rtld/common/dlfcns.c index 74432c1686..1c980860d5 100644 --- a/usr/src/cmd/sgs/rtld/common/dlfcns.c +++ b/usr/src/cmd/sgs/rtld/common/dlfcns.c @@ -745,7 +745,7 @@ dlmopen_core(Lm_list *lml, Lm_list *olml, const char *path, int mode, * provides flexibility should we be able to support dlopening more * than one object in the future. */ - if (LM_FIX_NAME(clmp)(path, clmp, &palp, AL_CNT_NEEDED, orig) == NULL) + if (LM_FIX_NAME(clmp)(path, clmp, &palp, AL_CNT_NEEDED, orig) == 0) return (NULL); if ((palp->al_arritems > 1) && ((mode & RTLD_FIRST) == 0)) { @@ -758,7 +758,7 @@ dlmopen_core(Lm_list *lml, Lm_list *olml, const char *path, int mode, * Establish a link-map control list for this request, and load the * associated object. */ - if ((nlmco = create_cntl(lml, 1)) == NULL) { + if ((nlmco = create_cntl(lml, 1)) == 0) { remove_alist(&palp, 1); return (NULL); } @@ -866,7 +866,7 @@ dlmopen_intn(Lm_list *lml, const char *path, int mode, Rt_map *clmp, * * LM_ID_BASE: Operate on the PRIMARY (executables) link map * LM_ID_LDSO: Operation on ld.so.1's link map - * LM_ID_NEWLM: Create a new link-map. + * LM_ID_NEWLM: Create a new link-map. */ if (lml == (Lm_list *)LM_ID_NEWLM) { if ((lml = calloc(sizeof (Lm_list), 1)) == NULL) @@ -2268,7 +2268,7 @@ dlinfo(void *handle, int request, void *p) * incrementing a pointer. Hence, alist additions that occur * in mid-traverse will not cause confusion. * - * There is one limitation: We cannot continue operation if an object + * There is one limitation: We cannot continue operation if an object * is removed from the process from within a callback. We detect when * this happens and return immediately with a -1 return value. * diff --git a/usr/src/cmd/sgs/rtld/common/elf.c b/usr/src/cmd/sgs/rtld/common/elf.c index a3600fddbe..ff89028c38 100644 --- a/usr/src/cmd/sgs/rtld/common/elf.c +++ b/usr/src/cmd/sgs/rtld/common/elf.c @@ -315,12 +315,12 @@ elf_verify(caddr_t addr, size_t size, Fdesc *fdp, const char *name, * * - elf_needed() is called to establish any ld.so.1 dependencies. These * dependencies should all be lazy loaded, so this routine is typically a - * no-op. However, we call elf_needed() for completeness, in case any + * no-op. However, we call elf_needed() for completeness, in case any * NEEDED initialization is required. * * - For intel, ld.so.1's JMPSLOT relocations need relative updates. These * are by default skipped thus delaying all relative relocation processing - * on every invocation of ld.so.1. + * on every invocation of ld.so.1. */ int elf_rtld_load() @@ -344,7 +344,7 @@ elf_rtld_load() * * - ld.so.1 does not exercise *any* PLT's before it has made a call * to elf_lazy_load(). This is because all dynamic dependencies - * are recorded as lazy dependencies. + * are recorded as lazy dependencies. */ (void) elf_reloc_relative_count((ulong_t)JMPREL(lmp), (ulong_t)(PLTRELSZ(lmp) / RELENT(lmp)), (ulong_t)RELENT(lmp), @@ -422,7 +422,7 @@ elf_lazy_load(Rt_map *clmp, Slookup *slp, uint_t ndx, const char *sym, /* * Establish a link-map control list for this request. */ - if ((lmco = create_cntl(lml, 0)) == NULL) { + if ((lmco = create_cntl(lml, 0)) == 0) { remove_alist(&palp, 1); return (NULL); } @@ -838,7 +838,7 @@ _elf_lookup_filtee(Slookup *slp, Sresult *srp, uint_t *binfo, uint_t ndx, (LML_FLG_TRC_UNREF | LML_FLG_TRC_UNUSED)); if (tracing || DBG_ENABLED) { - Bnd_desc *bdp; + Bnd_desc *bdp; Aliste idx; FLAGS1(ilmp) |= FL1_RT_USED; @@ -924,8 +924,8 @@ _elf_lookup_filtee(Slookup *slp, Sresult *srp, uint_t *binfo, uint_t ndx, /* * Establish a link-map control list for this request. */ - if ((lmco = create_cntl(lml, 0)) == NULL) - return (NULL); + if ((lmco = create_cntl(lml, 0)) == 0) + return (0); /* * Determine the capability filtees. If none can be @@ -1016,7 +1016,7 @@ _elf_lookup_filtee(Slookup *slp, Sresult *srp, uint_t *binfo, uint_t ndx, * - ld.so.1 is available to relocate * against. * - There's no need to add an dependencies - * to this handle. + * to this handle. */ rdflags = (GPD_DLSYM | GPD_RELOC); @@ -1070,8 +1070,8 @@ _elf_lookup_filtee(Slookup *slp, Sresult *srp, uint_t *binfo, uint_t ndx, * Establish a link-map control list for this * request. */ - if ((lmco = create_cntl(lml, 0)) == NULL) - return (NULL); + if ((lmco = create_cntl(lml, 0)) == 0) + return (0); /* * Locate and load the filtee. @@ -1874,13 +1874,13 @@ elf_new_lmp(Lm_list *lml, Aliste lmco, Fdesc *fdp, Addr addr, size_t msize, JMPREL(lmp) = (void *)(dyn->d_un.d_ptr + base); break; case DT_INIT: - if (dyn->d_un.d_ptr != NULL) + if (dyn->d_un.d_ptr != 0) INIT(lmp) = (void (*)())(dyn->d_un.d_ptr + base); break; case DT_FINI: - if (dyn->d_un.d_ptr != NULL) + if (dyn->d_un.d_ptr != 0) FINI(lmp) = (void (*)())(dyn->d_un.d_ptr + base); @@ -2510,7 +2510,7 @@ elf_dladdr(ulong_t addr, Rt_map *lmp, Dl_info *dlip, void **info, int flags) * symbol lookup hash table. */ str = STRTAB(lmp); - if (SUNWSYMSZ(lmp) == NULL) { + if (SUNWSYMSZ(lmp) == 0) { sym = SYMTAB(lmp); /* * If we don't have a .hash table there are no symbols @@ -2720,7 +2720,7 @@ elf_lazy_find_sym(Slookup *slp, Sresult *srp, uint_t *binfo, int *in_nfavl) * as each object supplies its own lazy dependencies. */ if (aplist_append(&alist, lmp, AL_CNT_LAZYFIND) == NULL) - return (NULL); + return (0); for (APLIST_TRAVERSE(alist, idx1, lmp1)) { uint_t dynndx; @@ -2777,8 +2777,8 @@ elf_lazy_find_sym(Slookup *slp, Sresult *srp, uint_t *binfo, int *in_nfavl) * A successful lazy load can mean one of two things: * * - new objects have been loaded, in which case the - * objects will have been analyzed, relocated, and - * finally moved to the callers control list. + * objects will have been analyzed, relocated, and + * finally moved to the callers control list. * - the objects are already loaded, and this lazy * load has simply associated the referenced object * with it's lazy dependencies. @@ -2860,7 +2860,7 @@ elf_lazy_find_sym(Slookup *slp, Sresult *srp, uint_t *binfo, int *in_nfavl) if (slp->sl_flags & LKUP_NODESCENT) continue; - if (aplist_test(&alist, nlmp, AL_CNT_LAZYFIND) == NULL) + if (aplist_test(&alist, nlmp, AL_CNT_LAZYFIND) == 0) return (0); } } diff --git a/usr/src/cmd/sgs/rtld/common/external.c b/usr/src/cmd/sgs/rtld/common/external.c index 2476a6dbbc..caade06cf1 100644 --- a/usr/src/cmd/sgs/rtld/common/external.c +++ b/usr/src/cmd/sgs/rtld/common/external.c @@ -368,9 +368,9 @@ get_lcinterface(Rt_map *lmp, Lc_interface *funcs) * If a version of libc gives us only a subset of the TLS * interfaces, it's confused and we discard the whole lot. */ - if ((lcp[CI_TLS_MODADD].lc_un.lc_func && - lcp[CI_TLS_MODREM].lc_un.lc_func && - lcp[CI_TLS_STATMOD].lc_un.lc_func) == NULL) { + if (((lcp[CI_TLS_MODADD].lc_un.lc_func != NULL) && + (lcp[CI_TLS_MODREM].lc_un.lc_func != NULL) && + (lcp[CI_TLS_STATMOD].lc_un.lc_func != NULL)) == 0) { lcp[CI_TLS_MODADD].lc_un.lc_func = NULL; lcp[CI_TLS_MODREM].lc_un.lc_func = NULL; lcp[CI_TLS_STATMOD].lc_un.lc_func = NULL; diff --git a/usr/src/cmd/sgs/rtld/common/object.c b/usr/src/cmd/sgs/rtld/common/object.c index 0b00292e83..31cc6b4c64 100644 --- a/usr/src/cmd/sgs/rtld/common/object.c +++ b/usr/src/cmd/sgs/rtld/common/object.c @@ -261,7 +261,7 @@ elf_obj_fini(Lm_list *lml, Rt_map *lmp, Rt_map *clmp, int *in_nfavl) * capabilities have been established, ensure that they are appropriate * for this system. */ - if (pnavl_recorded(&capavl, ofl->ofl_name, NULL, NULL)) + if (pnavl_recorded(&capavl, ofl->ofl_name, 0, NULL)) scapset = alt_scapset; else scapset = org_scapset; diff --git a/usr/src/cmd/sgs/rtld/common/util.c b/usr/src/cmd/sgs/rtld/common/util.c index f10f7a4aed..ebdd9e1943 100644 --- a/usr/src/cmd/sgs/rtld/common/util.c +++ b/usr/src/cmd/sgs/rtld/common/util.c @@ -1324,7 +1324,7 @@ create_cntl(Lm_list *lml, int dlopen) if ((lmc = alist_append(&lml->lm_lists, NULL, sizeof (Lm_cntl), AL_CNT_LMLISTS)) == NULL) - return (NULL); + return (0); return ((Aliste)((char *)lmc - (char *)lml->lm_lists)); } @@ -2006,7 +2006,7 @@ ld_generic_env(const char *s1, size_t len, const char *s2, Word *lmflags, } else if (select & SEL_ACT_SPEC_2) { /* * variables can be: ENV_FLG_ - * AUDIT_ARGS, BINDING, CONFGEN, LOADFLTR, PROFILE, + * AUDIT_ARGS, BINDING, CONFGEN, LOADFLTR, PROFILE, * SIGNAL, TRACE_OBJS */ switch (variable) { @@ -2863,7 +2863,7 @@ int printf(const char *format, ...) { va_list args; - char buffer[ERRSIZE]; + char buffer[ERRSIZE]; Prfbuf prf; va_start(args, format); diff --git a/usr/src/cmd/sgs/rtld/mdbmod/common/rtld.c b/usr/src/cmd/sgs/rtld/mdbmod/common/rtld.c index 679dabb628..9cd990cf23 100644 --- a/usr/src/cmd/sgs/rtld/mdbmod/common/rtld.c +++ b/usr/src/cmd/sgs/rtld/mdbmod/common/rtld.c @@ -502,7 +502,7 @@ rtmap_format(uintptr_t addr, const void *data, void *private) if (wdp && (wdp->w_flags & RTLD_FLG_VERBOSE)) { mdb_printf(MSG_ORIG(MSG_STR_DASHES)); (void) mdb_call_dcmd( - MSG_ORIG(MSG_RTMAP_STR), addr, DCMD_ADDRSPEC, NULL, NULL); + MSG_ORIG(MSG_RTMAP_STR), addr, DCMD_ADDRSPEC, 0, NULL); return (0); } @@ -679,7 +679,7 @@ dcmd_Setenv(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) static int walk_rtmap_init(mdb_walk_state_t *wsp) { - if (wsp->walk_addr == NULL) { + if (wsp->walk_addr == 0) { mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_RTMAP_STR)); return (WALK_ERR); } @@ -692,7 +692,7 @@ walk_rtmap_step(mdb_walk_state_t *wsp) int status; Rt_map lmp; - if (wsp->walk_addr == NULL) + if (wsp->walk_addr == 0) return (WALK_DONE); if (mdb_vread(&lmp, sizeof (Rt_map), wsp->walk_addr) == -1) { mdb_warn(MSG_ORIG(MSG_ERR_READ), diff --git a/usr/src/cmd/svc/startd/graph.c b/usr/src/cmd/svc/startd/graph.c index 0361d5ae4f..452d91250e 100644 --- a/usr/src/cmd/svc/startd/graph.c +++ b/usr/src/cmd/svc/startd/graph.c @@ -3563,7 +3563,7 @@ do_uadmin(void) char *fbarg = NULL; #endif /* __x86 */ - mdep = NULL; + mdep = 0; fd = creat(resetting, 0777); if (fd >= 0) startd_close(fd); diff --git a/usr/src/cmd/svc/startd/method.c b/usr/src/cmd/svc/startd/method.c index 915ad42da6..2629b74210 100644 --- a/usr/src/cmd/svc/startd/method.c +++ b/usr/src/cmd/svc/startd/method.c @@ -963,7 +963,7 @@ method_run(restarter_inst_t **instp, int type, int *exit_code) MUTEX_UNLOCK(&inst->ri_lock); do { - r = waitpid(pid, &ret_status, NULL); + r = waitpid(pid, &ret_status, 0); } while (r == -1 && errno == EINTR); if (r == -1) err = errno; diff --git a/usr/src/cmd/svc/startd/protocol.c b/usr/src/cmd/svc/startd/protocol.c index 009fe8c195..e4fc9f73c5 100644 --- a/usr/src/cmd/svc/startd/protocol.c +++ b/usr/src/cmd/svc/startd/protocol.c @@ -89,7 +89,7 @@ graph_protocol_init() (void) pthread_mutex_init(&graph_queue->gpeq_lock, &mutex_attrs); graph_queue->gpeq_event_list = startd_list_create( - graph_protocol_event_queue_pool, graph_queue, NULL); + graph_protocol_event_queue_pool, graph_queue, 0); } /* @@ -204,7 +204,7 @@ restarter_protocol_init() (void) pthread_mutex_init(&restarter_queue->rpeq_lock, &mutex_attrs); restarter_queue->rpeq_event_list = startd_list_create( - restarter_protocol_event_queue_pool, restarter_queue, NULL); + restarter_protocol_event_queue_pool, restarter_queue, 0); log_framework(LOG_DEBUG, "Initialized restarter protocol\n"); } @@ -382,11 +382,11 @@ restarter_protocol_init_delegate(char *fmri) /* * The following errors can be returned in this * case : - * EINVAL : inappropriate flags or dump flag - * and the dump failed. - * EEXIST : svc.startd already has a channel - * named as the master channel name - * ENOMEM : too many subscribers to the channel + * EINVAL : inappropriate flags or dump flag + * and the dump failed. + * EEXIST : svc.startd already has a channel + * named as the master channel name + * ENOMEM : too many subscribers to the channel */ uu_warn("Failed to subscribe to restarter %s, channel %s with " "subscriber id %s : \n", fmri, master_channel_name, sid); diff --git a/usr/src/cmd/svc/startd/restarter.c b/usr/src/cmd/svc/startd/restarter.c index a98c863fb5..7ed65aab6a 100644 --- a/usr/src/cmd/svc/startd/restarter.c +++ b/usr/src/cmd/svc/startd/restarter.c @@ -1738,7 +1738,7 @@ rep_retry: info->sf_id = rip->ri_id; info->sf_method_type = METHOD_REFRESH; info->sf_event_type = RERR_REFRESH; - info->sf_reason = NULL; + info->sf_reason = 0; assert(rip->ri_method_thread == 0); rip->ri_method_thread = diff --git a/usr/src/cmd/svc/startd/startd.c b/usr/src/cmd/svc/startd/startd.c index c5307879e2..d28687e761 100644 --- a/usr/src/cmd/svc/startd/startd.c +++ b/usr/src/cmd/svc/startd/startd.c @@ -597,7 +597,7 @@ timestamp: /* Read reconfigure property for recovery. */ if (scf_handle_decode_fmri(hndl, startd_reconfigure_fmri, NULL, NULL, - NULL, NULL, prop, NULL) != -1 && + NULL, NULL, prop, 0) != -1 && scf_property_get_value(prop, val) == 0) (void) scf_value_get_boolean(val, &prop_reconfig); diff --git a/usr/src/lib/brand/shared/brand/common/brand_util.c b/usr/src/lib/brand/shared/brand/common/brand_util.c index 051cbccb21..75db8568ae 100644 --- a/usr/src/lib/brand/shared/brand/common/brand_util.c +++ b/usr/src/lib/brand/shared/brand/common/brand_util.c @@ -366,7 +366,7 @@ brand_post_init(int version, int argc, char *argv[], char *envp[]) * Find the aux vector on the stack. */ p = (uintptr_t *)envp; - while (*p != NULL) + while (*p != 0) p++; /* @@ -401,9 +401,9 @@ brand_post_init(int version, int argc, char *argv[], char *envp[]) switch (ap->a_type) { case AT_BASE: /* Hide AT_BASE if static binary */ - if (sed.sed_base == NULL) { + if (sed.sed_base == 0) { ap->a_type = AT_IGNORE; - ap->a_un.a_val = NULL; + ap->a_un.a_val = 0; } else { ap->a_un.a_val = sed.sed_base; } @@ -432,13 +432,13 @@ brand_post_init(int version, int argc, char *argv[], char *envp[]) * for the binary. */ ap->a_type = AT_IGNORE; - ap->a_un.a_val = NULL; + ap->a_un.a_val = 0; break; case AT_SUN_LDDATA: /* Hide AT_SUN_LDDATA if static binary */ - if (sed.sed_lddata == NULL) { + if (sed.sed_lddata == 0) { ap->a_type = AT_IGNORE; - ap->a_un.a_val = NULL; + ap->a_un.a_val = 0; } else { ap->a_un.a_val = sed.sed_lddata; } diff --git a/usr/src/lib/libc_db/common/thread_db.c b/usr/src/lib/libc_db/common/thread_db.c index b58971dfec..a592ba0125 100644 --- a/usr/src/lib/libc_db/common/thread_db.c +++ b/usr/src/lib/libc_db/common/thread_db.c @@ -218,7 +218,7 @@ td_read_uberdata(td_thragent_t *ta_p) if (ta_p->hash_size != 1) { /* multi-threaded */ ta_p->initialized = 2; ta_p->single_lwpid = 0; - ta_p->single_ulwp_addr = NULL; + ta_p->single_ulwp_addr = 0; } else { /* single-threaded */ ta_p->initialized = 1; /* @@ -232,7 +232,7 @@ td_read_uberdata(td_thragent_t *ta_p) if (ps_pdread(ph_p, ta_p->hash_table_addr, &head, sizeof (head)) != PS_OK) return (TD_DBERR); - if ((psaddr_t)head.hash_bucket == NULL) + if ((psaddr_t)head.hash_bucket == 0) ta_p->initialized = 0; else if (ps_pdread(ph_p, (psaddr_t)head.hash_bucket + offsetof(ulwp_t, ul_lwpid), @@ -248,7 +248,7 @@ td_read_uberdata(td_thragent_t *ta_p) if (ps_pdread(ph_p, ta_p->hash_table_addr, &head, sizeof (head)) != PS_OK) return (TD_DBERR); - if ((psaddr_t)head.hash_bucket == NULL) + if ((psaddr_t)head.hash_bucket == 0) ta_p->initialized = 0; else if (ps_pdread(ph_p, (psaddr_t)head.hash_bucket + offsetof(ulwp32_t, ul_lwpid), @@ -319,14 +319,14 @@ td_read_bootstrap_data(td_thragent_t *ta_p) if (ps_pdread(ph_p, bootstrap_addr, &psaddr, sizeof (psaddr)) != PS_OK) return (TD_DBERR); - if ((ta_p->bootstrap_addr = psaddr) == NULL) + if ((ta_p->bootstrap_addr = psaddr) == 0) psaddr = uberdata_addr; else if (ps_pdread(ph_p, psaddr, &psaddr, sizeof (psaddr)) != PS_OK) return (TD_DBERR); - if (psaddr == NULL) { + if (psaddr == 0) { /* primary linkmap in the tgt is not initialized */ - ta_p->bootstrap_addr = NULL; + ta_p->bootstrap_addr = 0; psaddr = uberdata_addr; } ta_p->uberdata_addr = psaddr; @@ -336,14 +336,14 @@ td_read_bootstrap_data(td_thragent_t *ta_p) if (ps_pdread(ph_p, bootstrap_addr, &psaddr, sizeof (psaddr)) != PS_OK) return (TD_DBERR); - if ((ta_p->bootstrap_addr = (psaddr_t)psaddr) == NULL) + if ((ta_p->bootstrap_addr = (psaddr_t)psaddr) == 0) psaddr = (caddr32_t)uberdata_addr; else if (ps_pdread(ph_p, (psaddr_t)psaddr, &psaddr, sizeof (psaddr)) != PS_OK) return (TD_DBERR); - if (psaddr == NULL) { + if (psaddr == 0) { /* primary linkmap in the tgt is not initialized */ - ta_p->bootstrap_addr = NULL; + ta_p->bootstrap_addr = 0; psaddr = (caddr32_t)uberdata_addr; } ta_p->uberdata_addr = (psaddr_t)psaddr; @@ -354,7 +354,7 @@ td_read_bootstrap_data(td_thragent_t *ta_p) if ((return_val = td_read_uberdata(ta_p)) != TD_OK) return (return_val); - if (ta_p->bootstrap_addr == NULL) + if (ta_p->bootstrap_addr == 0) ta_p->initialized = 0; return (TD_OK); } @@ -483,7 +483,7 @@ ph_lock_ta(td_thragent_t *ta_p, td_err_e *err) static struct ps_prochandle * ph_lock_th(const td_thrhandle_t *th_p, td_err_e *err) { - if (th_p == NULL || th_p->th_unique == NULL) { + if (th_p == NULL || th_p->th_unique == 0) { *err = TD_BADTH; return (NULL); } @@ -498,7 +498,7 @@ ph_lock_th(const td_thrhandle_t *th_p, td_err_e *err) static struct ps_prochandle * ph_lock_sh(const td_synchandle_t *sh_p, td_err_e *err) { - if (sh_p == NULL || sh_p->sh_unique == NULL) { + if (sh_p == NULL || sh_p->sh_unique == 0) { *err = TD_BADSH; return (NULL); } @@ -674,7 +674,7 @@ td_mapper_id2thr(td_thrhandle_t *th_p, td_mapper_param_t *data) #pragma weak td_ta_map_id2thr = __td_ta_map_id2thr td_err_e __td_ta_map_id2thr(td_thragent_t *ta_p, thread_t tid, - td_thrhandle_t *th_p) + td_thrhandle_t *th_p) { td_err_e return_val; td_mapper_param_t data; @@ -733,7 +733,7 @@ __td_ta_map_addr2sync(td_thragent_t *ta_p, psaddr_t addr, td_synchandle_t *sh_p) if (sh_p == NULL) return (TD_BADSH); - if (addr == NULL) + if (addr == 0) return (TD_ERR); if ((ph_p = ph_lock_ta(ta_p, &return_val)) == NULL) return (return_val); @@ -913,8 +913,8 @@ sigequalset(const sigset_t *s1, const sigset_t *s2) #pragma weak td_ta_thr_iter = __td_ta_thr_iter td_err_e __td_ta_thr_iter(td_thragent_t *ta_p, td_thr_iter_f *cb, - void *cbdata_p, td_thr_state_e state, int ti_pri, - sigset_t *ti_sigmask_p, unsigned ti_user_flags) + void *cbdata_p, td_thr_state_e state, int ti_pri, + sigset_t *ti_sigmask_p, unsigned ti_user_flags) { struct ps_prochandle *ph_p; psaddr_t first_lwp_addr; @@ -982,7 +982,7 @@ __td_ta_thr_iter(td_thragent_t *ta_p, td_thr_iter_f *cb, * exited. Return TD_NOTHR and all will be well. */ if (db_return == PS_OK && - first_lwp_addr == NULL && first_zombie_addr == NULL) { + first_lwp_addr == 0 && first_zombie_addr == 0) { (void) ps_pcontinue(ph_p); ph_unlock(ta_p); return (TD_NOTHR); @@ -996,7 +996,7 @@ __td_ta_thr_iter(td_thragent_t *ta_p, td_thr_iter_f *cb, /* * Run down the lists of all living and dead lwps. */ - if (first_lwp_addr == NULL) + if (first_lwp_addr == 0) first_lwp_addr = first_zombie_addr; curr_lwp_addr = first_lwp_addr; for (;;) { @@ -1096,7 +1096,7 @@ advance: * or we have already been doing the zombie list, * in which case terminate the loop. */ - if (first_zombie_addr == NULL || + if (first_zombie_addr == 0 || first_lwp_addr == first_zombie_addr) break; curr_lwp_addr = first_lwp_addr = first_zombie_addr; @@ -1220,7 +1220,7 @@ __td_ta_sync_iter(td_thragent_t *ta_p, td_sync_iter_f *cb, void *cbdata) #endif /* _SYSCALL32 */ } - if (psaddr == NULL) + if (psaddr == 0) goto out; if (ps_pdread(ph_p, psaddr, sync_addr_hash, TDB_HASH_SIZE * sizeof (uint64_t)) != PS_OK) { @@ -1233,7 +1233,7 @@ __td_ta_sync_iter(td_thragent_t *ta_p, td_sync_iter_f *cb, void *cbdata) */ for (i = 0; i < TDB_HASH_SIZE; i++) { for (next_desc = (psaddr_t)sync_addr_hash[i]; - next_desc != NULL; + next_desc != 0; next_desc = (psaddr_t)sync_stats.next) { if (ps_pdread(ph_p, next_desc, &sync_stats, sizeof (sync_stats)) != PS_OK) { @@ -1299,7 +1299,7 @@ __td_ta_get_stats(const td_thragent_t *ta_p, td_ta_stats_t *tstats) */ static void td_thr2to(td_thragent_t *ta_p, psaddr_t ts_addr, - ulwp_t *ulwp, td_thrinfo_t *ti_p) + ulwp_t *ulwp, td_thrinfo_t *ti_p) { lwpid_t lwpid; @@ -1343,7 +1343,7 @@ td_thr2to(td_thragent_t *ta_p, psaddr_t ts_addr, #if defined(_LP64) && defined(_SYSCALL32) static void td_thr2to32(td_thragent_t *ta_p, psaddr_t ts_addr, - ulwp32_t *ulwp, td_thrinfo_t *ti_p) + ulwp32_t *ulwp, td_thrinfo_t *ti_p) { lwpid_t lwpid; @@ -1399,7 +1399,7 @@ __td_thr_get_info(td_thrhandle_t *th_p, td_thrinfo_t *ti_p) if (ti_p == NULL) return (TD_ERR); - (void) memset(ti_p, NULL, sizeof (*ti_p)); + (void) memset(ti_p, 0, sizeof (*ti_p)); if ((ph_p = ph_lock_th(th_p, &return_val)) == NULL) return (return_val); @@ -1709,7 +1709,7 @@ __td_thr_event_getmsg(td_thrhandle_t *th_p, td_event_msg_t *msg) msg->msg.data = (uintptr_t)evbuf.eventdata; /* "Consume" the message */ evbuf.eventnum = TD_EVENT_NONE; - evbuf.eventdata = NULL; + evbuf.eventdata = 0; if (ps_pdwrite(ph_p, psaddr, &evbuf, sizeof (evbuf)) != PS_OK) return_val = TD_DBERR; @@ -1875,7 +1875,7 @@ __td_thr_sigsetmask(const td_thrhandle_t *th_p, const sigset_t ti_sigmask) /* ARGSUSED */ td_err_e __td_thr_setsigpending(const td_thrhandle_t *th_p, - uchar_t ti_pending_flag, const sigset_t ti_pending) + uchar_t ti_pending_flag, const sigset_t ti_pending) { return (TD_NOCAPAB); } @@ -2110,7 +2110,7 @@ __td_thr_validate(const td_thrhandle_t *th_p) if (th_p == NULL) return (TD_BADTH); - if (th_p->th_unique == NULL || th_p->th_ta_p == NULL) + if (th_p->th_unique == 0 || th_p->th_ta_p == NULL) return (TD_BADTH); /* @@ -2171,12 +2171,12 @@ __td_thr_tsd(td_thrhandle_t *th_p, thread_key_t key, void **data_pp) else if (ps_pdread(ph_p, (psaddr_t)&ulwp->ul_stsd, &tsd_paddr, sizeof (tsd_paddr)) != PS_OK) return_val = TD_DBERR; - else if (tsd_paddr != NULL && + else if (tsd_paddr != 0 && ps_pdread(ph_p, tsd_paddr, &stsd, sizeof (stsd)) != PS_OK) return_val = TD_DBERR; else { maxkey = tsdm.tsdm_nused; - nkey = tsd_paddr == NULL ? TSD_NFAST : stsd.tsd_nalloc; + nkey = tsd_paddr == 0 ? TSD_NFAST : stsd.tsd_nalloc; if (key < TSD_NFAST) tsd_paddr = (psaddr_t)&ulwp->ul_ftsd[0]; @@ -2195,12 +2195,12 @@ __td_thr_tsd(td_thrhandle_t *th_p, thread_key_t key, void **data_pp) else if (ps_pdread(ph_p, (psaddr_t)&ulwp->ul_stsd, &addr, sizeof (addr)) != PS_OK) return_val = TD_DBERR; - else if (addr != NULL && + else if (addr != 0 && ps_pdread(ph_p, addr, &stsd, sizeof (stsd)) != PS_OK) return_val = TD_DBERR; else { maxkey = tsdm.tsdm_nused; - nkey = addr == NULL ? TSD_NFAST : stsd.tsd_nalloc; + nkey = addr == 0 ? TSD_NFAST : stsd.tsd_nalloc; if (key < TSD_NFAST) { tsd_paddr = (psaddr_t)&ulwp->ul_ftsd[0]; @@ -2264,7 +2264,7 @@ __td_thr_tlsbase(td_thrhandle_t *th_p, ulong_t moduleid, psaddr_t *base) if (base == NULL) return (TD_ERR); - *base = NULL; + *base = 0; if ((ph_p = ph_lock_th(th_p, &return_val)) == NULL) return (return_val); ta_p = th_p->th_ta_p; @@ -2408,7 +2408,7 @@ lowner_cb(const td_synchandle_t *sh_p, void *arg) #pragma weak td_thr_lockowner = __td_thr_lockowner td_err_e __td_thr_lockowner(const td_thrhandle_t *th_p, td_sync_iter_f *cb, - void *cb_data) + void *cb_data) { td_thragent_t *ta_p; td_err_e return_val; @@ -2468,9 +2468,9 @@ __td_thr_sleepinfo(const td_thrhandle_t *th_p, td_synchandle_t *sh_p) #endif /* _SYSCALL32 */ } - if (return_val != TD_OK || wchan == NULL) { + if (return_val != TD_OK || wchan == 0) { sh_p->sh_ta_p = NULL; - sh_p->sh_unique = NULL; + sh_p->sh_unique = 0; if (return_val == TD_OK) return_val = TD_ERR; } else { @@ -2488,7 +2488,7 @@ __td_thr_sleepinfo(const td_thrhandle_t *th_p, td_synchandle_t *sh_p) #pragma weak td_ta_map_lwp2thr = __td_ta_map_lwp2thr td_err_e __td_ta_map_lwp2thr(td_thragent_t *ta_p, lwpid_t lwpid, - td_thrhandle_t *th_p) + td_thrhandle_t *th_p) { return (__td_ta_map_id2thr(ta_p, lwpid, th_p)); } @@ -2498,7 +2498,7 @@ __td_ta_map_lwp2thr(td_thragent_t *ta_p, lwpid_t lwpid, */ static td_err_e sync_get_info_common(const td_synchandle_t *sh_p, struct ps_prochandle *ph_p, - td_syncinfo_t *si_p) + td_syncinfo_t *si_p) { int trunc = 0; td_so_un_t generic_so; @@ -2651,7 +2651,7 @@ tdb_addr_hash32(uint64_t addr) static td_err_e read_sync_stats(td_thragent_t *ta_p, psaddr_t hash_table, - psaddr_t sync_obj_addr, tdb_sync_stats_t *sync_stats) + psaddr_t sync_obj_addr, tdb_sync_stats_t *sync_stats) { psaddr_t next_desc; uint64_t first; @@ -2675,7 +2675,7 @@ read_sync_stats(td_thragent_t *ta_p, psaddr_t hash_table, /* * Search the linked list for an entry for the synch object.. */ - for (next_desc = (psaddr_t)first; next_desc != NULL; + for (next_desc = (psaddr_t)first; next_desc != 0; next_desc = (psaddr_t)sync_stats->next) { if (ps_pdread(ta_p->ph_p, next_desc, sync_stats, sizeof (*sync_stats)) != PS_OK) diff --git a/usr/src/lib/libcustr/common/custr.c b/usr/src/lib/libcustr/common/custr.c index 6d3a003e6b..8c8288ab7d 100644 --- a/usr/src/lib/libcustr/common/custr.c +++ b/usr/src/lib/libcustr/common/custr.c @@ -113,8 +113,9 @@ custr_append_vprintf(custr_t *cus, const char *fmt, va_list ap) int len = vsnprintf(NULL, 0, fmt, ap); size_t chunksz = STRING_CHUNK_SIZE; - if (len == -1) + if (len < 0) { return (len); + } while (chunksz < len) { chunksz *= 2; @@ -155,10 +156,10 @@ custr_append_vprintf(custr_t *cus, const char *fmt, va_list ap) /* * Append new string to existing string: */ - len = vsnprintf(cus->cus_data + cus->cus_strlen, - (uintptr_t)cus->cus_data - (uintptr_t)cus->cus_strlen, fmt, ap); - if (len == -1) + if ((len = vsnprintf(cus->cus_data + cus->cus_strlen, + cus->cus_datalen - cus->cus_strlen, fmt, ap)) < 0) { return (len); + } cus->cus_strlen += len; return (0); diff --git a/usr/src/lib/libdemangle/common/rust.c b/usr/src/lib/libdemangle/common/rust.c index def4056d74..f99fe79a10 100644 --- a/usr/src/lib/libdemangle/common/rust.c +++ b/usr/src/lib/libdemangle/common/rust.c @@ -10,7 +10,7 @@ */ /* - * Copyright 2019 Joyent, Inc. + * Copyright 2019, Joyent, Inc. */ #include <errno.h> @@ -239,7 +239,7 @@ rustdem_parse_name_segment(rustdem_state_t *st, strview_t *svp, boolean_t first) rem = sv_remaining(&sv); - if (rem < len || len >= SIZE_MAX) { + if (rem < len || len > SIZE_MAX) { st->rds_error = EINVAL; return (B_FALSE); } diff --git a/usr/src/lib/libgen/common/reg_compile.c b/usr/src/lib/libgen/common/reg_compile.c index 4c33f51322..2aea5a47d6 100644 --- a/usr/src/lib/libgen/common/reg_compile.c +++ b/usr/src/lib/libgen/common/reg_compile.c @@ -25,7 +25,7 @@ */ /* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ #include <sys/types.h> #include <ctype.h> @@ -143,11 +143,11 @@ _compile(const char *sp, char *ep, char *endbuf, int viflag) { wchar_t c; int n; - wchar_t d; - const char *oldsp; - char *lastep; - int cclcnt; - char bracket[NBRA], *bracketp; + wchar_t d; + const char *oldsp; + char *lastep; + int cclcnt; + char bracket[NBRA], *bracketp; int closed; int neg; int alloc; @@ -174,7 +174,7 @@ _compile(const char *sp, char *ep, char *endbuf, int viflag) /* malloc space */ const char *startsp = oldsp; n = 0; - while ((d = *startsp++) != NULL) { + while ((d = *startsp++) != 0) { if (d == '[') n += 33; /* add room for bitmaps */ } diff --git a/usr/src/lib/libgss/g_acquire_cred.c b/usr/src/lib/libgss/g_acquire_cred.c index c84d3a6ef7..eb6063e437 100644 --- a/usr/src/lib/libgss/g_acquire_cred.c +++ b/usr/src/lib/libgss/g_acquire_cred.c @@ -186,7 +186,7 @@ OM_uint32 * time_rec; } else mechs = desired_mechs; - if (mechs->count == NULL) + if (mechs->count == 0) return (GSS_S_BAD_MECH); /* allocate the output credential structure */ diff --git a/usr/src/lib/libinetsvc/common/inetsvc.c b/usr/src/lib/libinetsvc/common/inetsvc.c index b58557d03f..6c688c0c11 100644 --- a/usr/src/lib/libinetsvc/common/inetsvc.c +++ b/usr/src/lib/libinetsvc/common/inetsvc.c @@ -59,51 +59,51 @@ static inetd_prop_t inetd_properties[] = { {PR_SVC_NAME_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_STRING, - B_FALSE, IVE_UNSET, NULL, B_FALSE}, + B_FALSE, IVE_UNSET, 0, B_FALSE}, {PR_SOCK_TYPE_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_STRING, - B_FALSE, IVE_UNSET, NULL, B_FALSE}, + B_FALSE, IVE_UNSET, 0, B_FALSE}, {PR_PROTO_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_STRING_LIST, - B_FALSE, IVE_UNSET, NULL, B_FALSE}, + B_FALSE, IVE_UNSET, 0, B_FALSE}, {PR_ISRPC_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_BOOLEAN, - B_FALSE, IVE_UNSET, NULL, B_FALSE}, + B_FALSE, IVE_UNSET, 0, B_FALSE}, {PR_RPC_LW_VER_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER, - B_FALSE, IVE_UNSET, NULL, B_FALSE}, + B_FALSE, IVE_UNSET, 0, B_FALSE}, {PR_RPC_HI_VER_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER, - B_FALSE, IVE_UNSET, NULL, B_FALSE}, + B_FALSE, IVE_UNSET, 0, B_FALSE}, {PR_ISWAIT_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_BOOLEAN, - B_FALSE, IVE_UNSET, NULL, B_FALSE}, + B_FALSE, IVE_UNSET, 0, B_FALSE}, {PR_EXEC_NAME, START_METHOD_NAME, INET_TYPE_STRING, - B_FALSE, IVE_UNSET, NULL, B_FALSE}, + B_FALSE, IVE_UNSET, 0, B_FALSE}, {PR_ARG0_NAME, START_METHOD_NAME, INET_TYPE_STRING, - B_FALSE, IVE_UNSET, NULL, B_FALSE}, + B_FALSE, IVE_UNSET, 0, B_FALSE}, {PR_USER_NAME, START_METHOD_NAME, INET_TYPE_STRING, - B_FALSE, IVE_UNSET, NULL, B_FALSE}, + B_FALSE, IVE_UNSET, 0, B_FALSE}, {PR_BIND_ADDR_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_STRING, - B_TRUE, IVE_UNSET, NULL, B_FALSE}, + B_TRUE, IVE_UNSET, 0, B_FALSE}, {PR_BIND_FAIL_MAX_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER, - B_TRUE, IVE_UNSET, NULL, B_FALSE}, + B_TRUE, IVE_UNSET, 0, B_FALSE}, {PR_BIND_FAIL_INTVL_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER, - B_TRUE, IVE_UNSET, NULL, B_FALSE}, + B_TRUE, IVE_UNSET, 0, B_FALSE}, {PR_CON_RATE_MAX_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER, - B_TRUE, IVE_UNSET, NULL, B_FALSE}, + B_TRUE, IVE_UNSET, 0, B_FALSE}, {PR_MAX_COPIES_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER, - B_TRUE, IVE_UNSET, NULL, B_FALSE}, + B_TRUE, IVE_UNSET, 0, B_FALSE}, {PR_CON_RATE_OFFLINE_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER, - B_TRUE, IVE_UNSET, NULL, B_FALSE}, + B_TRUE, IVE_UNSET, 0, B_FALSE}, {PR_MAX_FAIL_RATE_CNT_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER, - B_TRUE, IVE_UNSET, NULL, B_FALSE}, + B_TRUE, IVE_UNSET, 0, B_FALSE}, {PR_MAX_FAIL_RATE_INTVL_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER, - B_TRUE, IVE_UNSET, NULL, B_FALSE}, + B_TRUE, IVE_UNSET, 0, B_FALSE}, {PR_INHERIT_ENV_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_BOOLEAN, - B_TRUE, IVE_UNSET, NULL, B_FALSE}, + B_TRUE, IVE_UNSET, 0, B_FALSE}, {PR_DO_TCP_TRACE_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_BOOLEAN, - B_TRUE, IVE_UNSET, NULL, B_FALSE}, + B_TRUE, IVE_UNSET, 0, B_FALSE}, {PR_DO_TCP_WRAPPERS_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_BOOLEAN, - B_TRUE, IVE_UNSET, NULL, B_FALSE}, + B_TRUE, IVE_UNSET, 0, B_FALSE}, {PR_CONNECTION_BACKLOG_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER, - B_TRUE, IVE_UNSET, NULL, B_FALSE}, + B_TRUE, IVE_UNSET, 0, B_FALSE}, {PR_DO_TCP_KEEPALIVE_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_BOOLEAN, - B_TRUE, IVE_UNSET, NULL, B_FALSE}, + B_TRUE, IVE_UNSET, 0, B_FALSE}, {NULL}, }; @@ -1617,7 +1617,8 @@ dg_template(void (*cb)(int, const struct sockaddr *, int, const void *, size_t), */ int safe_sendto_write(int fd, const void *buf, size_t sz, int flags, - const struct sockaddr *to, int tolen) { + const struct sockaddr *to, int tolen) +{ size_t cnt = 0; ssize_t ret; @@ -1639,7 +1640,8 @@ safe_sendto_write(int fd, const void *buf, size_t sz, int flags, int safe_sendto(int fd, const void *buf, size_t sz, int flags, - const struct sockaddr *to, int tolen) { + const struct sockaddr *to, int tolen) +{ return (safe_sendto_write(fd, buf, sz, flags, to, tolen)); } diff --git a/usr/src/lib/libkmf/libkmf/common/certgetsetop.c b/usr/src/lib/libkmf/libkmf/common/certgetsetop.c index 167df96507..f6acec95d6 100644 --- a/usr/src/lib/libkmf/libkmf/common/certgetsetop.c +++ b/usr/src/lib/libkmf/libkmf/common/certgetsetop.c @@ -1943,7 +1943,7 @@ kmf_set_cert_validity(KMF_X509_CERTIFICATE *CertData, return (KMF_ERR_BAD_PARAMETER); /* Set up validity fields */ - if (notBefore == NULL) + if (notBefore == 0) clock = time(NULL); else clock = notBefore; @@ -2002,7 +2002,7 @@ set_integer(KMF_DATA *data, void *value, int length) static KMF_RETURN set_bigint(KMF_BIGINT *data, KMF_BIGINT *bigint) { - if (data == NULL || bigint == NULL || bigint->len == NULL) + if (data == NULL || bigint == NULL || bigint->len == 0) return (KMF_ERR_BAD_PARAMETER); data->val = malloc(bigint->len); diff --git a/usr/src/lib/libkmf/libkmf/common/certop.c b/usr/src/lib/libkmf/libkmf/common/certop.c index 77cb1e949b..2bd06308ae 100644 --- a/usr/src/lib/libkmf/libkmf/common/certop.c +++ b/usr/src/lib/libkmf/libkmf/common/certop.c @@ -276,7 +276,7 @@ kmf_find_cert(KMF_HANDLE_T handle, int numattr, KMF_ATTRIBUTE *attrlist) return (plugin->funclist->FindCert(handle, numattr, attrlist)); } -#define NODATA(d) (d.Data == NULL || d.Length == NULL) +#define NODATA(d) (d.Data == NULL || d.Length == 0) KMF_RETURN kmf_encode_cert_record(KMF_X509_CERTIFICATE *CertData, KMF_DATA *encodedCert) diff --git a/usr/src/lib/libkmf/libkmf/common/generalop.c b/usr/src/lib/libkmf/libkmf/common/generalop.c index e29eaddf5d..fd52c64bbf 100644 --- a/usr/src/lib/libkmf/libkmf/common/generalop.c +++ b/usr/src/lib/libkmf/libkmf/common/generalop.c @@ -423,9 +423,9 @@ Cleanup_PK11_Session(KMF_HANDLE_T handle) { if (handle != NULL) { /* Close active session on a pkcs11 token */ - if (handle->pk11handle != NULL) { + if (handle->pk11handle != 0) { (void) C_CloseSession(handle->pk11handle); - handle->pk11handle = NULL; + handle->pk11handle = 0; } } } diff --git a/usr/src/lib/libkmf/libkmf/common/pk11keys.c b/usr/src/lib/libkmf/libkmf/common/pk11keys.c index 015cd8a14c..9aff2166c7 100644 --- a/usr/src/lib/libkmf/libkmf/common/pk11keys.c +++ b/usr/src/lib/libkmf/libkmf/common/pk11keys.c @@ -26,7 +26,7 @@ typedef struct } ALG_INFO; static const ALG_INFO alg_info_map[] = { - { KMF_ALGID_RSA, CKK_RSA, CKM_RSA_PKCS, CKM_RSA_PKCS, NULL}, + { KMF_ALGID_RSA, CKK_RSA, CKM_RSA_PKCS, CKM_RSA_PKCS, 0}, { KMF_ALGID_DSA, CKK_DSA, CKM_DSA, CKM_DSA, CKM_SHA_1 }, { KMF_ALGID_ECDSA, CKK_EC, CKM_ECDSA, CKM_ECDSA, CKM_SHA_1 }, { KMF_ALGID_SHA1WithDSA, CKK_DSA, CKM_DSA, CKM_DSA, CKM_SHA_1 }, @@ -554,7 +554,7 @@ PKCS_EncryptData(KMF_HANDLE_T kmfh, CK_MECHANISM_TYPE mechtype; CK_KEY_TYPE keytype; CK_OBJECT_HANDLE ckKeyHandle = 0; - CK_SESSION_HANDLE ckSession = NULL; + CK_SESSION_HANDLE ckSession = 0; CK_ULONG out_len = 0, in_len = 0, total_encrypted = 0; uint8_t *in_data, *out_data; int i, blocks, block_size; diff --git a/usr/src/lib/libkmf/libkmf/common/pk11tokens.c b/usr/src/lib/libkmf/libkmf/common/pk11tokens.c index a9cf513f29..c71bd73b4a 100644 --- a/usr/src/lib/libkmf/libkmf/common/pk11tokens.c +++ b/usr/src/lib/libkmf/libkmf/common/pk11tokens.c @@ -521,7 +521,7 @@ kmf_select_token(KMF_HANDLE_T handle, char *label, int readonly) } /* Only one token can be active per thread */ - if (handle->pk11handle != NULL) { + if (handle->pk11handle != 0) { return (KMF_ERR_TOKEN_SELECTED); } diff --git a/usr/src/lib/libkmf/plugins/kmf_openssl/common/openssl_spi.c b/usr/src/lib/libkmf/plugins/kmf_openssl/common/openssl_spi.c index f014d5b2be..f65274f7c2 100644 --- a/usr/src/lib/libkmf/plugins/kmf_openssl/common/openssl_spi.c +++ b/usr/src/lib/libkmf/plugins/kmf_openssl/common/openssl_spi.c @@ -818,7 +818,7 @@ readAltFormatPrivateKey(KMF_DATA *filedata, EVP_PKEY **pkey) KMF_RAW_RSA_KEY rsa; BerElement *asn1 = NULL; BerValue filebuf; - BerValue OID = { NULL, 0 }; + BerValue OID = { 0, 0 }; BerValue *Mod = NULL, *PubExp = NULL; BerValue *PriExp = NULL, *Prime1 = NULL, *Prime2 = NULL; BerValue *Coef = NULL; @@ -2635,7 +2635,7 @@ check_response_signature(KMF_HANDLE_T handle, OCSP_BASICRESP *bs, goto end; } - if (sk_X509_push(cert_stack, issuer) == NULL) { + if (sk_X509_push(cert_stack, issuer) == 0) { ret = KMF_ERR_INTERNAL; goto end; } @@ -3631,7 +3631,7 @@ OpenSSL_ExportPK12(KMF_HANDLE_T handle, int numattr, KMF_ATTRIBUTE *attrlist) } (void) memset(&certdata, 0, sizeof (certdata)); - rv = kmf_load_cert(kmfh, NULL, NULL, NULL, NULL, + rv = kmf_load_cert(kmfh, NULL, NULL, NULL, 0, fullpath, &certdata.certificate); if (rv != KMF_OK) goto end; @@ -3940,7 +3940,7 @@ openssl_parse_bag(PKCS12_SAFEBAG *bag, char *pass, int passlen, fname->value.asn1_string); if (len > 0 && data != NULL) { r = X509_alias_set1(xcert, data, len); - if (r == NULL) { + if (r == 0) { ret = KMF_ERR_PKCS12_FORMAT; goto end; } @@ -4026,7 +4026,7 @@ openssl_pkcs12_parse(PKCS12 *p12, char *pin, if (p12 == NULL || (keys == NULL && certs == NULL)) return (KMF_ERR_BAD_PARAMETER); - if (pin == NULL || *pin == NULL) { + if (pin == NULL || *pin == '\0') { if (PKCS12_verify_mac(p12, NULL, 0)) { pin = NULL; } else if (PKCS12_verify_mac(p12, "", 0)) { diff --git a/usr/src/lib/libkmf/plugins/kmf_pkcs11/common/pkcs11_spi.c b/usr/src/lib/libkmf/plugins/kmf_pkcs11/common/pkcs11_spi.c index bab6957c45..85f6b08b22 100644 --- a/usr/src/lib/libkmf/plugins/kmf_pkcs11/common/pkcs11_spi.c +++ b/usr/src/lib/libkmf/plugins/kmf_pkcs11/common/pkcs11_spi.c @@ -194,7 +194,7 @@ pk11_authenticate(KMF_HANDLE_T handle, CK_RV ck_rv = CKR_OK; CK_SESSION_HANDLE hSession = (CK_SESSION_HANDLE)handle->pk11handle; - if (hSession == NULL) + if (hSession == 0) return (KMF_ERR_NO_TOKEN_SELECTED); if (cred == NULL || cred->cred == NULL) { @@ -1104,7 +1104,7 @@ CreateCertObject(KMF_HANDLE_T handle, char *label, KMF_DATA *pcert) CK_CERTIFICATE_TYPE certtype = CKC_X_509; CK_OBJECT_CLASS certClass = CKO_CERTIFICATE; CK_ATTRIBUTE x509templ[11]; - CK_OBJECT_HANDLE hCert = NULL; + CK_OBJECT_HANDLE hCert = 0; int i; if (kmfh == NULL) @@ -3742,7 +3742,7 @@ KMFPK11_SetTokenPin(KMF_HANDLE_T handle, KMF_RETURN ret = KMF_OK; CK_RV rv = CKR_OK; KMF_HANDLE *kmfh = (KMF_HANDLE *)handle; - CK_SESSION_HANDLE session = NULL; + CK_SESSION_HANDLE session = 0; KMF_CREDENTIAL *oldcred; KMF_CREDENTIAL *newcred; CK_SLOT_ID slotid; @@ -3819,7 +3819,7 @@ KMFPK11_SetTokenPin(KMF_HANDLE_T handle, ret = KMF_ERR_INTERNAL; } end: - if (session != NULL) + if (session != 0) (void) C_CloseSession(session); return (ret); } diff --git a/usr/src/lib/libmapid/common/mapid.c b/usr/src/lib/libmapid/common/mapid.c index d0a006d6be..42eceb21b4 100644 --- a/usr/src/lib/libmapid/common/mapid.c +++ b/usr/src/lib/libmapid/common/mapid.c @@ -959,7 +959,7 @@ get_nfs_domain(void) bzero(value, NS_MAXCDNAME); ret = nfs_smf_get_prop("nfsmapid_domain", value, DEFAULT_INSTANCE, SCF_TYPE_ASTRING, NFSMAPID, &bufsz); - if (ret == SA_OK && *value != NULL) { + if (ret == SA_OK && *value != '\0') { char *dp = NULL; #ifdef DEBUG char *whoami = "get_nfs_domain"; diff --git a/usr/src/lib/libpkg/THIRDPARTYLICENSE.descrip b/usr/src/lib/libpkg/THIRDPARTYLICENSE.descrip deleted file mode 100644 index cb84cdcb4c..0000000000 --- a/usr/src/lib/libpkg/THIRDPARTYLICENSE.descrip +++ /dev/null @@ -1 +0,0 @@ -PORTIONS OF THE SVR4 PACKAGE LIBRARY (LIBPKG) diff --git a/usr/src/lib/libproc/amd64/Pisadep.c b/usr/src/lib/libproc/amd64/Pisadep.c index 95064ae33a..360997dab3 100644 --- a/usr/src/lib/libproc/amd64/Pisadep.c +++ b/usr/src/lib/libproc/amd64/Pisadep.c @@ -353,9 +353,9 @@ Pstack_iter32(struct ps_prochandle *P, const prgregset_t regs, if (find_uclink(&ucl, pfp + sizeof (sf_t))) uc_addr = pfp + sizeof (sf_t); else - uc_addr = NULL; + uc_addr = (uintptr_t)NULL; - if (uc_addr != NULL && + if (uc_addr != (uintptr_t)NULL && Pread(P, &uc, sizeof (uc), uc_addr) == sizeof (uc)) { ucontext_32_to_prgregs(&uc, gregs); fp = gregs[R_FP]; diff --git a/usr/src/lib/libproc/common/Pcore.c b/usr/src/lib/libproc/common/Pcore.c index cfeb0ebb87..b0b2efec85 100644 --- a/usr/src/lib/libproc/common/Pcore.c +++ b/usr/src/lib/libproc/common/Pcore.c @@ -1934,7 +1934,7 @@ core_find_data(struct ps_prochandle *P, Elf *elf, rd_loadobj_t *rlp) uint_t i, pagemask; size_t nphdrs; - rlp->rl_data_base = NULL; + rlp->rl_data_base = (uintptr_t)NULL; /* * Find the first loadable, writeable Phdr and compute rl_data_base @@ -1958,7 +1958,7 @@ core_find_data(struct ps_prochandle *P, Elf *elf, rd_loadobj_t *rlp) * If we didn't find an appropriate phdr or if the address we * computed has no mapping, return NULL. */ - if (rlp->rl_data_base == NULL || + if (rlp->rl_data_base == (uintptr_t)NULL || (mp = Paddr2mptr(P, rlp->rl_data_base)) == NULL) return (NULL); diff --git a/usr/src/lib/libproc/common/Pexecname.c b/usr/src/lib/libproc/common/Pexecname.c index 8af0416e10..cb52191dfe 100644 --- a/usr/src/lib/libproc/common/Pexecname.c +++ b/usr/src/lib/libproc/common/Pexecname.c @@ -180,7 +180,7 @@ Pfindexec(struct ps_prochandle *P, const char *aout, * Fourth try: read the string pointed to by argv[0] out of the * stack in the process's address space. */ - if (P->psinfo.pr_argv != NULL && + if (P->psinfo.pr_argv != (uintptr_t)NULL && Pread(P, &addr, sizeof (addr), P->psinfo.pr_argv) != -1 && Pread_string(P, path, sizeof (path), (off_t)addr) > 0) { diff --git a/usr/src/lib/libproc/common/Pstack.c b/usr/src/lib/libproc/common/Pstack.c index f0f8b5ce8d..fde462c0e2 100644 --- a/usr/src/lib/libproc/common/Pstack.c +++ b/usr/src/lib/libproc/common/Pstack.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Pstack.c * @@ -176,7 +174,7 @@ load_uclist(uclist_t *ucl, const lwpstatus_t *psp) uint_t new_size, i; ucontext_t uc; - if (addr == NULL) + if (addr == (uintptr_t)NULL) return (0); for (;;) { @@ -214,7 +212,7 @@ load_uclist(uclist_t *ucl, const lwpstatus_t *psp) * entry which could indicate a cycle or a very peculiar * interference pattern between threads. */ - if (addr == NULL) + if (addr == (uintptr_t)NULL) break; for (i = 0; i < ucl->uc_nelems - 1; i++) { diff --git a/usr/src/lib/libproc/common/Psymtab.c b/usr/src/lib/libproc/common/Psymtab.c index aed64d7799..a224dd4055 100644 --- a/usr/src/lib/libproc/common/Psymtab.c +++ b/usr/src/lib/libproc/common/Psymtab.c @@ -647,7 +647,7 @@ Paddr_to_text_map(struct ps_prochandle *P, uintptr_t addr) * section. */ if (fptr != NULL && fptr->file_lo != NULL && - (fptr->file_lo->rl_data_base == NULL || + (fptr->file_lo->rl_data_base == (uintptr_t)NULL || pmp->pr_vaddr + pmp->pr_size <= fptr->file_lo->rl_data_base)) return (pmp); @@ -3574,7 +3574,7 @@ Penv_iter(struct ps_prochandle *P, proc_env_f *func, void *data) nenv = 0; } - if ((envoff = envp[nenv++]) == NULL) + if ((envoff = envp[nenv++]) == (uintptr_t)NULL) break; /* diff --git a/usr/src/lib/libproc/common/Psymtab_machelf32.c b/usr/src/lib/libproc/common/Psymtab_machelf32.c index e2554a0d27..ea972ba1ac 100644 --- a/usr/src/lib/libproc/common/Psymtab_machelf32.c +++ b/usr/src/lib/libproc/common/Psymtab_machelf32.c @@ -258,7 +258,7 @@ fake_elf32(struct ps_prochandle *P, file_info_t *fptr, uintptr_t addr, uint_t i; Off off; size_t pltsz = 0, pltentries = 0; - uintptr_t hptr = NULL; + uintptr_t hptr = (uintptr_t)NULL; Word hnchains = 0, hnbuckets = 0; if (ehdr->e_type == ET_DYN) @@ -628,7 +628,8 @@ done_with_plt: symtabptr = (Sym*)((uintptr_t)symtabptr + addr); } - if ((hptr == NULL) || (hnbuckets == 0) || (hnchains == 0)) { + if ((hptr == (uintptr_t)NULL) || (hnbuckets == 0) || + (hnchains == 0)) { dprintf("empty or missing .hash\n"); goto badplt; } diff --git a/usr/src/lib/libproc/i386/Pisadep.c b/usr/src/lib/libproc/i386/Pisadep.c index 855f50a5d4..077ba5ad0d 100644 --- a/usr/src/lib/libproc/i386/Pisadep.c +++ b/usr/src/lib/libproc/i386/Pisadep.c @@ -286,9 +286,9 @@ Pstack_iter(struct ps_prochandle *P, const prgregset_t regs, if (find_uclink(&ucl, pfp + sizeof (sf_t))) uc_addr = pfp + sizeof (sf_t); else - uc_addr = NULL; + uc_addr = (uintptr_t)NULL; - if (uc_addr != NULL && + if (uc_addr != (uintptr_t)NULL && Pread(P, &uc, sizeof (uc), uc_addr) == sizeof (uc)) { ucontext_n_to_prgregs(&uc, gregs); diff --git a/usr/src/lib/libshare/autofs/libshare_autofs.c b/usr/src/lib/libshare/autofs/libshare_autofs.c index 8098a6e36e..1d1e3dffb1 100644 --- a/usr/src/lib/libshare/autofs/libshare_autofs.c +++ b/usr/src/lib/libshare/autofs/libshare_autofs.c @@ -68,8 +68,8 @@ static int range_check_validator(int index, char *value); struct sa_plugin_ops sa_plugin_ops = { SA_PLUGIN_VERSION, "autofs", - autofs_init, /* Init autofs */ - autofs_fini, /* Fini autofs */ + autofs_init, /* Init autofs */ + autofs_fini, /* Fini autofs */ NULL, /* Start Sharing */ NULL, /* stop sharing */ autofs_validate_property, @@ -146,8 +146,8 @@ struct proto_option_defs { #define PROTO_OPT_AUTOMOUNTD_ENV 5 { "environment", "environment", PROTO_OPT_AUTOMOUNTD_ENV, SCF_TYPE_ASTRING, - NULL, 0, 1024, strlen_validator}, - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} + 0, 0, 1024, strlen_validator}, + {NULL, NULL, 0, 0, 0, 0, 0, NULL} }; #define AUTOFS_PROP_MAX (sizeof (proto_options) / sizeof (proto_options[0])) diff --git a/usr/src/lib/libshare/nfs/libshare_nfs.c b/usr/src/lib/libshare/nfs/libshare_nfs.c index c2d95210c7..f8f8ff0710 100644 --- a/usr/src/lib/libshare/nfs/libshare_nfs.c +++ b/usr/src/lib/libshare/nfs/libshare_nfs.c @@ -1263,7 +1263,7 @@ printarg(char *path, struct exportdata *ep) (void) printf("LOG_ALLOPS "); if (ep->ex_flags == 0) (void) printf("(none)"); - (void) printf("\n"); + (void) printf("\n"); if (ep->ex_flags & EX_LOG) { (void) printf("\tex_log_buffer = %s\n", (ep->ex_log_buffer ? ep->ex_log_buffer : "(NULL)")); @@ -2539,7 +2539,7 @@ struct proto_option_defs { #define PROTO_OPT_NFSMAPID_DOMAIN 10 {"nfsmapid_domain", "nfsmapid_domain", PROTO_OPT_NFSMAPID_DOMAIN, OPT_TYPE_DOMAIN, - NULL, SVC_NFSMAPID, 0, 0}, + 0, SVC_NFSMAPID, 0, 0}, #define PROTO_OPT_NFSD_MAX_CONNECTIONS 11 {"nfsd_max_connections", "max_connections", PROTO_OPT_NFSD_MAX_CONNECTIONS, @@ -2555,7 +2555,7 @@ struct proto_option_defs { #define PROTO_OPT_NFSD_DEVICE 14 {"nfsd_device", "device", PROTO_OPT_NFSD_DEVICE, - OPT_TYPE_STRING, NULL, SVC_NFSD, 0, 0}, + OPT_TYPE_STRING, 0, SVC_NFSD, 0, 0}, #define PROTO_OPT_MOUNTD_LISTEN_BACKLOG 15 {"mountd_listen_backlog", "mountd_listen_backlog", PROTO_OPT_MOUNTD_LISTEN_BACKLOG, diff --git a/usr/src/lib/libshare/smb/libshare_smb.c b/usr/src/lib/libshare/smb/libshare_smb.c index 0429edca77..7a731820e0 100644 --- a/usr/src/lib/libshare/smb/libshare_smb.c +++ b/usr/src/lib/libshare/smb/libshare_smb.c @@ -182,7 +182,7 @@ struct option_defs optdefs[] = { { SHOPT_FSO, OPT_TYPE_BOOLEAN }, { SHOPT_QUOTAS, OPT_TYPE_BOOLEAN }, { SHOPT_ENCRYPT, OPT_TYPE_STRING }, - { NULL, NULL } + { NULL, 0 } }; /* diff --git a/usr/src/lib/nsswitch/ldap/common/getkeyent.c b/usr/src/lib/nsswitch/ldap/common/getkeyent.c index 95f27cddb9..6fa6219c6f 100644 --- a/usr/src/lib/nsswitch/ldap/common/getkeyent.c +++ b/usr/src/lib/nsswitch/ldap/common/getkeyent.c @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <pwd.h> #include <ctype.h> #include "ldap_common.h" @@ -87,7 +85,7 @@ _nss_ldap_key2str(ldap_backend_ptr be, nss_XbyY_args_t *argp) goto result_key2str; } while (*pkey_array) { - if (strncasecmp(*pkey_array, keytype, keytypelen) == NULL) + if (strncasecmp(*pkey_array, keytype, keytypelen) == 0) break; pkey_array++; } @@ -112,7 +110,7 @@ _nss_ldap_key2str(ldap_backend_ptr be, nss_XbyY_args_t *argp) goto result_key2str; } while (*skey_array) { - if (strncasecmp(*skey_array, keytype, keytypelen) == NULL) + if (strncasecmp(*skey_array, keytype, keytypelen) == 0) break; skey_array++; } diff --git a/usr/src/lib/nsswitch/ldap/common/getprinter.c b/usr/src/lib/nsswitch/ldap/common/getprinter.c index 079741d61e..c24bb67320 100644 --- a/usr/src/lib/nsswitch/ldap/common/getprinter.c +++ b/usr/src/lib/nsswitch/ldap/common/getprinter.c @@ -212,7 +212,7 @@ _nss_ldap_printers2str(ldap_backend_ptr be, nss_XbyY_args_t *argp) * be backslashed plus ending ':' or ','. */ k = 0; - for (kp = attr->attrvalue[j]; *kp != NULL; kp++) + for (kp = attr->attrvalue[j]; *kp != '\0'; kp++) if (*kp == ':') /* count ':' in value */ k++; @@ -259,7 +259,7 @@ append_attr(char *buf, char *attr) } bp = buf; cp = attr; - while (*cp != NULL) { + while (*cp != '\0') { if (*cp == ':') { *bp++ = '\\'; } diff --git a/usr/src/lib/nsswitch/mdns/common/mdns_common.c b/usr/src/lib/nsswitch/mdns/common/mdns_common.c index 3e914e5744..c850d2edac 100644 --- a/usr/src/lib/nsswitch/mdns/common/mdns_common.c +++ b/usr/src/lib/nsswitch/mdns/common/mdns_common.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "mdns_common.h" static int _nss_mdns_queryrecord(const char *rrname, int rrclass, int rrtype, @@ -91,7 +89,7 @@ _nss_mdns_queryrecord(const char *rrname, int rrclass, int rrtype, err = DNSServiceQueryRecord(&ref, flags, opinterface, rrname, rrtype, rrclass, callback, data); if (err != kDNSServiceErr_NoError || ref == NULL || - (sockfd = DNSServiceRefSockFD(ref)) == NULL) { + (sockfd = DNSServiceRefSockFD(ref)) == 0) { DNSServiceRefDeallocate(ref); data->status = NSS_UNAVAIL; return (NSS_UNAVAIL); diff --git a/usr/src/lib/nsswitch/user/common/getprinter.c b/usr/src/lib/nsswitch/user/common/getprinter.c index 7e62b69724..4c64fb79be 100644 --- a/usr/src/lib/nsswitch/user/common/getprinter.c +++ b/usr/src/lib/nsswitch/user/common/getprinter.c @@ -27,8 +27,6 @@ * convenient method of aliasing and specifying an interest list. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #pragma weak _nss_user__printers_constr = _nss_user_printers_constr #include <nss_dbdefs.h> @@ -47,17 +45,18 @@ _nss_user_printers_convert(char *entry, nss_XbyY_args_t *args) int length = 0; if ((value = strpbrk(entry, "\t ")) != NULL) { - *value = NULL; value++; + *value = '\0'; + value++; - while ((*value != NULL) && (isspace(*value) != 0)) + while ((*value != '\0') && (isspace(*value) != 0)) value++; if ((key = strpbrk(value, "\n\t ")) != NULL) - *key = NULL; + *key = '\0'; } - args->buf.buffer[0] = NULL; - if ((value == NULL) || (*value == NULL)) { /* bad value */ + args->buf.buffer[0] = '\0'; + if ((value == NULL) || (*value == '\0')) { /* bad value */ args->erange = 1; return (res); } @@ -71,7 +70,7 @@ _nss_user_printers_convert(char *entry, nss_XbyY_args_t *args) namelist, key); /* append the value ':' must be escaped for posix style names */ - while ((length < args->buf.buflen) && (*value != NULL)) { + while ((length < args->buf.buflen) && (*value != '\0')) { if (*value == ':') args->buf.buffer[length++] = '\\'; args->buf.buffer[length++] = *value++; @@ -82,7 +81,7 @@ _nss_user_printers_convert(char *entry, nss_XbyY_args_t *args) return (res); } - args->buf.buffer[length] = NULL; /* terminate, just in case */ + args->buf.buffer[length] = '\0'; /* terminate, just in case */ args->returnval = args->buf.result; res = NSS_SUCCESS; diff --git a/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_element.c b/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_element.c index 3b53e3294f..ff9e33e186 100644 --- a/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_element.c +++ b/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_element.c @@ -24,6 +24,9 @@ * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. * Use is subject to license terms. */ +/* + * Copyright 2019 RackTop Systems. + */ #include <sys/types.h> #include <stddef.h> @@ -963,30 +966,37 @@ elem_parse_threshold(ses_plugin_t *sp, ses_node_t *np) VERIFY(nvlist_lookup_uint64(nvl, SES_PROP_ELEMENT_TYPE, &type) == 0); + if ((tp = ses_plugin_page_lookup(sp, snap, + SES2_DIAGPAGE_THRESHOLD_IO, np, &len)) == NULL) + return (0); + switch (type) { case SES_ET_TEMPERATURE_SENSOR: + SES_NV_ADD(int64, nverr, nvl, SES_PROP_THRESH_CRIT_HI, + (int)tp->sti_high_crit + SES2_ES_TEMP_OFFSET); + SES_NV_ADD(int64, nverr, nvl, SES_PROP_THRESH_WARN_HI, + (int)tp->sti_high_warn + SES2_ES_TEMP_OFFSET); + SES_NV_ADD(int64, nverr, nvl, SES_PROP_THRESH_CRIT_LO, + (int)tp->sti_low_crit + SES2_ES_TEMP_OFFSET); + SES_NV_ADD(int64, nverr, nvl, SES_PROP_THRESH_WARN_LO, + (int)tp->sti_low_warn + SES2_ES_TEMP_OFFSET); + return (0); + case SES_ET_UPS: - case SES_ET_VOLTAGE_SENSOR: case SES_ET_CURRENT_SENSOR: - break; + case SES_ET_VOLTAGE_SENSOR: + SES_NV_ADD(uint64, nverr, nvl, SES_PROP_THRESH_CRIT_HI, + tp->sti_high_crit); + SES_NV_ADD(uint64, nverr, nvl, SES_PROP_THRESH_WARN_HI, + tp->sti_high_warn); + SES_NV_ADD(uint64, nverr, nvl, SES_PROP_THRESH_CRIT_LO, + tp->sti_low_crit); + SES_NV_ADD(uint64, nverr, nvl, SES_PROP_THRESH_WARN_LO, + tp->sti_low_warn); + return (0); default: return (0); } - - if ((tp = ses_plugin_page_lookup(sp, snap, - SES2_DIAGPAGE_THRESHOLD_IO, np, &len)) == NULL) - return (0); - - SES_NV_ADD(uint64, nverr, nvl, SES_PROP_THRESH_CRIT_HI, - tp->sti_high_crit); - SES_NV_ADD(uint64, nverr, nvl, SES_PROP_THRESH_WARN_HI, - tp->sti_high_warn); - SES_NV_ADD(uint64, nverr, nvl, SES_PROP_THRESH_CRIT_LO, - tp->sti_low_crit); - SES_NV_ADD(uint64, nverr, nvl, SES_PROP_THRESH_WARN_LO, - tp->sti_low_warn); - - return (0); } int diff --git a/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_impl.h b/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_impl.h index 43c287975c..a080c1e32c 100644 --- a/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_impl.h +++ b/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_impl.h @@ -22,6 +22,9 @@ /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. */ +/* + * Copyright 2019 RackTop Systems + */ #ifndef _PLUGIN_SES_IMPL_H #define _PLUGIN_SES_IMPL_H @@ -1163,6 +1166,9 @@ typedef struct ses2_aes_page_impl { /* * SES-2 Additional Element Status descriptor (EIP == 1) (Table 26, 6.1.13). + * Updated with EIIOE for Table 32 from SES-3, 6.1.13. + * Note that we think later revs of SES-3 probably widen the EIIOE to 2 bits, + * waiting for final document to be sure. */ typedef struct ses2_aes_descr_eip_impl { DECL_BITFIELD4( @@ -1171,7 +1177,9 @@ typedef struct ses2_aes_descr_eip_impl { _reserved1 :2, sadei_invalid :1); uint8_t sadei_length; - uint8_t _reserved2; + DECL_BITFIELD2( + sadei_eiioe :2, + _reserved2 :6); uint8_t sadei_element_index; uint8_t sadei_protocol_specific[1]; } ses2_aes_descr_eip_impl_t; diff --git a/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_pages.c b/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_pages.c index f4d6bd661f..6b0ac8e4a8 100644 --- a/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_pages.c +++ b/usr/src/lib/scsi/plugins/ses/ses2/common/ses2_pages.c @@ -24,6 +24,7 @@ */ /* * Copyright 2012 Nexenta Systems, Inc. All rights reserved. + * Copyright 2019 RackTop Systems */ #include <stddef.h> @@ -59,14 +60,16 @@ ses2_aes_index(ses_plugin_t *sp, ses_node_t *np, void *data, size_t pagelen, size_t *len) { ses2_aes_page_impl_t *apip = data; - uint64_t index, type; + uint64_t index, eindex, oindex, type; nvlist_t *props = ses_node_props(np); ses2_aes_descr_eip_impl_t *dep; size_t desclen; int i, pos; VERIFY(nvlist_lookup_uint64(props, SES_PROP_ELEMENT_ONLY_INDEX, - &index) == 0); + &eindex) == 0); + VERIFY(nvlist_lookup_uint64(props, SES_PROP_ELEMENT_INDEX, + &oindex) == 0); VERIFY(nvlist_lookup_uint64(props, SES_PROP_ELEMENT_TYPE, &type) == 0); @@ -86,6 +89,34 @@ ses2_aes_index(ses_plugin_t *sp, ses_node_t *np, void *data, size_t pagelen, if (!SES_WITHIN_PAGE(dep, desclen, data, pagelen)) break; + if (dep->sadei_eip) { + /* + * The following switch table deals with the cases + * for the EIIOE (element index includes overall + * elements). The treatment for this includes handling + * connector and other element indices, but we don't + * actually care about or use them, so for now we + * really only care about the ELEMENT INDEX field. + */ + switch (dep->sadei_eiioe) { + case 1: + /* + * Use the overall index. We expect most + * modern implementations to use this case. + */ + index = oindex; + break; + case 0: + case 2: + case 3: + /* + * Use the element only index - excluding + * the overall elements. + */ + index = eindex; + break; + } + } pos += desclen; if (!dep->sadei_eip && type != SES_ET_DEVICE && @@ -102,8 +133,11 @@ ses2_aes_index(ses_plugin_t *sp, ses_node_t *np, void *data, size_t pagelen, * to have otherwise. See 6.1.13.1. */ continue; - } else if (dep->sadei_eip && - dep->sadei_element_index != index) { + } else if (dep->sadei_eip) { + if (dep->sadei_element_index == index) { + *len = desclen; + return (dep); + } /* * The element index field from AES descriptor is * element only index which doesn't include the OVERALL @@ -112,7 +146,7 @@ ses2_aes_index(ses_plugin_t *sp, ses_node_t *np, void *data, size_t pagelen, * SES_PROP_ELEMENT_INDEX. */ continue; - } else if (dep->sadei_eip || i == index) { + } else if (i == eindex) { *len = desclen; return (dep); } diff --git a/usr/src/lib/smbsrv/libfksmbsrv/Makefile.com b/usr/src/lib/smbsrv/libfksmbsrv/Makefile.com index c8020ed722..507122dadd 100644 --- a/usr/src/lib/smbsrv/libfksmbsrv/Makefile.com +++ b/usr/src/lib/smbsrv/libfksmbsrv/Makefile.com @@ -133,6 +133,10 @@ OBJS_FS_SMBSRV = \ smb2_create.o \ smb2_echo.o \ smb2_flush.o \ + smb2_fsctl_copychunk.o \ + smb2_fsctl_fs.o \ + smb2_fsctl_odx.o \ + smb2_fsctl_sparse.o \ smb2_ioctl.o \ smb2_lease.o \ smb2_lock.o \ diff --git a/usr/src/lib/smbsrv/libfksmbsrv/common/fake_vfs.c b/usr/src/lib/smbsrv/libfksmbsrv/common/fake_vfs.c index cf53ca03b2..9fda731567 100644 --- a/usr/src/lib/smbsrv/libfksmbsrv/common/fake_vfs.c +++ b/usr/src/lib/smbsrv/libfksmbsrv/common/fake_vfs.c @@ -10,7 +10,7 @@ */ /* - * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 Nexenta Systems, Inc. All rights reserved. */ #include <sys/types.h> @@ -50,7 +50,11 @@ static uint64_t vfs_features = VFSFT_XVATTR; vnode_t *rootdir = NULL; /* pointer to root inode vnode. */ static struct vfs fake_rootvfs; +static struct vfsops fake_vfsops; struct vfs *rootvfs = NULL; +static struct vfssw fake_vfssw = { + .vsw_name = "fake" /* see smb_tree.c:smb_mtype[] */ +}; int fksmbsrv_vfs_init(void) @@ -64,6 +68,7 @@ fksmbsrv_vfs_init(void) rootvfs = &fake_rootvfs; rootvfs->vfs_mntpt = refstr_alloc(name); rootvfs->vfs_fsid.val[0] = 1; + rootvfs->vfs_op = &fake_vfsops; } if (rootdir == NULL) { @@ -126,6 +131,8 @@ vfs_getops(vfs_t *vfsp) struct vfssw * vfs_getvfsswbyvfsops(vfsops_t *vfsops) { + if (vfsops == &fake_vfsops) + return (&fake_vfssw); return (NULL); } diff --git a/usr/src/lib/smbsrv/libfksmbsrv/common/fake_vop.c b/usr/src/lib/smbsrv/libfksmbsrv/common/fake_vop.c index 3d6ec6e52e..f99c1a3bfc 100644 --- a/usr/src/lib/smbsrv/libfksmbsrv/common/fake_vop.c +++ b/usr/src/lib/smbsrv/libfksmbsrv/common/fake_vop.c @@ -218,7 +218,29 @@ fop_ioctl( int *rvalp, caller_context_t *ct) { - return (ENOSYS); + off64_t off; + int rv, whence; + + switch (cmd) { + case _FIO_SEEK_DATA: + case _FIO_SEEK_HOLE: + whence = (cmd == _FIO_SEEK_DATA) ? SEEK_DATA : SEEK_HOLE; + bcopy((void *)arg, &off, sizeof (off)); + off = lseek(vp->v_fd, off, whence); + if (off == (off64_t)-1) { + rv = errno; + } else { + bcopy(&off, (void *)arg, sizeof (off)); + rv = 0; + } + break; + + default: + rv = ENOTTY; + break; + } + + return (rv); } /* ARGSUSED */ @@ -266,10 +288,15 @@ fop_setattr( caller_context_t *ct) { timespec_t times[2]; + int err; if (vap->va_mask & AT_SIZE) { - if (ftruncate(vp->v_fd, vap->va_size) == -1) - return (errno); + if (ftruncate(vp->v_fd, vap->va_size) == -1) { + err = errno; + if (err == EBADF) + err = EACCES; + return (err); + } } /* AT_MODE or anything else? */ diff --git a/usr/src/man/man1/dis.1 b/usr/src/man/man1/dis.1 index dcb12b50b6..103fd48509 100644 --- a/usr/src/man/man1/dis.1 +++ b/usr/src/man/man1/dis.1 @@ -43,6 +43,7 @@ .\" Copyright 1989 AT&T .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved +.\" Copyright 2019 Joyent, Inc. .\" .TH DIS 1 "Dec 19, 2018" .SH NAME @@ -55,14 +56,12 @@ dis \- object code disassembler .fi .SH DESCRIPTION -.sp .LP The \fBdis\fR command produces an assembly language listing of \fIfile\fR, which can be an object file or an archive of object files. The listing includes assembly statements and an octal or hexadecimal representation of the binary that produced those statements. .SH OPTIONS -.sp .LP Options are interpreted by the disassembler and can be specified in any order. .sp @@ -194,7 +193,6 @@ On output, a number enclosed in brackets at the beginning of a line, such as following instruction. These line numbers is printed only if the file was compiled with additional debugging information. .SH OPERANDS -.sp .LP The following operand is supported: .sp @@ -207,7 +205,6 @@ A path name of an object file or an archive (see \fBar\fR(1)) of object files. .RE .SH ENVIRONMENT VARIABLES -.sp .LP See \fBenviron\fR(5) for descriptions of the following environment variables that affect the execution of \fBdis\fR: \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and @@ -224,7 +221,6 @@ defaults to searching for the library under \fB/usr/lib\fR. .RE .SH EXIT STATUS -.sp .LP The following exit values are returned: .sp @@ -246,7 +242,6 @@ An error occurred. .RE .SH FILES -.sp .ne 2 .na \fB\fB/usr/lib\fR\fR @@ -256,7 +251,6 @@ default \fBLIBDIR\fR .RE .SH ATTRIBUTES -.sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp @@ -276,12 +270,10 @@ Interface Stability See below. The human readable output is Uncommitted. The command line options are Committed. .SH SEE ALSO -.sp .LP \fBar\fR(1), \fBas\fR(1), \fBld\fR(1), \fBa.out\fR(4), \fBattributes\fR(5), \fBenviron\fR(5) .SH DIAGNOSTICS -.sp .LP The self-explanatory diagnostics indicate errors in the command line or problems encountered with the specified files. diff --git a/usr/src/man/man1/dump.1 b/usr/src/man/man1/dump.1 index ebe40fe09a..6c1c4ff317 100644 --- a/usr/src/man/man1/dump.1 +++ b/usr/src/man/man1/dump.1 @@ -1,5 +1,6 @@ '\" te .\" Copyright 1989 AT&T Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved +.\" Copyright 2019 Joyent, Inc. .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] @@ -28,7 +29,6 @@ dump \- dump selected parts of an object file .fi .SH DESCRIPTION -.sp .LP The \fBdump\fR utility dumps selected parts of each of its object \fIfile\fR arguments. @@ -37,7 +37,6 @@ arguments. The \fBdump\fR utility is best suited for use in shell scripts, whereas the \fBelfdump\fR(1) command is recommended for more human-readable output. .SH OPTIONS -.sp .LP This utility will accept both object files and archives of object files. It processes each file argument according to one or more of the following options: @@ -315,7 +314,6 @@ The \fBdump\fR utility attempts to format the information it dumps in a meaningful way, printing certain information in character, hexadecimal, octal, or decimal representation as appropriate. .SH SEE ALSO -.sp .LP \fBelfdump\fR(1), \fBnm\fR(1), \fBar.h\fR(3HEAD), \fBa.out\fR(4), \fBattributes\fR(5) diff --git a/usr/src/man/man1/elfdump.1 b/usr/src/man/man1/elfdump.1 index 01a9963189..3859847ecf 100644 --- a/usr/src/man/man1/elfdump.1 +++ b/usr/src/man/man1/elfdump.1 @@ -1,6 +1,7 @@ '\" te .\" Copyright (c) 2009 by Sun Microsystems, Inc. .\" All rights reserved. +.\" Copyright 2019 Joyent, Inc. .\" The contents of this file are subject to the .\" terms of the Common Development and Distribution License (the "License"). .\" You may not use this file except in compliance with the License. You can @@ -22,7 +23,6 @@ elfdump \- dumps selected parts of an object file .fi .SH DESCRIPTION -.sp .LP The \fBelfdump\fR utility symbolically dumps selected parts of the specified object file(s). The options allow specific portions of the file to be @@ -93,7 +93,6 @@ displays all available information for each object. For a complete description of the displayed information, refer to the \fILinker and Libraries Guide\fR. .SH OPTIONS -.sp .LP The following options are supported: .sp @@ -505,7 +504,6 @@ Dumps the contents of the \fB\&.SUNW_syminfo\fR section. .RE .SH OPERANDS -.sp .LP The following operand is supported: .sp @@ -519,7 +517,6 @@ The name of the specified object file. .SH USAGE .SS "Matching Options" -.sp .LP The options \fB-I\fR, \fB-N\fR, and \fB-T\fR are collectively referred to as the \fBmatching options\fR. These options are used to narrow the range of @@ -562,7 +559,6 @@ matched by any of the matching options used. This feature allows for the selection of complex groupings of items using the most convenient form for specifying each item. .SH FILES -.sp .ne 2 .na \fB\fBliblddbg.so\fR\fR @@ -572,7 +568,6 @@ linker debugging library .RE .SH ATTRIBUTES -.sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp @@ -588,7 +583,6 @@ Interface Stability Committed .TE .SH SEE ALSO -.sp .LP \fBar\fR(1), \fBdump\fR(1), \fBnm\fR(1), \fBpvs\fR(1), \fBelf\fR(3ELF), \fBcore\fR(4), \fBattributes\fR(5) diff --git a/usr/src/man/man1/gprof.1 b/usr/src/man/man1/gprof.1 index a6bfc0f2b4..feb128771c 100644 --- a/usr/src/man/man1/gprof.1 +++ b/usr/src/man/man1/gprof.1 @@ -1,5 +1,6 @@ '\" te .\" Copyright 1989 AT&T Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved +.\" Copyright 2019 Joyent, Inc. .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] @@ -16,7 +17,6 @@ gprof \- display call-graph profile data .fi .SH DESCRIPTION -.sp .LP The \fBgprof\fR utility produces an execution profile of a program. The effect of called routines is incorporated in the profile of each caller. The profile @@ -67,7 +67,6 @@ number of times that arc is traversed. The profiled program must call \fBexit\fR(2) or return normally for the profiling information to be saved in the \fBgmon.out\fR file. .SH OPTIONS -.sp .LP The following options are supported: .sp @@ -230,7 +229,6 @@ examined by the \fB-c\fR option. .RE .SH ENVIRONMENT VARIABLES -.sp .ne 2 .na \fB\fBPROFDIR\fR\fR @@ -246,7 +244,6 @@ file \fBgmon.out\fR. .RE .SH FILES -.sp .ne 2 .na \fB\fBa.out\fR\fR @@ -283,7 +280,6 @@ summarized dynamic call-graph and profile .RE .SH SEE ALSO -.sp .LP \fBcc\fR(1), \fBld.so.1\fR(1), \fBprof\fR(1), \fBexit\fR(2), \fBpcsample\fR(2), \fBprofil\fR(2), \fBmalloc\fR(3C), \fBmalloc\fR(3MALLOC), \fBmonitor\fR(3C), @@ -297,7 +293,6 @@ Profiler Proceedings of the SIGPLAN '82 Symposium on Compiler Construction\fR, .LP \fILinker and Libraries Guide\fR .SH NOTES -.sp .LP If the executable image has been stripped and does not have the \fB\&.symtab\fR symbol table, \fBgprof\fR reads the global dynamic symbol tables @@ -339,7 +334,6 @@ functions are not present in an unprofiled application, time accumulated and call counts for these functions may be ignored when evaluating the performance of an application. .SS "64-bit profiling" -.sp .LP 64-bit profiling may be used freely with dynamically linked executables, and profiling information is collected for the shared objects if the objects are @@ -353,7 +347,6 @@ appropriate module for the symbol. When using the \fB-s\fR or \fB-D\fRoption to sum multiple profile files, care must be taken not to mix 32-bit profile files with 64-bit profile files. .SS "32-bit profiling" -.sp .LP 32-bit profiling may be used with dynamically linked executables, but care must be applied. In 32-bit profiling, shared objects cannot be profiled with @@ -386,7 +379,6 @@ improvement can be made by looking at routine \fBB\fR and not routine \fBA\fR. The value of the profiler in this case is severely degraded; the solution is to use archives as much as possible for profiling. .SH BUGS -.sp .LP Parents which are not themselves profiled will have the time of their profiled children propagated to them, but they will appear to be spontaneously invoked diff --git a/usr/src/man/man1/ls.1 b/usr/src/man/man1/ls.1 index b1d58e81d3..37f60ebc87 100644 --- a/usr/src/man/man1/ls.1 +++ b/usr/src/man/man1/ls.1 @@ -394,7 +394,7 @@ For others permissions, the third position can be occupied by \fBt\fR or .SS "Color Output" .LP If color output is enabled, the environment variable LS_COLORS is checked. If -it exists, it's contents are used to control the colors used to display +it exists, its contents are used to control the colors used to display filenames. If it is not set, a default list of colors is used. The format of LS_COLORS is a colon separated list of attribute specifications. Each attribute specification is of the format diff --git a/usr/src/man/man1/pvs.1 b/usr/src/man/man1/pvs.1 index 9375613b36..b6ea0d52d8 100644 --- a/usr/src/man/man1/pvs.1 +++ b/usr/src/man/man1/pvs.1 @@ -1,5 +1,6 @@ '\" te .\" Copyright (c) 2008, Sun Microsystems, Inc. +.\" Copyright 2019 Joyent, Inc. .\" All Rights Reserved .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. @@ -14,7 +15,6 @@ pvs \- display the internal version information of dynamic objects .fi .SH DESCRIPTION -.sp .LP The \fBpvs\fR utility displays any internal version information contained within an \fBELF\fR file. Commonly, these files are dynamic executables and @@ -53,7 +53,6 @@ dynamic object being created. At process initialization, the runtime linker uses any version \fIdependencies\fR as a means of validating the interface requirements of the dynamic objects used to construct the process. .SH OPTIONS -.sp .LP The following options are supported. If neither the \fB-d\fR or \fB-r\fR options are specified, both are enabled. @@ -220,7 +219,6 @@ inheritance of the base version definition is also shown. When used with the .RE .SH OPERANDS -.sp .LP The following operands are supported. .sp @@ -234,7 +232,6 @@ The \fBELF\fR file about which internal version information is displayed. .SH USAGE .SS "Matching Options" -.sp .LP The \fB-I\fR and \fB-N\fR options are collectively referred to as the \fBmatching options\fR. These options are used to narrow the range of versions @@ -388,7 +385,6 @@ specify its name: .sp .SH EXIT STATUS -.sp .LP If the requested version information is not found, a non-zero value is returned. Otherwise, a \fB0\fR value is returned. @@ -415,7 +411,6 @@ neither the \fB-d\fR nor \fB-r\fR option is specified and no version definitions or version requirements are found. .RE .SH SEE ALSO -.sp .LP \fBelfdump\fR(1), \fBld\fR(1), \fBldd\fR(1), \fBstrip\fR(1), \fBelf\fR(3ELF), \fBattributes\fR(5) diff --git a/usr/src/pkg/manifests/system-test-utiltest.mf b/usr/src/pkg/manifests/system-test-utiltest.mf index fbfb38267b..caaab64b23 100644 --- a/usr/src/pkg/manifests/system-test-utiltest.mf +++ b/usr/src/pkg/manifests/system-test-utiltest.mf @@ -1448,5 +1448,7 @@ file path=opt/util-tests/tests/xargs_test mode=0555 license lic_CDDL license=lic_CDDL license usr/src/lib/libdemangle/THIRDPARTYLICENSE \ license=usr/src/lib/libdemangle/THIRDPARTYLICENSE +license usr/src/test/util-tests/tests/demangle/THIRDPARTYLICENSE.rust \ + license=usr/src/test/util-tests/tests/demangle/THIRDPARTYLICENSE.rust depend fmri=system/library/iconv/utf-8 type=require depend fmri=system/test/testrunner type=require diff --git a/usr/src/pkg/proto_list_ihv_i386 b/usr/src/pkg/proto_list_ihv_i386 deleted file mode 100644 index c4cba07150..0000000000 --- a/usr/src/pkg/proto_list_ihv_i386 +++ /dev/null @@ -1,41 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# -# -# proto_list file listing all realmode components installed in -# proto area by realmode builds. This is used for builds without -# realmode to append the proto list to compare against the -# reference (typically the gate's) proto list. -# -f kernel/drv/adp - 755 root sys 0 1 - - -f kernel/drv/adp.conf - 644 root sys 0 1 - - -f kernel/drv/cadp - 755 root sys 0 1 - - -f kernel/drv/cadp.conf - 644 root sys 0 1 - - -f kernel/drv/cpqhpc - 755 root sys 0 1 - - -f kernel/drv/cpqhpc.conf - 644 root sys 0 1 - - -f platform/i86pc/kernel/drv/amd64/cadp160 - 755 root sys 0 1 - - -f platform/i86pc/kernel/drv/cadp160 - 755 root sys 0 1 - - -f platform/i86pc/kernel/drv/cadp160.conf - 644 root sys 0 1 - - diff --git a/usr/src/test/util-tests/tests/demangle/Makefile b/usr/src/test/util-tests/tests/demangle/Makefile index f5522772db..18c2a25cb9 100644 --- a/usr/src/test/util-tests/tests/demangle/Makefile +++ b/usr/src/test/util-tests/tests/demangle/Makefile @@ -11,7 +11,7 @@ # # Copyright 2018 Jason King. -# Copyright 2019, Joyent, Inc. +# Copyright 2019 Joyent, Inc. # include $(SRC)/Makefile.master @@ -33,7 +33,8 @@ SRCS = $(OBJS:%.o=%.c) CSTD = $(CSTD_GNU99) -LDLIBS += -ldemangle-sys -lumem +LDLIBS += -ldemangle-sys +rust := LDLIBS += -lumem all: $(PROG) diff --git a/usr/src/test/util-tests/tests/demangle/THIRDPARTYLICENSE.rust b/usr/src/test/util-tests/tests/demangle/THIRDPARTYLICENSE.rust new file mode 100644 index 0000000000..39e0ed6602 --- /dev/null +++ b/usr/src/test/util-tests/tests/demangle/THIRDPARTYLICENSE.rust @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/usr/src/test/util-tests/tests/demangle/THIRDPARTYLICENSE.rust.descrip b/usr/src/test/util-tests/tests/demangle/THIRDPARTYLICENSE.rust.descrip new file mode 100644 index 0000000000..8b510416f8 --- /dev/null +++ b/usr/src/test/util-tests/tests/demangle/THIRDPARTYLICENSE.rust.descrip @@ -0,0 +1 @@ +Rust test case data diff --git a/usr/src/uts/common/Makefile.files b/usr/src/uts/common/Makefile.files index 48e7efb278..92f087c3ff 100644 --- a/usr/src/uts/common/Makefile.files +++ b/usr/src/uts/common/Makefile.files @@ -1239,6 +1239,10 @@ SMBSRV_OBJS += $(SMBSRV_SHARED_OBJS) \ smb2_create.o \ smb2_echo.o \ smb2_flush.o \ + smb2_fsctl_copychunk.o \ + smb2_fsctl_fs.o \ + smb2_fsctl_odx.o \ + smb2_fsctl_sparse.o \ smb2_ioctl.o \ smb2_lease.o \ smb2_lock.o \ diff --git a/usr/src/uts/common/fs/smbsrv/smb2_aapl.c b/usr/src/uts/common/fs/smbsrv/smb2_aapl.c index 1c2e3bfdf9..3deac16513 100644 --- a/usr/src/uts/common/fs/smbsrv/smb2_aapl.c +++ b/usr/src/uts/common/fs/smbsrv/smb2_aapl.c @@ -24,13 +24,17 @@ /* SMB2 AAPL extensions: enabled? */ int smb2_aapl_extensions = 1; -uint64_t smb2_aapl_server_caps = - kAAPL_SUPPORTS_READ_DIR_ATTR; - /* | kAAPL_SUPPORTS_OSX_COPYFILE; (not yet) */ - /* | kAAPL_UNIX_BASED; */ + /* - * We could turn on kAAPL_UNIX_BASED above and report UNIX modes in - * directory listings (see smb2_aapl_get_macinfo below) but don't + * smb2_aapl_server_caps is a flags word containing detailed + * capabilities as shown in smb2_aapl.h (kAPPL_...) + * + * We actually can support OSX_COPYFILE but modern MacOS clients + * work better using the plain old FSCTL_SRV_COPYCHUNK ioctl, which + * avoids our needing to handle all the meta-data and streams. + * + * We could turn on kAAPL_UNIX_BASED below and report UNIX modes in + * directory listings (see smb2_aapl_get_macinfo below) but we don't * because the modes ZFS presents with non-trivial ACLs cause mac * clients to misbehave when copying files from the share to local. * For example, we may have a file that we can read, but which has @@ -39,6 +43,10 @@ uint64_t smb2_aapl_server_caps = * kAAPL_UNIX_BASED flag. Later we might set this flag and return * modes only when we have a trivial ACL. */ +uint64_t smb2_aapl_server_caps = + kAAPL_SUPPORTS_READ_DIR_ATTR; + /* | kAAPL_SUPPORTS_OSX_COPYFILE */ + /* | kAAPL_UNIX_BASED; */ uint64_t smb2_aapl_volume_caps = kAAPL_SUPPORTS_FULL_SYNC; @@ -216,7 +224,7 @@ smb2_aapl_get_macinfo(smb_request_t *sr, smb_odir_t *od, uio.uio_resid = sizeof (AfpInfo); uio.uio_segflg = UIO_SYSSPACE; uio.uio_extflg = UIO_COPY_DEFAULT; - rc = smb_fsop_read(sr, kcr, snode, &uio); + rc = smb_fsop_read(sr, kcr, snode, NULL, &uio); if (rc == 0 && uio.uio_resid == 0) { bcopy(&AfpInfo[4], &mi->mi_finderinfo, sizeof (mi->mi_finderinfo)); diff --git a/usr/src/uts/common/fs/smbsrv/smb2_durable.c b/usr/src/uts/common/fs/smbsrv/smb2_durable.c index 981b09a28e..9ba3dd9c07 100644 --- a/usr/src/uts/common/fs/smbsrv/smb2_durable.c +++ b/usr/src/uts/common/fs/smbsrv/smb2_durable.c @@ -438,7 +438,7 @@ smb2_dh_shutdown(smb_server_t *sv) } uint32_t -smb2_fsctl_resiliency(smb_request_t *sr, smb_fsctl_t *fsctl) +smb2_fsctl_set_resilient(smb_request_t *sr, smb_fsctl_t *fsctl) { uint32_t timeout; smb_ofile_t *of = sr->fid_ofile; diff --git a/usr/src/uts/common/fs/smbsrv/smb2_fsctl_copychunk.c b/usr/src/uts/common/fs/smbsrv/smb2_fsctl_copychunk.c new file mode 100644 index 0000000000..4240328207 --- /dev/null +++ b/usr/src/uts/common/fs/smbsrv/smb2_fsctl_copychunk.c @@ -0,0 +1,503 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2018 Nexenta Systems, Inc. All rights reserved. + */ + +/* + * Support functions for smb2_ioctl/fsctl codes: + * FSCTL_SRV_COPYCHUNK + * FSCTL_SRV_COPYCHUNK_WRITE + * (and related) + */ + +#include <smbsrv/smb2_kproto.h> +#include <smbsrv/smb_fsops.h> +#include <smb/winioctl.h> + +typedef struct chunk { + uint64_t src_off; + uint64_t dst_off; + uint32_t length; + uint32_t _reserved; +} chunk_t; + +struct copychunk_resp { + uint32_t ChunksWritten; + uint32_t ChunkBytesWritten; + uint32_t TotalBytesWritten; +}; + +typedef struct copychunk_args { + smb_attr_t src_attr; + void *buffer; + size_t bufsize; + uint32_t ccnt; + chunk_t cvec[1]; /* actually longer */ +} copychunk_args_t; + +uint32_t smb2_copychunk_max_cnt = 256; +uint32_t smb2_copychunk_max_seg = (1<<20); /* 1M, == smb2_max_rwsize */ +uint32_t smb2_copychunk_max_total = (1<<24); /* 16M */ + +static uint32_t smb2_fsctl_copychunk_decode(smb_request_t *, mbuf_chain_t *); +static uint32_t smb2_fsctl_copychunk_array(smb_request_t *, smb_ofile_t *, + struct copychunk_resp *); +static uint32_t smb2_fsctl_copychunk_aapl(smb_request_t *, smb_ofile_t *, + struct copychunk_resp *); +static uint32_t smb2_fsctl_copychunk_1(smb_request_t *, smb_ofile_t *, + struct chunk *); +static int smb2_fsctl_copychunk_meta(smb_request_t *, smb_ofile_t *); + +/* + * FSCTL_SRV_COPYCHUNK + * FSCTL_SRV_COPYCHUNK_WRITE + * + * Copies from a source file identified by a "resume key" + * (previously returned by FSCTL_SRV_REQUEST_RESUME_KEY) + * to the file on which the ioctl is issues. + * + * The fsctl appears to _always_ respond with a data payload + * (struct copychunk_resp), even on fatal errors. Note that + * smb2_ioctl also has special handling to allow that. + */ +uint32_t +smb2_fsctl_copychunk(smb_request_t *sr, smb_fsctl_t *fsctl) +{ + struct copychunk_resp ccr; + smb_ofile_t *dst_of = sr->fid_ofile; + smb_ofile_t *src_of = NULL; + copychunk_args_t *args = NULL; + smb2fid_t smb2fid; + uint32_t status = NT_STATUS_INVALID_PARAMETER; + uint32_t desired_access; /* for dest */ + uint32_t chunk_cnt; + int rc; + boolean_t aapl_copyfile = B_FALSE; + + bzero(&ccr, sizeof (ccr)); + if (fsctl->MaxOutputResp < sizeof (ccr)) { + status = NT_STATUS_INVALID_PARAMETER; + goto out; + } + + /* + * Make sure dst_of is open on a regular file, and + * granted access is sufficient for this operation. + * FSCTL_SRV_COPYCHUNK requires READ+WRITE + * FSCTL_SRV_COPYCHUNK_WRITE just WRITE + */ + if (!smb_node_is_file(dst_of->f_node)) { + status = NT_STATUS_ACCESS_DENIED; + goto out; + } + desired_access = FILE_WRITE_DATA; + if (fsctl->CtlCode == FSCTL_SRV_COPYCHUNK) + desired_access |= FILE_READ_DATA; + status = smb_ofile_access(dst_of, dst_of->f_cr, desired_access); + if (status != NT_STATUS_SUCCESS) + goto out; + + /* + * Decode the resume key (src file ID) and length of the + * "chunks" array. Note the resume key is 24 bytes of + * opaque data from FSCTL_SRV_REQUEST_RESUME_KEY, but + * here know it's an smb2fid plus 8 bytes of padding. + */ + rc = smb_mbc_decodef( + fsctl->in_mbc, "qq8.l4.", + &smb2fid.persistent, /* q */ + &smb2fid.temporal, /* q */ + /* pad 8. */ + &chunk_cnt); /* l */ + /* reserved 4. */ + if (rc != 0) { + status = NT_STATUS_INVALID_PARAMETER; + goto out; + } + + /* + * Lookup the source ofile using the resume key, + * which smb2_fsctl_get_resume_key encoded as an + * smb2fid_t. Similar to smb2sr_lookup_fid(), + * but different error code. + */ + src_of = smb_ofile_lookup_by_fid(sr, (uint16_t)smb2fid.temporal); + if (src_of == NULL || + src_of->f_persistid != smb2fid.persistent) { + status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + goto out; + } + + /* + * Make sure src_of is open on a regular file, and + * granted access includes READ_DATA + */ + if (!smb_node_is_file(src_of->f_node)) { + status = NT_STATUS_ACCESS_DENIED; + goto out; + } + status = smb_ofile_access(src_of, src_of->f_cr, FILE_READ_DATA); + if (status != NT_STATUS_SUCCESS) + goto out; + + /* + * Before decoding the chunks array, check the size. Note: + * When we offer the AAPL extensions, MacOS clients assume + * they can use chunk_cnt==0 to mean "copy the whole file". + */ + if (chunk_cnt == 0) { + if ((sr->session->s_flags & SMB_SSN_AAPL_CCEXT) != 0) { + aapl_copyfile = B_TRUE; + } else { + status = NT_STATUS_INVALID_PARAMETER; + goto out; + } + } + if (chunk_cnt > smb2_copychunk_max_cnt) { + status = NT_STATUS_INVALID_PARAMETER; + goto out; + } + + /* + * Get some memory for the array of chunks and decode it. + * Also checks the per-chunk and total size limits. + * Note that chunk_cnt may be zero here (MacOS). + */ + args = smb_srm_zalloc(sr, sizeof (*args) + + (chunk_cnt * sizeof (args->cvec))); + args->ccnt = chunk_cnt; + sr->arg.other = args; + if (chunk_cnt > 0) { + status = smb2_fsctl_copychunk_decode(sr, fsctl->in_mbc); + if (status != 0) + goto out; + } + + /* + * Normally need just the source file size, etc. If doing + * Apple server-side copy, we want all the attributes. + */ + if (aapl_copyfile) + args->src_attr.sa_mask = SMB_AT_ALL; + else + args->src_attr.sa_mask = SMB_AT_STANDARD; + status = smb2_ofile_getattr(sr, src_of, &args->src_attr); + if (status != 0) + goto out; + + /* + * Get a buffer used for copying, always + * smb2_copychunk_max_seg (1M) + * + * Rather than sleep for this relatively large allocation, + * allow the allocation to fail and return an error. + * The client should then fall back to normal copy. + */ + args->bufsize = smb2_copychunk_max_seg; + args->buffer = kmem_alloc(args->bufsize, KM_NOSLEEP | KM_NORMALPRI); + if (args->buffer == NULL) { + status = NT_STATUS_INSUFF_SERVER_RESOURCES; + goto out; + } + + /* + * Finally, do the I/O + */ + if (aapl_copyfile) { + status = smb2_fsctl_copychunk_aapl(sr, src_of, &ccr); + } else { + status = smb2_fsctl_copychunk_array(sr, src_of, &ccr); + } + +out: + if (args != NULL) { + if (args->buffer != NULL) { + kmem_free(args->buffer, args->bufsize); + } + } + + if (src_of != NULL) + smb_ofile_release(src_of); + + if (status == NT_STATUS_INVALID_PARAMETER) { + /* + * Tell the client our max chunk cnt, size, etc. + */ + ccr.ChunksWritten = smb2_copychunk_max_cnt; + ccr.ChunkBytesWritten = smb2_copychunk_max_seg; + ccr.TotalBytesWritten = smb2_copychunk_max_total; + } + + /* Checked MaxOutputResp above, so ignore errors here */ + (void) smb_mbc_encodef( + fsctl->out_mbc, "lll", + ccr.ChunksWritten, + ccr.ChunkBytesWritten, + ccr.TotalBytesWritten); + + sr->arg.other = NULL; + /* smb_srm_fini will free args */ + + return (status); +} + +/* + * Decode the list of chunks and check each. + */ +static uint32_t +smb2_fsctl_copychunk_decode(smb_request_t *sr, mbuf_chain_t *mbc) +{ + copychunk_args_t *args = sr->arg.other; + chunk_t *cc; + uint32_t status = NT_STATUS_INVALID_PARAMETER; + uint32_t total_len = 0; + int i, rc; + + for (i = 0; i < args->ccnt; i++) { + cc = &args->cvec[i]; + rc = smb_mbc_decodef( + mbc, "qqll", + &cc->src_off, /* q */ + &cc->dst_off, /* q */ + &cc->length, /* l */ + &cc->_reserved); /* l */ + if (rc != 0 || cc->length == 0 || + cc->length > smb2_copychunk_max_seg) + goto out; + total_len += cc->length; + } + if (total_len > smb2_copychunk_max_total) + goto out; + status = 0; + +out: + return (status); +} + +/* + * Run the actual I/O described by the copychunks array. + * (normal, non-apple case) + */ +static uint32_t +smb2_fsctl_copychunk_array(smb_request_t *sr, smb_ofile_t *src_of, + struct copychunk_resp *ccr) +{ + copychunk_args_t *args = sr->arg.other; + chunk_t *cc; + uint64_t src_size = args->src_attr.sa_vattr.va_size; + uint32_t save_len; + uint32_t copied; + uint32_t status = 0; + int i; + + for (i = 0; i < args->ccnt; i++) { + cc = &args->cvec[i]; + + /* Chunk must be entirely within file bounds. */ + if (cc->src_off > src_size || + (cc->src_off + cc->length) < cc->src_off || + (cc->src_off + cc->length) > src_size) { + status = NT_STATUS_INVALID_VIEW_SIZE; + goto out; + } + + save_len = cc->length; + status = smb2_fsctl_copychunk_1(sr, src_of, cc); + if (status != 0) { + /* no part of this chunk written */ + break; + } + /* + * All or part of the chunk written. + * cc->length is now the resid count. + */ + copied = save_len - cc->length; + ccr->TotalBytesWritten += copied; + if (cc->length != 0) { + /* Did not write the whole chunk */ + ccr->ChunkBytesWritten = copied; + break; + } + /* Whole chunk moved. */ + ccr->ChunksWritten++; + } + if (ccr->ChunksWritten > 0) + status = NT_STATUS_SUCCESS; + +out: + return (status); +} + +/* + * Helper for smb2_fsctl_copychunk, where MacOS uses chunk_cnt==0 + * to mean "copy the whole file". This interface does not have any + * way to report a partial copy (client ignores copychunk_resp) so + * if that happens we just report an error. + * + * This extension makes no provision for the server to impose any + * bound on the amount of data moved by one SMB copychunk request. + * We could impose a total size, but it's hard to know what size + * would be an appropriate limit because performance of various + * storage subsystems can vary quite a bit. The best we can do is + * limit the time we spend in this copy, and allow cancellation. + */ +int smb2_fsctl_copychunk_aapl_timeout = 10; /* sec */ +static uint32_t +smb2_fsctl_copychunk_aapl(smb_request_t *sr, smb_ofile_t *src_of, + struct copychunk_resp *ccr) +{ + copychunk_args_t *args = sr->arg.other; + chunk_t *cc = args->cvec; /* always at least one element */ + uint64_t src_size = args->src_attr.sa_vattr.va_size; + uint64_t off; + uint32_t xfer; + uint32_t status = 0; + hrtime_t end_time = sr->sr_time_active + + (smb2_fsctl_copychunk_aapl_timeout * NANOSEC); + + off = 0; + while (off < src_size) { + /* + * Check that (a) the request has not been cancelled, + * and (b) we've not run past the timeout. + */ + if (sr->sr_state != SMB_REQ_STATE_ACTIVE) + return (NT_STATUS_CANCELLED); + if (gethrtime() > end_time) + return (NT_STATUS_IO_TIMEOUT); + + xfer = smb2_copychunk_max_seg; + if (off + xfer > src_size) + xfer = (uint32_t)(src_size - off); + cc->src_off = off; + cc->dst_off = off; + cc->length = xfer; + status = smb2_fsctl_copychunk_1(sr, src_of, cc); + if (status != 0) + break; + if (cc->length != 0) { + status = NT_STATUS_PARTIAL_COPY; + break; + } + /* + * Whole chunk moved. It appears that MacOS clients + * ignore the response here, but let's put something + * meaningful in it anyway, so one can see how far + * the copy went by looking at a network trace. + */ + ccr->TotalBytesWritten += xfer; + ccr->ChunksWritten++; + off += xfer; + } + + /* + * MacOS servers also copy meta-data from the old to new file. + * We need to do this because Finder does not set the meta-data + * when copying a file with this interface. If we fail to copy + * the meta-data, just log. We'd rather not fail the entire + * copy job if this fails. + */ + if (status == 0) { + int rc = smb2_fsctl_copychunk_meta(sr, src_of); + if (rc != 0) { + cmn_err(CE_NOTE, "smb2 copychunk meta, rc=%d", rc); + } + } + + return (status); +} + +/* + * Helper for Apple copychunk, to copy meta-data + */ +static int +smb2_fsctl_copychunk_meta(smb_request_t *sr, smb_ofile_t *src_of) +{ + smb_fssd_t fs_sd; + copychunk_args_t *args = sr->arg.other; + smb_ofile_t *dst_of = sr->fid_ofile; + uint32_t sd_flags = 0; + uint32_t secinfo = SMB_DACL_SECINFO; + int error; + + /* + * Copy attributes. We obtained SMB_AT_ALL above. + * Now correct the mask for what's settable. + */ + args->src_attr.sa_mask = SMB_AT_MODE | SMB_AT_SIZE | + SMB_AT_ATIME | SMB_AT_MTIME | SMB_AT_CTIME | + SMB_AT_DOSATTR | SMB_AT_ALLOCSZ; + error = smb_node_setattr(sr, dst_of->f_node, sr->user_cr, + dst_of, &args->src_attr); + if (error != 0) + return (error); + + /* + * Copy the ACL. Unfortunately, the ofiles used by the Mac + * here don't generally have WRITE_DAC access (sigh) so we + * have to bypass ofile access checks for this operation. + * The file-system level still does its access checking. + */ + smb_fssd_init(&fs_sd, secinfo, sd_flags); + sr->fid_ofile = NULL; + error = smb_fsop_sdread(sr, sr->user_cr, src_of->f_node, &fs_sd); + if (error == 0) { + error = smb_fsop_sdwrite(sr, sr->user_cr, dst_of->f_node, + &fs_sd, 1); + } + sr->fid_ofile = dst_of; + smb_fssd_term(&fs_sd); + + return (error); +} + +/* + * Copy one chunk from src_of to sr->fid_ofile, + * with offsets and length from chunk *cc + */ +static uint32_t +smb2_fsctl_copychunk_1(smb_request_t *sr, smb_ofile_t *src_ofile, + struct chunk *cc) +{ + copychunk_args_t *args = sr->arg.other; + smb_ofile_t *dst_ofile = sr->fid_ofile; + uint32_t status; + + if (cc->length > args->bufsize) + return (NT_STATUS_INTERNAL_ERROR); + + /* + * Check for lock conflicting with the read. + */ + status = smb_lock_range_access(sr, src_ofile->f_node, + cc->src_off, cc->length, B_FALSE); + if (status != 0) + return (status); + + /* + * Check for lock conflicting with the write. + */ + status = smb_lock_range_access(sr, dst_ofile->f_node, + cc->dst_off, cc->length, B_TRUE); + if (status != 0) + return (status); + + /* + * Copy src to dst for cc->length + */ + status = smb2_sparse_copy(sr, src_ofile, dst_ofile, + cc->src_off, cc->dst_off, &cc->length, + args->buffer, args->bufsize); + + return (status); +} diff --git a/usr/src/uts/common/fs/smbsrv/smb2_fsctl_fs.c b/usr/src/uts/common/fs/smbsrv/smb2_fsctl_fs.c new file mode 100644 index 0000000000..829beda2e4 --- /dev/null +++ b/usr/src/uts/common/fs/smbsrv/smb2_fsctl_fs.c @@ -0,0 +1,227 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2018 Nexenta Systems, Inc. All rights reserved. + */ + +/* + * Support functions for smb2_ioctl/fsctl categories: + * FILE_DEVICE_FILE_SYSTEM (9) + * FILE_DEVICE_NETWORK_FILE_SYSTEM (20) + */ + +#include <smbsrv/smb2_kproto.h> +#include <smbsrv/smb_fsops.h> +#include <smb/winioctl.h> + +/* ARGSUSED */ +static uint32_t +smb2_fsctl_notsup(smb_request_t *sr, smb_fsctl_t *fsctl) +{ + return (NT_STATUS_NOT_SUPPORTED); +} + +/* + * Same as smb2_fsctl_notsup, but make some noise (if DEBUG) + * so we'll learn about new fsctl codes clients start using. + */ +/* ARGSUSED */ +static uint32_t +smb2_fsctl_unknown(smb_request_t *sr, smb_fsctl_t *fsctl) +{ +#ifdef DEBUG + cmn_err(CE_NOTE, "smb2_fsctl_unknown: code 0x%x", fsctl->CtlCode); +#endif + return (NT_STATUS_NOT_SUPPORTED); +} + +/* + * FSCTL_GET_COMPRESSION + */ +static uint32_t +smb2_fsctl_get_compression(smb_request_t *sr, smb_fsctl_t *fsctl) +{ + _NOTE(ARGUNUSED(sr)) + uint16_t compress_state = 0; + + (void) smb_mbc_encodef(fsctl->in_mbc, "w", + compress_state); + + return (NT_STATUS_SUCCESS); +} + +/* + * FSCTL_SET_COMPRESSION + */ +static uint32_t +smb2_fsctl_set_compression(smb_request_t *sr, smb_fsctl_t *fsctl) +{ + _NOTE(ARGUNUSED(sr)) + + uint16_t compress_state; + (void) smb_mbc_decodef(fsctl->in_mbc, "w", + &compress_state); + + if (compress_state > 0) + return (NT_STATUS_COMPRESSION_DISABLED); + + return (NT_STATUS_SUCCESS); +} + +/* + * FSCTL_SRV_REQUEST_RESUME_KEY + * + * The returned data is an (opaque to the client) 24-byte blob + * in which we stash the SMB2 "file ID" (both parts). Later, + * copychunk may lookup the ofile using that file ID. + * See: smb2_fsctl_copychunk() + * + * Note that Mac clients make this request on a directory + * (even though this only makes sense on a file) just to + * find out if the server supports server-side copy. + * There's no harm letting a client have a resume key + * for a directory. They'll never be able to DO anything + * with it because we check for a plain file later. + */ +static uint32_t +smb2_fsctl_get_resume_key(smb_request_t *sr, smb_fsctl_t *fsctl) +{ + smb_ofile_t *of = sr->fid_ofile; + smb2fid_t smb2fid; + + /* Caller makes sure we have of = sr->fid_ofile */ + /* Don't insist on a plain file (see above). */ + + smb2fid.persistent = of->f_persistid; + smb2fid.temporal = of->f_fid; + + (void) smb_mbc_encodef( + fsctl->out_mbc, "qq16.", + smb2fid.persistent, + smb2fid.temporal); + + return (NT_STATUS_SUCCESS); +} + +/* + * FILE_DEVICE_FILE_SYSTEM (9) + */ +uint32_t +smb2_fsctl_fs(smb_request_t *sr, smb_fsctl_t *fsctl) +{ + uint32_t (*func)(smb_request_t *, smb_fsctl_t *); + uint32_t status; + + switch (fsctl->CtlCode) { + case FSCTL_GET_COMPRESSION: /* 15 */ + func = smb2_fsctl_get_compression; + break; + case FSCTL_SET_COMPRESSION: /* 16 */ + func = smb2_fsctl_set_compression; + break; + case FSCTL_SET_REPARSE_POINT: /* 41 */ + case FSCTL_GET_REPARSE_POINT: /* 42 */ + case FSCTL_CREATE_OR_GET_OBJECT_ID: /* 48 */ + func = smb2_fsctl_notsup; + break; + case FSCTL_SET_SPARSE: /* 49 */ + func = smb2_fsctl_set_sparse; + break; + case FSCTL_SET_ZERO_DATA: /* 50 */ + func = smb2_fsctl_set_zero_data; + break; + case FSCTL_QUERY_ALLOCATED_RANGES: /* 51 */ + func = smb2_fsctl_query_alloc_ranges; + break; + case FSCTL_FILE_LEVEL_TRIM: /* 130 */ + func = smb2_fsctl_notsup; + break; + case FSCTL_OFFLOAD_READ: /* 153 */ + func = smb2_fsctl_odx_read; + break; + case FSCTL_OFFLOAD_WRITE: /* 154 */ + func = smb2_fsctl_odx_write; + break; + case FSCTL_SET_INTEGRITY_INFORMATION: /* 160 */ + func = smb2_fsctl_notsup; + break; + case FSCTL_QUERY_FILE_REGIONS: /* 161 */ + func = smb2_fsctl_query_file_regions; + break; + + default: + func = smb2_fsctl_unknown; + break; + } + + /* + * All "fs" sub-codes require a disk file. + */ + if (sr->fid_ofile == NULL || + !SMB_FTYPE_IS_DISK(sr->fid_ofile->f_ftype)) + return (NT_STATUS_INVALID_PARAMETER); + + status = (*func)(sr, fsctl); + return (status); +} + +/* + * FILE_DEVICE_NETWORK_FILE_SYSTEM (20) + */ +uint32_t +smb2_fsctl_netfs(smb_request_t *sr, smb_fsctl_t *fsctl) +{ + uint32_t (*func)(smb_request_t *, smb_fsctl_t *); + uint32_t status; + boolean_t need_disk_file = B_TRUE; + + switch (fsctl->CtlCode) { + case FSCTL_SRV_ENUMERATE_SNAPSHOTS: /* 0x19 */ + func = smb_vss_enum_snapshots; + break; + case FSCTL_SRV_REQUEST_RESUME_KEY: /* 0x1e */ + func = smb2_fsctl_get_resume_key; + break; + case FSCTL_SRV_COPYCHUNK: /* 0x3c(r) */ + case FSCTL_SRV_COPYCHUNK_WRITE: /* 0x3c(w) */ + func = smb2_fsctl_copychunk; + break; + case FSCTL_SRV_READ_HASH: /* 0x6e */ + func = smb2_fsctl_notsup; + break; + case FSCTL_LMR_REQUEST_RESILIENCY: /* 0x75 */ + func = smb2_fsctl_set_resilient; + break; + case FSCTL_QUERY_NETWORK_INTERFACE_INFO: /* 0x7f */ + need_disk_file = B_FALSE; + func = smb2_fsctl_notsup; + break; + case FSCTL_VALIDATE_NEGOTIATE_INFO: /* 0x81 */ + need_disk_file = B_FALSE; + func = smb2_nego_validate; + break; + default: + func = smb2_fsctl_unknown; + break; + } + + /* + * Most "net fs" sub-codes require a disk file, + * except a couple that clear need_disk_file. + */ + if (need_disk_file && (sr->fid_ofile == NULL || + !SMB_FTYPE_IS_DISK(sr->fid_ofile->f_ftype))) + return (NT_STATUS_INVALID_PARAMETER); + + status = (*func)(sr, fsctl); + return (status); +} diff --git a/usr/src/uts/common/fs/smbsrv/smb2_fsctl_odx.c b/usr/src/uts/common/fs/smbsrv/smb2_fsctl_odx.c new file mode 100644 index 0000000000..0452cddb39 --- /dev/null +++ b/usr/src/uts/common/fs/smbsrv/smb2_fsctl_odx.c @@ -0,0 +1,847 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2018 Nexenta Systems, Inc. All rights reserved. + */ + +/* + * Support functions for smb2_ioctl/fsctl codes: + * FSCTL_SRV_OFFLOAD_READ + * FSCTL_SRV_OFFLOAD_WRITE + * (and related) + */ + +#include <smbsrv/smb2_kproto.h> +#include <smbsrv/smb_fsops.h> +#include <smb/winioctl.h> + +/* + * Summary of how offload data transfer works: + * + * The client drives a server-side copy. Outline: + * 1: open src_file + * 2: create dst_file and set its size + * 3: while src_file not all copied { + * offload_read(src_file, &token); + * while token not all copied { + * offload_write(dst_file, token); + * } + * } + * + * Each "offload read" request returns a "token" representing some + * portion of the source file. The server decides what kind of + * token to use, and how much of the source file it should cover. + * The length represented may be less then the client requested. + * No data are copied during offload_read (just meta-data). + * + * Each "offload write" request copies some portion of the data + * represented by the "token" into the output file. The amount + * of data copied may be less than the client requested, and the + * client keeps sending offload write requests until they have + * copied all the data represented by the current token. + */ + +/* [MS-FSA] OFFLOAD_READ_FLAG_ALL_ZERO_BEYOND_CURRENT_RANGE */ +#define OFFLOAD_READ_FLAG_ALL_ZERO_BEYOND 1 + +/* + * [MS-FSCC] 2.3.79 STORAGE_OFFLOAD_TOKEN + * Note reserved: 0xFFFF0002 – 0xFFFFFFFF + * + * ...TOKEN_TYPE_ZERO_DATA: A well-known Token that indicates ... + * (offload write should just zero to the destination) + * The payload (tok_other) is ignored with this type. + */ +#define STORAGE_OFFLOAD_TOKEN_TYPE_ZERO_DATA 0xFFFF0001 + +/* Our vendor-specific token type: struct tok_native1 */ +#define STORAGE_OFFLOAD_TOKEN_TYPE_NATIVE1 0x10001 + +#define TOKEN_TOTAL_SIZE 512 +#define TOKEN_MAX_PAYLOAD 504 /* 512 - 8 */ + +/* This mask is for sanity checking offsets etc. */ +#define OFFMASK ((uint64_t)DEV_BSIZE-1) + +typedef struct smb_odx_token { + uint32_t tok_type; /* big-endian on the wire */ + uint16_t tok_reserved; /* zero */ + uint16_t tok_len; /* big-endian on the wire */ + union { + uint8_t u_tok_other[TOKEN_MAX_PAYLOAD]; + struct tok_native1 { + smb2fid_t tn1_fid; + uint64_t tn1_off; + uint64_t tn1_eof; + } u_tok_native1; + } tok_u; +} smb_odx_token_t; + +typedef struct odx_write_args { + uint32_t in_struct_size; + uint32_t in_flags; + uint64_t in_dstoff; + uint64_t in_xlen; + uint64_t in_xoff; + uint32_t out_struct_size; + uint32_t out_flags; + uint64_t out_xlen; + uint64_t wa_eof; +} odx_write_args_t; + +static int smb_odx_get_token(mbuf_chain_t *, smb_odx_token_t *); +static int smb_odx_get_token_native1(mbuf_chain_t *, struct tok_native1 *); +static int smb_odx_put_token(mbuf_chain_t *, smb_odx_token_t *); +static int smb_odx_put_token_native1(mbuf_chain_t *, struct tok_native1 *); + +static uint32_t smb2_fsctl_odx_write_zeros(smb_request_t *, odx_write_args_t *); +static uint32_t smb2_fsctl_odx_write_native1(smb_request_t *, + odx_write_args_t *, smb_odx_token_t *); + + +/* We can disable this feature for testing etc. */ +int smb2_odx_enable = 1; + +/* + * These two variables determine the intervals of offload_read and + * offload_write calls (respectively) during an offload copy. + * + * For the offload read token we could offer a token representing + * the whole file, but we'll have the client come back for a new + * "token" after each 256M so we have a chance to look for "holes". + * This lets us use the special "zero" token while we're in any + * un-allocated parts of the file, so offload_write can use the + * (more efficient) smb_fsop_freesp instead of copying. + * + * We limit the size of offload_write to 16M per request so we + * don't end up taking so long with I/O that the client might + * time out the request. Keep: write_max <= read_max + */ +uint32_t smb2_odx_read_max = (1<<28); /* 256M */ +uint32_t smb2_odx_write_max = (1<<24); /* 16M */ + +/* + * This buffer size determines the I/O size for the copy during + * offoad write, where it will read/write using this buffer. + * Note: We kmem_alloc this, so don't make it HUGE. It only + * needs to be large enough to allow the copy to proceed with + * reasonable efficiency. 1M is currently the largest possible + * block size with ZFS, so that's what we'll use here. + */ +uint32_t smb2_odx_buf_size = (1<<20); /* 1M */ + + +/* + * FSCTL_OFFLOAD_READ + * [MS-FSCC] 2.3.77 + * + * Similar (in concept) to FSCTL_SRV_REQUEST_RESUME_KEY + * + * The returned data is an (opaque to the client) 512-byte "token" + * that represents the specified range (offset, length) of the + * source file. The "token" we return here comes back to us in an + * FSCTL_OFFLOAD_READ. We must stash whatever we'll need then in + * the token we return here. + * + * We want server-side copy to be able to copy "holes" efficiently, + * but would rather avoid the complexity of encoding a list of all + * allocated ranges into our returned token, so this compromise: + * + * When the current range is entirely within a "hole", we'll return + * the special "zeros" token, and the offload write using that token + * will use the simple and very efficient smb_fsop_freesp. In this + * scenario, we'll have a copy stride of smb2_odx_read_max (256M). + * + * When there's any data in the range to copy, we'll return our + * "native" token, and the subsequent offload_write will walk the + * allocated ranges copying and/or zeroing as needed. In this + * scenario, we'll have a copy stride of smb2_odx_write_max (16M). + * + * One additional optimization allowed by the protocol is that when + * we discover that there's no more data after the current range, + * we can set the flag ..._ALL_ZERO_BEYOND which tells that client + * they can stop copying here if they like. + */ +uint32_t +smb2_fsctl_odx_read(smb_request_t *sr, smb_fsctl_t *fsctl) +{ + smb_attr_t src_attr; + smb_odx_token_t *tok = NULL; + struct tok_native1 *tn1; + smb_ofile_t *ofile = sr->fid_ofile; + uint64_t src_size, src_rnd_size; + off64_t data, hole; + uint32_t in_struct_size; + uint32_t in_flags; + uint32_t in_ttl; + uint64_t in_file_off; + uint64_t in_copy_len; + uint64_t out_xlen; + uint32_t out_struct_size = TOKEN_TOTAL_SIZE + 16; + uint32_t out_flags = 0; + uint32_t status; + uint32_t tok_type; + int rc; + + if (smb2_odx_enable == 0) + return (NT_STATUS_NOT_SUPPORTED); + + /* + * Make sure the (src) ofile granted access allows read. + * [MS-FSA] didn't mention this, so it's not clear where + * this should happen relative to other checks. Usually + * access checks happen early. + */ + status = smb_ofile_access(ofile, ofile->f_cr, FILE_READ_DATA); + if (status != NT_STATUS_SUCCESS) + return (status); + + /* + * Decode FSCTL_OFFLOAD_READ_INPUT struct, + * and do in/out size checks. + */ + rc = smb_mbc_decodef( + fsctl->in_mbc, "lll4.qq", + &in_struct_size, /* l */ + &in_flags, /* l */ + &in_ttl, /* l */ + /* reserved 4. */ + &in_file_off, /* q */ + &in_copy_len); /* q */ + if (rc != 0) + return (NT_STATUS_BUFFER_TOO_SMALL); + if (fsctl->MaxOutputResp < out_struct_size) + return (NT_STATUS_BUFFER_TOO_SMALL); + + /* + * More arg checking per MS-FSA + */ + if ((in_file_off & OFFMASK) != 0 || + (in_copy_len & OFFMASK) != 0) + return (NT_STATUS_INVALID_PARAMETER); + if (in_struct_size != 32) + return (NT_STATUS_INVALID_PARAMETER); + if (in_file_off > INT64_MAX || + (in_file_off + in_copy_len) < in_file_off) + return (NT_STATUS_INVALID_PARAMETER); + + /* + * [MS-FSA] (summarizing) + * If not data stream, or if sparse, encrypted, compressed... + * return STATUS_OFFLOAD_READ_FILE_NOT_SUPPORTED. + * + * We'll ignore most of those except to require: + * Plain file, not a stream. + */ + if (!smb_node_is_file(ofile->f_node)) + return (NT_STATUS_OFFLOAD_READ_FILE_NOT_SUPPORTED); + if (SMB_IS_STREAM(ofile->f_node)) + return (NT_STATUS_OFFLOAD_READ_FILE_NOT_SUPPORTED); + + /* + * [MS-FSA] If Open.Stream.IsDeleted ... + * We don't really have this. + */ + + /* + * If CopyLength == 0, "return immediately success". + */ + if (in_copy_len == 0) { + out_xlen = 0; + tok_type = STORAGE_OFFLOAD_TOKEN_TYPE_ZERO_DATA; + goto done; + } + + /* + * Check for lock conflicting with the read. + */ + status = smb_lock_range_access(sr, ofile->f_node, + in_file_off, in_copy_len, B_FALSE); + if (status != 0) + return (status); /* == FILE_LOCK_CONFLICT */ + + /* + * Get the file size (rounded to a full block) + * and check the requested offset. + */ + bzero(&src_attr, sizeof (src_attr)); + src_attr.sa_mask = SMB_AT_SIZE; + status = smb2_ofile_getattr(sr, ofile, &src_attr); + if (status != NT_STATUS_SUCCESS) + return (status); + src_size = src_attr.sa_vattr.va_size; + if (in_file_off >= src_size) + return (NT_STATUS_END_OF_FILE); + + /* + * Limit the transfer length based on (rounded) EOF. + * Clients expect ranges of whole disk blocks. + * If we get a read in this rounded-up range, + * we'll supply zeros. + */ + src_rnd_size = (src_size + OFFMASK) & ~OFFMASK; + out_xlen = in_copy_len; + if ((in_file_off + out_xlen) > src_rnd_size) + out_xlen = src_rnd_size - in_file_off; + + /* + * Also, have the client come back for a new token after every + * smb2_odx_read_max bytes, so we'll have opportunities to + * recognize "holes" in the source file. + */ + if (out_xlen > smb2_odx_read_max) + out_xlen = smb2_odx_read_max; + + /* + * Ask the filesystem if there are any allocated regions in + * the requested range, and return either the "zeros" token + * or our "native" token as appropriate (details above). + */ + data = in_file_off; + tok_type = STORAGE_OFFLOAD_TOKEN_TYPE_NATIVE1; + rc = smb_fsop_next_alloc_range(ofile->f_cr, ofile->f_node, + &data, &hole); + switch (rc) { + case 0: + /* Found some data. Is it beyond this range? */ + if (data >= (in_file_off + out_xlen)) + tok_type = STORAGE_OFFLOAD_TOKEN_TYPE_ZERO_DATA; + break; + case ENXIO: + /* No data here or following. */ + tok_type = STORAGE_OFFLOAD_TOKEN_TYPE_ZERO_DATA; + out_flags |= OFFLOAD_READ_FLAG_ALL_ZERO_BEYOND; + break; + case ENOSYS: /* FS does not support VOP_IOCTL... */ + case ENOTTY: /* ... or _FIO_SEEK_DATA, _HOLE */ + break; + default: + cmn_err(CE_NOTE, "smb_fsop_next_alloc_range: rc=%d", rc); + break; + } + +done: + /* Already checked MaxOutputResp */ + (void) smb_mbc_encodef( + fsctl->out_mbc, "llq", + out_struct_size, /* l */ + out_flags, /* l */ + out_xlen); /* q */ + + /* + * Build the ODX token to return + */ + tok = smb_srm_zalloc(sr, sizeof (*tok)); + tok->tok_type = tok_type; + tok->tok_reserved = 0; + if (tok_type == STORAGE_OFFLOAD_TOKEN_TYPE_NATIVE1) { + tok->tok_len = sizeof (*tn1); + tn1 = &tok->tok_u.u_tok_native1; + tn1->tn1_fid.persistent = ofile->f_persistid; + tn1->tn1_fid.temporal = ofile->f_fid; + tn1->tn1_off = in_file_off; + tn1->tn1_eof = src_size; + } + + rc = smb_odx_put_token(fsctl->out_mbc, tok); + if (rc != 0) + return (NT_STATUS_BUFFER_TOO_SMALL); + + return (NT_STATUS_SUCCESS); +} + +/* + * FSCTL_SRV_OFFLOAD_WRITE + * [MS-FSCC] 2.3.80 + * + * Similar (in concept) to FSCTL_COPYCHUNK_WRITE + * + * Copies from a source file identified by a "token" + * (previously returned by FSCTL_OFFLOAD_READ) + * to the file on which the ioctl is issued. + */ +uint32_t +smb2_fsctl_odx_write(smb_request_t *sr, smb_fsctl_t *fsctl) +{ + smb_attr_t dst_attr; + odx_write_args_t args; + smb_odx_token_t *tok = NULL; + smb_ofile_t *ofile = sr->fid_ofile; + uint64_t dst_rnd_size; + uint32_t status = NT_STATUS_INVALID_PARAMETER; + int rc; + + bzero(&args, sizeof (args)); + args.out_struct_size = 16; + + if (smb2_odx_enable == 0) + return (NT_STATUS_NOT_SUPPORTED); + + /* + * Make sure the (dst) ofile granted_access allows write. + * [MS-FSA] didn't mention this, so it's not clear where + * this should happen relative to other checks. Usually + * access checks happen early. + */ + status = smb_ofile_access(ofile, ofile->f_cr, FILE_WRITE_DATA); + if (status != NT_STATUS_SUCCESS) + return (status); + + /* + * Decode FSCTL_OFFLOAD_WRITE_INPUT struct, + * and do in/out size checks. + */ + rc = smb_mbc_decodef( + fsctl->in_mbc, "llqqq", + &args.in_struct_size, /* l */ + &args.in_flags, /* l */ + &args.in_dstoff, /* q */ + &args.in_xlen, /* q */ + &args.in_xoff); /* q */ + if (rc != 0) + return (NT_STATUS_BUFFER_TOO_SMALL); + tok = smb_srm_zalloc(sr, sizeof (*tok)); + rc = smb_odx_get_token(fsctl->in_mbc, tok); + if (rc != 0) + return (NT_STATUS_BUFFER_TOO_SMALL); + if (fsctl->MaxOutputResp < args.out_struct_size) + return (NT_STATUS_BUFFER_TOO_SMALL); + + /* + * More arg checking per MS-FSA + */ + if ((args.in_dstoff & OFFMASK) != 0 || + (args.in_xoff & OFFMASK) != 0 || + (args.in_xlen & OFFMASK) != 0) + return (NT_STATUS_INVALID_PARAMETER); + if (args.in_struct_size != (TOKEN_TOTAL_SIZE + 32)) + return (NT_STATUS_INVALID_PARAMETER); + if (args.in_dstoff > INT64_MAX || + (args.in_dstoff + args.in_xlen) < args.in_dstoff) + return (NT_STATUS_INVALID_PARAMETER); + + /* + * If CopyLength == 0, "return immediately success". + */ + if (args.in_xlen == 0) { + status = 0; + goto done; + } + + /* + * [MS-FSA] (summarizing) + * If not data stream, or if sparse, encrypted, compressed... + * return STATUS_OFFLOAD_WRITE_FILE_NOT_SUPPORTED. + * + * We'll ignore most of those except to require: + * Plain file, not a stream. + */ + if (!smb_node_is_file(ofile->f_node)) + return (NT_STATUS_OFFLOAD_WRITE_FILE_NOT_SUPPORTED); + if (SMB_IS_STREAM(ofile->f_node)) + return (NT_STATUS_OFFLOAD_WRITE_FILE_NOT_SUPPORTED); + + /* + * [MS-FSA] If Open.Stream.IsDeleted ... + * We don't really have such a thing. + * Also skip Volume.MaxFileSize check. + */ + + /* + * Check for lock conflicting with the write. + */ + status = smb_lock_range_access(sr, ofile->f_node, + args.in_dstoff, args.in_xlen, B_TRUE); + if (status != 0) + return (status); /* == FILE_LOCK_CONFLICT */ + + /* + * Need the file size + */ + bzero(&dst_attr, sizeof (dst_attr)); + dst_attr.sa_mask = SMB_AT_SIZE; + status = smb2_ofile_getattr(sr, ofile, &dst_attr); + if (status != NT_STATUS_SUCCESS) + return (status); + args.wa_eof = dst_attr.sa_vattr.va_size; + dst_rnd_size = (args.wa_eof + OFFMASK) & ~OFFMASK; + + /* + * Destination offset vs. EOF + */ + if (args.in_dstoff >= args.wa_eof) + return (NT_STATUS_END_OF_FILE); + + /* + * Destination offset+len vs. EOF + * + * The spec. is silent about copying when the file length is + * not block aligned, but clients appear to ask us to copy a + * range that's rounded up to a block size. We'll limit the + * transfer size to the rounded up file size, but the actual + * copy will stop at EOF (args.wa_eof). + */ + if ((args.in_dstoff + args.in_xlen) > dst_rnd_size) + args.in_xlen = dst_rnd_size - args.in_dstoff; + + /* + * Finally, run the I/O + */ + switch (tok->tok_type) { + case STORAGE_OFFLOAD_TOKEN_TYPE_ZERO_DATA: + status = smb2_fsctl_odx_write_zeros(sr, &args); + break; + case STORAGE_OFFLOAD_TOKEN_TYPE_NATIVE1: + status = smb2_fsctl_odx_write_native1(sr, &args, tok); + break; + default: + status = NT_STATUS_INVALID_TOKEN; + break; + } + +done: + /* + * Checked MaxOutputResp above, so we can ignore errors + * from mbc_encodef here. + */ + if (status == NT_STATUS_SUCCESS) { + (void) smb_mbc_encodef( + fsctl->out_mbc, "llq", + args.out_struct_size, + args.out_flags, + args.out_xlen); + } + + return (status); +} + +/* + * Handle FSCTL_OFFLOAD_WRITE with token type + * STORAGE_OFFLOAD_TOKEN_TYPE_ZERO_DATA + * + * In this handler, the "token" represents a source of zeros. + */ +static uint32_t +smb2_fsctl_odx_write_zeros(smb_request_t *sr, odx_write_args_t *args) +{ + smb_ofile_t *dst_ofile = sr->fid_ofile; + uint64_t xlen = args->in_xlen; + uint32_t status = 0; + int rc; + + ASSERT(args->in_xlen > 0); + + /* + * Limit the I/O size. In here we're just doing freesp, + * which is assumed to require only meta-data I/O, so + * we'll allow up to smb2_odx_read_max (256M) per call. + * This is essentially just a double-check of the range + * we gave the client at the offload_read call, making + * sure they can't use a zero token for longer ranges + * than offload_read would allow. + */ + if (xlen > smb2_odx_read_max) + xlen = smb2_odx_read_max; + + /* + * Also limit to the actual file size, which may be + * smaller than the (block-aligned) transfer size. + * Report the rounded up size to the caller at EOF. + */ + args->out_xlen = xlen; + if ((args->in_dstoff + xlen) > args->wa_eof) + xlen = args->wa_eof - args->in_dstoff; + + /* + * Arrange for zeros to appear in the range: + * in_dstoff, (in_dstoff + in_xlen) + * + * Just "free" the range and let it allocate as needed + * when someone later writes in this range. + */ + rc = smb_fsop_freesp(sr, dst_ofile->f_cr, dst_ofile, + args->in_dstoff, xlen); + if (rc != 0) { + status = smb_errno2status(rc); + if (status == NT_STATUS_INVALID_PARAMETER || + status == NT_STATUS_NOT_SUPPORTED) + status = NT_STATUS_INVALID_DEVICE_REQUEST; + args->out_xlen = 0; + } else { + status = 0; + } + + return (status); +} + +/* + * Handle FSCTL_OFFLOAD_WRITE with token type + * STORAGE_OFFLOAD_TOKEN_TYPE_NATIVE1 + */ +static uint32_t +smb2_fsctl_odx_write_native1(smb_request_t *sr, + odx_write_args_t *args, smb_odx_token_t *tok) +{ + struct tok_native1 *tn1; + smb_ofile_t *dst_ofile = sr->fid_ofile; + smb_ofile_t *src_ofile = NULL; + void *buffer = NULL; + size_t bufsize = smb2_odx_buf_size; + uint64_t src_offset; + uint32_t resid; + uint32_t xlen; + uint32_t status; + + /* + * Lookup the source ofile using the resume key, + * which smb2_fsctl_offload_read encoded as an + * smb2fid_t. Similar to smb2sr_lookup_fid(), + * but different error code. + */ + tn1 = &tok->tok_u.u_tok_native1; + src_ofile = smb_ofile_lookup_by_fid(sr, + (uint16_t)tn1->tn1_fid.temporal); + if (src_ofile == NULL || + src_ofile->f_persistid != tn1->tn1_fid.persistent) { + status = NT_STATUS_INVALID_TOKEN; + goto out; + } + + /* + * Make sure src_ofile is open on a regular file, and + * granted access includes READ_DATA + */ + if (!smb_node_is_file(src_ofile->f_node)) { + status = NT_STATUS_ACCESS_DENIED; + goto out; + } + status = smb_ofile_access(src_ofile, src_ofile->f_cr, FILE_READ_DATA); + if (status != NT_STATUS_SUCCESS) + goto out; + + /* + * Limit the I/O size. In here we're actually copying, + * so limit to smb2_odx_write_max (16M) per call. + * Note that xlen is a 32-bit value here. + */ + if (args->in_xlen > smb2_odx_write_max) + xlen = smb2_odx_write_max; + else + xlen = (uint32_t)args->in_xlen; + + /* + * Also limit to the actual file size, which may be + * smaller than the (block-aligned) transfer size. + * Report the rounded up size to the caller at EOF. + */ + args->out_xlen = xlen; + if ((args->in_dstoff + xlen) > args->wa_eof) + xlen = (uint32_t)(args->wa_eof - args->in_dstoff); + + /* + * Note: in_xoff is relative to the beginning of the "token" + * (a range of the source file tn1_off, tn1_eof). Make sure + * in_xoff is within the range represented by this token. + */ + src_offset = tn1->tn1_off + args->in_xoff; + if (src_offset >= tn1->tn1_eof || + src_offset < tn1->tn1_off) { + status = NT_STATUS_INVALID_PARAMETER; + goto out; + } + + /* + * Get a buffer used for copying, always + * smb2_odx_buf_size (1M) + * + * Rather than sleep for this relatively large allocation, + * allow the allocation to fail and return an error. + * The client should then fall back to normal copy. + */ + buffer = kmem_alloc(bufsize, KM_NOSLEEP | KM_NORMALPRI); + if (buffer == NULL) { + status = NT_STATUS_INSUFF_SERVER_RESOURCES; + goto out; + } + + /* + * Copy src to dst for xlen + */ + resid = xlen; + status = smb2_sparse_copy(sr, src_ofile, dst_ofile, + src_offset, args->in_dstoff, &resid, buffer, bufsize); + + /* + * If the result was a partial copy, round down the + * reported transfer size to a block boundary. + */ + if (resid != 0) { + xlen -= resid; + xlen &= ~OFFMASK; + args->out_xlen = xlen; + } + + /* + * If we did any I/O, ignore the error that stopped us. + * We'll report this error during the next call. + */ + if (args->out_xlen > 0) + status = 0; + +out: + if (src_ofile != NULL) + smb_ofile_release(src_ofile); + + if (buffer != NULL) + kmem_free(buffer, bufsize); + + return (status); +} + +/* + * Get an smb_odx_token_t from the (input) mbuf chain. + * Consumes exactly TOKEN_TOTAL_SIZE bytes. + */ +static int +smb_odx_get_token(mbuf_chain_t *mbc, smb_odx_token_t *tok) +{ + mbuf_chain_t tok_mbc; + int start_pos = mbc->chain_offset; + int rc; + + if (MBC_ROOM_FOR(mbc, TOKEN_TOTAL_SIZE) == 0) + return (-1); + + /* + * No big-endian support in smb_mbc_encodef, so swap + * the big-endian fields: tok_type (32-bits), + * (reserved is 16-bit zero, so no swap), + * and tok_len (16-bits) + */ + rc = smb_mbc_decodef( + mbc, "l..w", + &tok->tok_type, + /* tok_reserved */ + &tok->tok_len); + if (rc != 0) + return (rc); + tok->tok_type = BSWAP_32(tok->tok_type); + tok->tok_len = BSWAP_16(tok->tok_len); + + if (tok->tok_len > TOKEN_MAX_PAYLOAD) + return (-1); + rc = MBC_SHADOW_CHAIN(&tok_mbc, mbc, + mbc->chain_offset, tok->tok_len); + if (rc != 0) + return (rc); + + switch (tok->tok_type) { + case STORAGE_OFFLOAD_TOKEN_TYPE_ZERO_DATA: + /* no payload */ + break; + case STORAGE_OFFLOAD_TOKEN_TYPE_NATIVE1: + rc = smb_odx_get_token_native1(&tok_mbc, + &tok->tok_u.u_tok_native1); + break; + default: + /* caller will error out */ + break; + } + + if (rc == 0) { + /* Advance past what we shadowed. */ + mbc->chain_offset = start_pos + TOKEN_TOTAL_SIZE; + } + + return (rc); +} + +static int +smb_odx_get_token_native1(mbuf_chain_t *mbc, struct tok_native1 *tn1) +{ + int rc; + + rc = smb_mbc_decodef( + mbc, "qqqq", + &tn1->tn1_fid.persistent, + &tn1->tn1_fid.temporal, + &tn1->tn1_off, + &tn1->tn1_eof); + + return (rc); +} + +/* + * Put an smb_odx_token_t into the (output) mbuf chain, + * padded to TOKEN_TOTAL_SIZE bytes. + */ +static int +smb_odx_put_token(mbuf_chain_t *mbc, smb_odx_token_t *tok) +{ + int rc, padlen; + int start_pos = mbc->chain_offset; + int end_pos = start_pos + TOKEN_TOTAL_SIZE; + + if (tok->tok_len > TOKEN_MAX_PAYLOAD) + return (-1); + + /* + * No big-endian support in smb_mbc_encodef, so swap + * the big-endian fields: tok_type (32-bits), + * (reserved is 16-bit zero, so no swap), + * and tok_len (16-bits) + */ + rc = smb_mbc_encodef( + mbc, "lww", + BSWAP_32(tok->tok_type), + 0, /* tok_reserved */ + BSWAP_16(tok->tok_len)); + if (rc != 0) + return (rc); + + switch (tok->tok_type) { + case STORAGE_OFFLOAD_TOKEN_TYPE_ZERO_DATA: + /* no payload */ + break; + case STORAGE_OFFLOAD_TOKEN_TYPE_NATIVE1: + rc = smb_odx_put_token_native1(mbc, + &tok->tok_u.u_tok_native1); + break; + default: + ASSERT(0); + return (-1); + } + + /* Pad out to TOKEN_TOTAL_SIZE bytes. */ + if (mbc->chain_offset < end_pos) { + padlen = end_pos - mbc->chain_offset; + (void) smb_mbc_encodef(mbc, "#.", padlen); + } + ASSERT(mbc->chain_offset == end_pos); + + return (rc); +} + +static int +smb_odx_put_token_native1(mbuf_chain_t *mbc, struct tok_native1 *tn1) +{ + int rc; + + rc = smb_mbc_encodef( + mbc, "qqqq", + tn1->tn1_fid.persistent, + tn1->tn1_fid.temporal, + tn1->tn1_off, + tn1->tn1_eof); + + return (rc); +} diff --git a/usr/src/uts/common/fs/smbsrv/smb2_fsctl_sparse.c b/usr/src/uts/common/fs/smbsrv/smb2_fsctl_sparse.c new file mode 100644 index 0000000000..db89469cc0 --- /dev/null +++ b/usr/src/uts/common/fs/smbsrv/smb2_fsctl_sparse.c @@ -0,0 +1,691 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2018 Nexenta Systems, Inc. All rights reserved. + */ + +/* + * Support functions for smb2_ioctl/fsctl codes: + * FSCTL_SET_SPARSE + * FSCTL_SET_ZERO_DATA + * FSCTL_QUERY_ALLOCATED_RANGES + */ + +#include <smbsrv/smb2_kproto.h> +#include <smbsrv/smb_fsops.h> +#include <smb/winioctl.h> + +/* + * FSCTL_SET_SPARSE + * + * In args: one byte flag (optional: default TRUE) + */ +uint32_t +smb2_fsctl_set_sparse(smb_request_t *sr, smb_fsctl_t *fsctl) +{ + smb_attr_t attr; + smb_ofile_t *ofile = sr->fid_ofile; + cred_t *kcr; + uint32_t amask; + uint32_t status; + uint8_t flag; + int rc; + + rc = smb_mbc_decodef(fsctl->in_mbc, "b", &flag); + if (rc != 0) + flag = 0xff; + + if (!smb_node_is_file(ofile->f_node)) + return (NT_STATUS_INVALID_PARAMETER); + + /* + * Allow if we have any of FILE_WRITE_ATTRIBUTES, + * FILE_WRITE_DATA, FILE_APPEND_DATA + */ + amask = FILE_WRITE_ATTRIBUTES | FILE_WRITE_DATA | FILE_APPEND_DATA; + if ((ofile->f_granted_access & amask) == 0) + return (NT_STATUS_ACCESS_DENIED); + + /* + * Need the current DOS attributes + */ + bzero(&attr, sizeof (attr)); + attr.sa_mask = SMB_AT_DOSATTR; + kcr = zone_kcred(); + status = smb_node_getattr(sr, ofile->f_node, kcr, ofile, &attr); + if (status != NT_STATUS_SUCCESS) + return (status); + + if (flag != 0) { + /* Set "sparse" */ + if (attr.sa_dosattr & FILE_ATTRIBUTE_SPARSE_FILE) + return (0); + attr.sa_dosattr |= FILE_ATTRIBUTE_SPARSE_FILE; + } else { + /* Clear "sparse" */ + if ((attr.sa_dosattr & FILE_ATTRIBUTE_SPARSE_FILE) == 0) + return (0); + attr.sa_dosattr &= ~FILE_ATTRIBUTE_SPARSE_FILE; + } + + attr.sa_mask = SMB_AT_DOSATTR; + status = smb_node_setattr(sr, ofile->f_node, kcr, ofile, &attr); + return (status); +} + +/* + * FSCTL_SET_ZERO_DATA + * + * In args: uint64_t start_off, end_off + */ +uint32_t +smb2_fsctl_set_zero_data(smb_request_t *sr, smb_fsctl_t *fsctl) +{ + smb_attr_t attr; + smb_ofile_t *ofile = sr->fid_ofile; + uint64_t start_off, end_off, zero_len; + uint32_t status; + int rc; + + rc = smb_mbc_decodef(fsctl->in_mbc, "qq", + &start_off, &end_off); + if (rc != 0) + return (NT_STATUS_BUFFER_TOO_SMALL); + + /* + * The given offsets are actually int64_t (signed). + */ + if (start_off > INT64_MAX || + end_off > INT64_MAX || + start_off > end_off) + return (NT_STATUS_INVALID_PARAMETER); + + if (!smb_node_is_file(ofile->f_node)) + return (NT_STATUS_INVALID_PARAMETER); + + /* + * This operation is effectively a write (of zeros) + */ + status = smb_ofile_access(ofile, ofile->f_cr, FILE_WRITE_DATA); + if (status != NT_STATUS_SUCCESS) + return (status); + + /* + * Need the file size + */ + bzero(&attr, sizeof (attr)); + attr.sa_mask = SMB_AT_SIZE; + status = smb_node_getattr(sr, ofile->f_node, ofile->f_cr, + ofile, &attr); + if (status != NT_STATUS_SUCCESS) + return (status); + + /* + * Ignore any zero-ing beyond EOF + */ + if (end_off > attr.sa_vattr.va_size) + end_off = attr.sa_vattr.va_size; + if (start_off >= end_off) + return (0); + zero_len = end_off - start_off; + + /* + * Check for lock conflicting with the write. + */ + status = smb_lock_range_access(sr, ofile->f_node, + start_off, zero_len, B_TRUE); + if (status != 0) + return (status); /* == FILE_LOCK_CONFLICT */ + + rc = smb_fsop_freesp(sr, ofile->f_cr, ofile, + start_off, zero_len); + if (rc != 0) + status = smb_errno2status(rc); + + return (status); +} + +/* + * FSCTL_QUERY_ALLOCATED_RANGES + * + * Incoming args: uint64_t start_off, end_off + */ +struct alloc_range { + off64_t off; + off64_t len; +}; +uint32_t +smb2_fsctl_query_alloc_ranges(smb_request_t *sr, smb_fsctl_t *fsctl) +{ + smb_attr_t attr; + cred_t *kcr; + smb_ofile_t *ofile = sr->fid_ofile; + struct alloc_range arg, res; + off64_t cur_off, end_off; + uint32_t status; + int err, rc; + + /* + * Most ioctls return NT_STATUS_BUFFER_TOO_SMALL for + * short in/out buffers, but for this one, MS-FSA + * says short input returns invalid parameter. + */ + rc = smb_mbc_decodef(fsctl->in_mbc, "qq", &arg.off, &arg.len); + if (rc != 0) + return (NT_STATUS_INVALID_PARAMETER); + + /* + * The given offsets are actually int64_t (signed). + */ + end_off = arg.off + arg.len; + if (arg.off > INT64_MAX || arg.len < 0 || + end_off > INT64_MAX || end_off < arg.off) + return (NT_STATUS_INVALID_PARAMETER); + + if (!smb_node_is_file(ofile->f_node)) + return (NT_STATUS_INVALID_PARAMETER); + + /* + * This operation is effectively a read + */ + status = smb_ofile_access(ofile, ofile->f_cr, FILE_READ_DATA); + if (status != NT_STATUS_SUCCESS) + return (status); + + if (arg.len == 0) { + /* MS-FSA says empty result for this. */ + return (0); + } + + /* + * Need the file size and dosattr + */ + bzero(&attr, sizeof (attr)); + attr.sa_mask = SMB_AT_SIZE | SMB_AT_DOSATTR; + kcr = zone_kcred(); + status = smb_node_getattr(sr, ofile->f_node, kcr, ofile, &attr); + if (status != NT_STATUS_SUCCESS) + return (status); + if (end_off > attr.sa_vattr.va_size) + end_off = attr.sa_vattr.va_size; + + /* + * Only sparse files should present un-allocated ranges. + * If non-sparse, MS-FSA says (just return one range). + */ + if ((attr.sa_dosattr & FILE_ATTRIBUTE_SPARSE_FILE) == 0) { + if (arg.off < end_off) { + res.off = arg.off; + res.len = end_off - arg.off; + rc = smb_mbc_encodef(fsctl->out_mbc, "qq", + res.off, res.len); + if (rc != 0) + return (NT_STATUS_BUFFER_TOO_SMALL); + } + return (0); + } + + cur_off = arg.off; + while (cur_off < end_off) { + off64_t data, hole; + + data = cur_off; + err = smb_fsop_next_alloc_range(kcr, ofile->f_node, + &data, &hole); + if (err != 0) + break; + + /* sanity check data (ensure progress) */ + if (data < cur_off) { + ASSERT(0); + data = cur_off; + } + + /* Normal termination */ + if (data >= end_off) + break; + + /* sanity check hole (ensure progress) */ + if (hole <= data) + hole = end_off; + + /* Trim this range as needed. */ + if (hole > end_off) + hole = end_off; + + res.off = data; + res.len = hole - data; + + if (res.len > 0) { + rc = smb_mbc_encodef(fsctl->out_mbc, "qq", + res.off, res.len); + if (rc != 0) + return (NT_STATUS_BUFFER_TOO_SMALL); + } + + cur_off = hole; + } + + return (0); +} + +/* + * Copy a segment of a file, preserving sparseness. + * Uses a caller-provided buffer for read/write. + * Caller should already have checked for locks. + * + * On entry, *residp is the length to copy. + * On return, it's the "resid" (amount not copied) + * + * If this gets an error from any I/O, return it, even if some data + * have already been copied. The caller should normally ignore an + * error when some data have been copied. + */ +uint32_t +smb2_sparse_copy( + smb_request_t *sr, + smb_ofile_t *src_ofile, smb_ofile_t *dst_ofile, + off64_t src_off, off64_t dst_off, uint32_t *residp, + void *buffer, size_t bufsize) +{ + iovec_t iov; + uio_t uio; + off64_t data, hole; + uint32_t xfer; + uint32_t status = 0; + int rc; + + while (*residp > 0) { + + data = src_off; + rc = smb_fsop_next_alloc_range(src_ofile->f_cr, + src_ofile->f_node, &data, &hole); + switch (rc) { + case 0: + /* Found data, hole */ + break; + case ENXIO: + /* No data after here (will skip below). */ + data = hole = (src_off + *residp); + break; + default: + cmn_err(CE_NOTE, + "smb_fsop_next_alloc_range: rc=%d", rc); + /* FALLTHROUGH */ + case ENOSYS: /* FS does not support VOP_IOCTL... */ + case ENOTTY: /* ... or _FIO_SEEK_DATA, _HOLE */ + data = src_off; + hole = src_off + *residp; + break; + } + + /* + * Don't try to go past (src_off + *residp) + */ + if (hole > (src_off + *residp)) + hole = src_off + *residp; + if (data > hole) + data = hole; + + /* + * If there's a gap (src_off .. data) + * skip in src_ofile, zero in dst_ofile + */ + if (src_off < data) { + off64_t skip = data - src_off; + rc = smb_fsop_freesp(sr, dst_ofile->f_cr, + dst_ofile, dst_off, skip); + if (rc == 0) { + src_off += skip; + dst_off += skip; + *residp -= (uint32_t)skip; + } else { + /* Fall back to regular copy */ + data = src_off; + } + } + ASSERT(src_off == data); + + /* + * Copy this segment: src_off .. hole + */ + while (src_off < hole) { + ssize_t tsize = hole - src_off; + if (tsize > bufsize) + tsize = bufsize; + + /* + * Read src_ofile into buffer + */ + iov.iov_base = buffer; + iov.iov_len = tsize; + bzero(&uio, sizeof (uio)); + uio.uio_iov = &iov; + uio.uio_iovcnt = 1; + uio.uio_resid = tsize; + uio.uio_loffset = src_off; + uio.uio_segflg = UIO_SYSSPACE; + uio.uio_extflg = UIO_COPY_DEFAULT; + + rc = smb_fsop_read(sr, src_ofile->f_cr, + src_ofile->f_node, src_ofile, &uio); + if (rc != 0) { + status = smb_errno2status(rc); + return (status); + } + /* Note: Could be partial read. */ + tsize -= uio.uio_resid; + ASSERT(tsize > 0); + + /* + * Write buffer to dst_ofile + */ + iov.iov_base = buffer; + iov.iov_len = tsize; + bzero(&uio, sizeof (uio)); + uio.uio_iov = &iov; + uio.uio_iovcnt = 1; + uio.uio_resid = tsize; + uio.uio_loffset = dst_off; + uio.uio_segflg = UIO_SYSSPACE; + uio.uio_extflg = UIO_COPY_DEFAULT; + + rc = smb_fsop_write(sr, dst_ofile->f_cr, + dst_ofile->f_node, dst_ofile, &uio, &xfer, 0); + if (rc != 0) { + status = smb_errno2status(rc); + return (status); + } + ASSERT(xfer <= tsize); + + src_off += xfer; + dst_off += xfer; + *residp -= xfer; + } + ASSERT(src_off == hole); + } + + return (status); +} + +/* + * Not sure what header this might go in. + */ +#define FILE_REGION_USAGE_VALID_CACHED_DATA 1 +#define FILE_REGION_USAGE_VALID_NONCACHED_DATA 2 +#define FILE_REGION_USAGE_VALID__MASK 3 + +typedef struct _FILE_REGION_INFO { + uint64_t off; + uint64_t len; + uint32_t usage; + uint32_t reserved; +} FILE_REGION_INFO; + + +/* + * FSCTL_QUERY_FILE_REGIONS + * + * [MS-FSCC] 2.3.39 FSCTL_QUERY_FILE_REGIONS Request + * [MS-FSCC] 2.3.40.1 FILE_REGION_INFO + * + * Looks like Hyper-V uses this to query the "valid data length", + * which to us is the beginning offset of the last "hole". + * Similar logic as smb2_sparse_copy() + */ +uint32_t +smb2_fsctl_query_file_regions(smb_request_t *sr, smb_fsctl_t *fsctl) +{ + smb_attr_t attr; + cred_t *kcr; + smb_ofile_t *ofile = sr->fid_ofile; + FILE_REGION_INFO arg; + off64_t cur_off, end_off, eof; + off64_t data, hole; + uint32_t tot_regions, put_regions; + uint32_t status; + int rc; + + if (fsctl->InputCount == 0) { + arg.off = 0; + arg.len = INT64_MAX; + arg.usage = FILE_REGION_USAGE_VALID_CACHED_DATA; + arg.reserved = 0; + } else { + /* min size check: reserved is optional */ + rc = smb_mbc_decodef(fsctl->in_mbc, "qql", + &arg.off, &arg.len, &arg.usage); + if (rc != 0) + return (NT_STATUS_BUFFER_TOO_SMALL); + + /* + * The given offset and length are int64_t (signed). + */ + if (arg.off > INT64_MAX || arg.len > INT64_MAX) + return (NT_STATUS_INVALID_PARAMETER); + if ((arg.off + arg.len) > INT64_MAX) + return (NT_STATUS_INVALID_PARAMETER); + if ((arg.usage & FILE_REGION_USAGE_VALID__MASK) == 0) + return (NT_STATUS_INVALID_PARAMETER); + arg.reserved = 0; + } + + if (fsctl->MaxOutputResp < (16 + sizeof (FILE_REGION_INFO))) + return (NT_STATUS_BUFFER_TOO_SMALL); + + if (!smb_node_is_file(ofile->f_node)) + return (NT_STATUS_INVALID_PARAMETER); + + /* + * This operation is effectively a read + */ + status = smb_ofile_access(ofile, ofile->f_cr, FILE_READ_DATA); + if (status != NT_STATUS_SUCCESS) + return (status); + + /* + * Need the file size and dosattr + */ + bzero(&attr, sizeof (attr)); + attr.sa_mask = SMB_AT_SIZE | SMB_AT_DOSATTR; + kcr = zone_kcred(); + status = smb_node_getattr(sr, ofile->f_node, kcr, ofile, &attr); + if (status != NT_STATUS_SUCCESS) + return (status); + + cur_off = arg.off; + end_off = arg.off + arg.len; + eof = attr.sa_vattr.va_size; + + /* + * If (InputRegion.FileOffset > Eof) OR + * ((InputRegion.FileOffset == Eof) AND (Eof > 0)), + * the operation MUST return STATUS_SUCCESS, with + * BytesReturned set to 0 (empty data response) + */ + if ((arg.off > eof) || (arg.off == eof && eof > 0)) + return (NT_STATUS_SUCCESS); + if (end_off > eof) + end_off = eof; + + /* + * We're going to return at least one region. Put place-holder + * data for the fixed part of the response. Will overwrite this + * later, when we know how many regions there are and how many + * of those fit in the allowed response buffer space. These are: + * Flags, TotalRegionEntryCount, RegionEntryCount, Reserved + */ + rc = smb_mbc_encodef(fsctl->out_mbc, "llll", 0, 0, 0, 0); + if (rc != 0) + return (NT_STATUS_BUFFER_TOO_SMALL); + tot_regions = put_regions = 0; + + /* + * Get the first pair of (data, hole) offsets at or after + * the current offset (cur_off). + */ + data = hole = cur_off; + rc = smb_fsop_next_alloc_range(ofile->f_cr, + ofile->f_node, &data, &hole); + switch (rc) { + case 0: + /* Found (data, hole) */ + break; + case ENXIO: + /* No more data after cur_off. */ + break; + default: + cmn_err(CE_NOTE, "smb_fsop_next_alloc_range: rc=%d", rc); + /* FALLTHROUGH */ + case ENOSYS: /* FS does not support VOP_IOCTL... */ + case ENOTTY: /* ... or _FIO_SEEK_DATA, _HOLE */ + data = cur_off; + hole = eof; + break; + } + DTRACE_PROBE2(range0, uint64_t, data, uint64_t, hole); + + /* + * Only sparse files should present un-allocated regions. + * If non-sparse, MS-FSA says to just return one region. + * There still can be a "hole" but only one, starting at + * "valid data length" (VDL) and ending at end of file. + * To determine VDL, find the last (data,hole) pair, then + * VDL is the last "hole" offset. Note that the above + * smb_fsop_next_alloc_range may have set data somewhere + * above cur_off, so we we have to reset that here. + */ + if ((attr.sa_dosattr & FILE_ATTRIBUTE_SPARSE_FILE) == 0) { + /* + * This works, but it's rather inefficient, and + * usually just finds VDL==EOF. Should look into + * whether there's a faster way to find the VDL. + */ +#if 0 + off64_t next_data, next_hole; + data = cur_off; + do { + next_data = next_hole = hole; + rc = smb_fsop_next_alloc_range(ofile->f_cr, + ofile->f_node, &next_data, &next_hole); + if (rc == 0) { + hole = next_hole; + } + } while (rc == 0); +#else + /* Assume no "holes" anywhere (VDL==EOF) */ + data = cur_off; + hole = eof; +#endif + DTRACE_PROBE2(range1, uint64_t, data, uint64_t, hole); + } + + /* + * Loop terminates in the middle, continuing + * while (cur_off < end_off) + */ + for (;;) { + /* + * We have a data region that covers (data, hole). + * It could be partially or entirely beyond the range + * the caller asked about (if so trim it). + */ + if (hole > end_off) + hole = end_off; + if (data > hole) + data = hole; + + /* + * If cur_off < data encode a "hole" region + * (cur_off,data) and advance cur_off. + */ + if (cur_off < data) { + rc = smb_mbc_encodef(fsctl->out_mbc, "qqll", + cur_off, + (data - cur_off), + 0, // usage (hole) + 0); // reserved + cur_off = data; + if (rc == 0) + put_regions++; + tot_regions++; + } + + /* + * If cur_off < hole encode a "data" region + * (cur_off,hole) and advance cur_off. + */ + if (cur_off < hole) { + rc = smb_mbc_encodef(fsctl->out_mbc, "qqll", + cur_off, + (hole - cur_off), + FILE_REGION_USAGE_VALID_CACHED_DATA, + 0); // reserved + cur_off = hole; + if (rc == 0) + put_regions++; + tot_regions++; + } + + /* + * Normal loop termination + */ + if (cur_off >= end_off) + break; + + /* + * Get the next region (data, hole) starting on or after + * the current offset (cur_off). + */ + data = hole = cur_off; + rc = smb_fsop_next_alloc_range(ofile->f_cr, + ofile->f_node, &data, &hole); + switch (rc) { + case 0: + /* Found (data, hole) */ + break; + case ENXIO: + /* + * No more data after cur_off. + * Will encode one last hole. + */ + data = hole = eof; + break; + default: + cmn_err(CE_NOTE, "smb_fsop_next_alloc_range: rc=%d", + rc); + /* FALLTHROUGH */ + case ENOSYS: /* FS does not support VOP_IOCTL... */ + case ENOTTY: /* ... or _FIO_SEEK_DATA, _HOLE */ + data = cur_off; + hole = eof; + break; + } + DTRACE_PROBE2(range2, uint64_t, data, uint64_t, hole); + } + + /* + * Overwrite the fixed part of the response with the + * final numbers of regions etc. + * Flags, TotalRegionEntryCount, RegionEntryCount, Reserved + */ + (void) smb_mbc_poke(fsctl->out_mbc, 0, "llll", + 0, // flags + tot_regions, + put_regions, + 0); // reserved + + if (put_regions < tot_regions) + return (NT_STATUS_BUFFER_OVERFLOW); + + return (NT_STATUS_SUCCESS); +} diff --git a/usr/src/uts/common/fs/smbsrv/smb2_ioctl.c b/usr/src/uts/common/fs/smbsrv/smb2_ioctl.c index df0881f31b..40f671eba7 100644 --- a/usr/src/uts/common/fs/smbsrv/smb2_ioctl.c +++ b/usr/src/uts/common/fs/smbsrv/smb2_ioctl.c @@ -33,31 +33,19 @@ #include <smbsrv/smb2_kproto.h> #include <smb/winioctl.h> -struct smb2_ioctbl_ent { - uint32_t te_code; - uint32_t te_flags; - uint32_t (*te_func)(smb_request_t *, smb_fsctl_t *); -}; -static struct smb2_ioctbl_ent smb2_ioc_tbl[]; - -/* te_flags */ -#define ITF_IPC_ONLY 1 -#define ITF_NO_FID 2 -#define ITF_DISK_FID 4 - smb_sdrc_t smb2_ioctl(smb_request_t *sr) { smb2fid_t smb2fid; smb_fsctl_t fsctl; mbuf_chain_t in_mbc; - struct smb2_ioctbl_ent *te; uint32_t InputOffset; uint32_t MaxInputResp; uint32_t OutputOffset; uint32_t Flags; uint32_t status = 0; uint16_t StructSize; + uint16_t DeviceType; int rc = 0; /* Todo: put fsctl in sr->arg.ioctl (visible in dtrace probes) */ @@ -148,55 +136,48 @@ smb2_ioctl(smb_request_t *sr) if (status) goto errout; - for (te = smb2_ioc_tbl; te->te_code; te++) { - if (te->te_code == fsctl.CtlCode) - break; - } - if (te->te_code == 0) { -#ifdef DEBUG - cmn_err(CE_NOTE, "smb2_ioctl: unknown code 0x%x", - fsctl.CtlCode); -#endif - status = NT_STATUS_NOT_SUPPORTED; - goto errout; - } - - /* - * Some requests are only valid on IPC$ - */ - if ((te->te_flags & ITF_IPC_ONLY) != 0 && - !STYPE_ISIPC(sr->tid_tree->t_res_type)) { - status = NT_STATUS_INVALID_DEVICE_REQUEST; - goto errout; - } - - /* - * Note: some ioctls require a "disk" fid. - */ - if (te->te_flags & ITF_DISK_FID) { - if (sr->fid_ofile == NULL || - !SMB_FTYPE_IS_DISK(sr->fid_ofile->f_ftype)) { - status = NT_STATUS_INVALID_PARAMETER; - goto errout; - } - } - /* * Dispatch to the handler for CtlCode + * See CTL_CODE() in winioctl.h */ - status = (te->te_func)(sr, &fsctl); + DeviceType = fsctl.CtlCode >> 16; + switch (DeviceType) { + case FILE_DEVICE_DFS: /* 6 */ + status = smb_dfs_fsctl(sr, &fsctl); + break; + case FILE_DEVICE_FILE_SYSTEM: /* 9 */ + status = smb2_fsctl_fs(sr, &fsctl); + break; + case FILE_DEVICE_NAMED_PIPE: /* 17 */ + status = smb_opipe_fsctl(sr, &fsctl); + break; + case FILE_DEVICE_NETWORK_FILE_SYSTEM: /* 20 */ + status = smb2_fsctl_netfs(sr, &fsctl); + break; + default: + status = NT_STATUS_NOT_SUPPORTED; + break; + } errout: sr->smb2_status = status; DTRACE_SMB2_DONE(op__Ioctl, smb_request_t *, sr); if (status != 0) { - if (NT_SC_SEVERITY(status) == NT_STATUS_SEVERITY_ERROR) { + /* + * NT status codes with severity "error" normally cause + * an error response with no data. However, there are + * exceptions like smb2_fsctl_copychunk that may return + * severity==error _with_ a data part. + */ + if ((NT_SC_SEVERITY(status) == NT_STATUS_SEVERITY_ERROR) && + (fsctl.CtlCode != FSCTL_SRV_COPYCHUNK) && + (fsctl.CtlCode != FSCTL_SRV_COPYCHUNK_WRITE)) { /* no error data */ smb2sr_put_error(sr, status); return (SDRC_SUCCESS); } - /* Warnings like NT_STATUS_BUFFER_OVERFLOW are OK. */ + /* Else, error response _with_ data. */ } fsctl.InputCount = 0; @@ -220,7 +201,7 @@ errout: fsctl.InputCount, /* l */ OutputOffset, /* l */ fsctl.OutputCount, /* l */ - Flags, /* l */ + 0, /* Flags l */ /* reserved2 4. */ fsctl.OutputCount, /* # */ &sr->raw_data); /* C */ @@ -229,60 +210,3 @@ errout: return (SDRC_SUCCESS); } - -/* ARGSUSED */ -static uint32_t -smb2_fsctl_notsup(smb_request_t *sr, smb_fsctl_t *fsctl) -{ - return (NT_STATUS_NOT_SUPPORTED); -} - -static struct smb2_ioctbl_ent -smb2_ioc_tbl[] = { - - /* - * FILE_DEVICE_DFS (6) - */ - { FSCTL_DFS_GET_REFERRALS, - ITF_IPC_ONLY | ITF_NO_FID, smb_dfs_get_referrals }, - { FSCTL_DFS_GET_REFERRALS_EX, - ITF_IPC_ONLY | ITF_NO_FID, smb_dfs_get_referrals }, - - /* - * FILE_DEVICE_FILE_SYSTEM (9) - */ - { FSCTL_SET_REPARSE_POINT, 0, smb2_fsctl_notsup }, - { FSCTL_CREATE_OR_GET_OBJECT_ID, 0, smb2_fsctl_notsup }, - { FSCTL_FILE_LEVEL_TRIM, 0, smb2_fsctl_notsup }, - - /* - * FILE_DEVICE_NAMED_PIPE (17) - */ - { FSCTL_PIPE_PEEK, - ITF_IPC_ONLY, smb_opipe_fsctl }, - { FSCTL_PIPE_TRANSCEIVE, - ITF_IPC_ONLY, smb_opipe_fsctl }, - { FSCTL_PIPE_WAIT, - ITF_IPC_ONLY | ITF_NO_FID, smb_opipe_fsctl }, - - /* - * FILE_DEVICE_NETWORK_FILE_SYSTEM (20) - */ - { FSCTL_SRV_ENUMERATE_SNAPSHOTS, - ITF_DISK_FID, smb_vss_enum_snapshots }, - { FSCTL_SRV_REQUEST_RESUME_KEY, 0, smb2_fsctl_notsup }, - { FSCTL_SRV_COPYCHUNK, 0, smb2_fsctl_notsup }, - { FSCTL_SRV_COPYCHUNK_WRITE, 0, smb2_fsctl_notsup }, - { FSCTL_SRV_READ_HASH, 0, smb2_fsctl_notsup }, - - { FSCTL_LMR_REQUEST_RESILIENCY, 0, smb2_fsctl_resiliency }, - { FSCTL_QUERY_NETWORK_INTERFACE_INFO, - ITF_NO_FID, smb2_fsctl_notsup }, - { FSCTL_VALIDATE_NEGOTIATE_INFO, - ITF_NO_FID, smb2_fsctl_vneginfo }, - - /* - * End marker - */ - { 0, 0, 0 } -}; diff --git a/usr/src/uts/common/fs/smbsrv/smb2_negotiate.c b/usr/src/uts/common/fs/smbsrv/smb2_negotiate.c index d31abaa3e8..c534ebe7fb 100644 --- a/usr/src/uts/common/fs/smbsrv/smb2_negotiate.c +++ b/usr/src/uts/common/fs/smbsrv/smb2_negotiate.c @@ -411,7 +411,7 @@ smb2_negotiate(smb_request_t *sr) * VALIDATE_NEGOTIATE_INFO [MS-SMB2] 2.2.32.6 */ uint32_t -smb2_fsctl_vneginfo(smb_request_t *sr, smb_fsctl_t *fsctl) +smb2_nego_validate(smb_request_t *sr, smb_fsctl_t *fsctl) { smb_session_t *s = sr->session; int rc; diff --git a/usr/src/uts/common/fs/smbsrv/smb2_qinfo_fs.c b/usr/src/uts/common/fs/smbsrv/smb2_qinfo_fs.c index bd1b37ed9d..856a59e939 100644 --- a/usr/src/uts/common/fs/smbsrv/smb2_qinfo_fs.c +++ b/usr/src/uts/common/fs/smbsrv/smb2_qinfo_fs.c @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 Nexenta Systems, Inc. All rights reserved. */ /* @@ -41,6 +41,7 @@ uint32_t smb2_qfs_attr(smb_request_t *); uint32_t smb2_qfs_control(smb_request_t *); uint32_t smb2_qfs_fullsize(smb_request_t *); uint32_t smb2_qfs_obj_id(smb_request_t *); +uint32_t smb2_qfs_sectorsize(smb_request_t *); uint32_t smb2_qinfo_fs(smb_request_t *sr, smb_queryinfo_t *qi) @@ -71,10 +72,19 @@ smb2_qinfo_fs(smb_request_t *sr, smb_queryinfo_t *qi) case FileFsObjectIdInformation: /* 8 */ status = smb2_qfs_obj_id(sr); break; - - default: + case FileFsDriverPathInformation: /* 9 */ + case FileFsVolumeFlagsInformation: /* A */ status = NT_STATUS_INVALID_INFO_CLASS; break; + case FileFsSectorSizeInformation: /* B */ + status = smb2_qfs_sectorsize(sr); + break; + default: /* there are some infoclasses we don't yet handle */ + status = NT_STATUS_INVALID_INFO_CLASS; +#ifdef DEBUG + cmn_err(CE_NOTE, "unknown InfoClass 0x%x", qi->qi_InfoClass); +#endif + break; } return (status); @@ -287,3 +297,116 @@ smb2_qfs_obj_id(smb_request_t *sr) { return (NT_STATUS_INVALID_PARAMETER); } + +/* + * Not sure yet where these should go. + * Flags in FileFsSectorSizeInformation + */ + +#define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001 +// When set, this flag indicates that the first physical sector of the device +// is aligned with the first logical sector. When not set, the first physical +// sector of the device is misaligned with the first logical sector. + +#define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002 +// When set, this flag indicates that the partition is aligned to physical +// sector boundaries on the storage device. + +#define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004 +// When set, the device reports that it does not incur a seek penalty (this +// typically indicates that the device does not have rotating media, such as +// flash-based disks). + +#define SSINFO_FLAGS_TRIM_ENABLED 0x00000008 +// When set, the device supports TRIM operations, either T13 (ATA) TRIM or +// T10 (SCSI/SAS) UNMAP. + +#define SSINFO_OFFSET_UNKNOWN 0xffffffff +// For "Alignment" fields below + +/* + * We have to lie to Windows Hyper-V about our logical record size, + * because with larger sizes it fails setting up a virtual disk. + */ +int smb2_max_logical_sector_size = 4096; + +/* + * FileFsSectorSizeInformation + * + * Returns a FILE_FS_SECTOR_SIZE_INFORMATION + * See: [MS-FSCC] 2.5.8 FileFsSizeInformation + * + * LogicalBytesPerSector (4 bytes): ... number of bytes in a logical sector + * for the device backing the volume. This field is the unit of logical + * addressing for the device and is not the unit of atomic write. + * PhysicalBytesPerSectorForAtomicity (4 bytes): ... number of bytes in a + * physical sector for the device backing the volume. This is the reported + * physical sector size of the device and is the unit of atomic write. + * PhysicalBytesPerSectorForPerformance (4 bytes): ... number of bytes in a + * physical sector for the device backing the volume. This is the reported + * physical sector size of the device and is the unit of performance. + * FileSystemEffectivePhysicalBytesPerSectorForAtomicity (4 bytes): unit, in + * bytes, that the file system on the volume will use for internal operations + * that require alignment and atomicity. + * Flags (4 bytes): See ... + * ByteOffsetForSectorAlignment (4 bytes): ... logical sector offset within the + * first physical sector where the first logical sector is placed, in bytes. + * If this value is set to SSINFO_OFFSET_UNKNOWN (0xffffffff), there was + * insufficient information to compute this field. + * ByteOffsetForPartitionAlignment (4 bytes): ... byte offset from the first + * physical sector where the first partition is placed. If this value is + * set to SSINFO_OFFSET_UNKNOWN (0xffffffff), there was either insufficient + * information or an error was encountered in computing this field. + */ +uint32_t +smb2_qfs_sectorsize(smb_request_t *sr) +{ + smb_fssize_t fssize; + smb_tree_t *tree = sr->tid_tree; + uint32_t lbps, pbps; + uint32_t flags; + int rc; + + if (!STYPE_ISDSK(tree->t_res_type)) + return (NT_STATUS_INVALID_PARAMETER); + + rc = smb_fssize(sr, &fssize); + if (rc) + return (smb_errno2status(rc)); + pbps = fssize.fs_bytes_per_sector; + lbps = fssize.fs_sectors_per_unit * pbps; + if (lbps > smb2_max_logical_sector_size) + lbps = smb2_max_logical_sector_size; + + // LogicalBytesPerSector + (void) smb_mbc_encodef(&sr->raw_data, "l", lbps); + + // PhysicalBytesPerSectorForAtomicity + (void) smb_mbc_encodef(&sr->raw_data, "l", pbps); + + // PhysicalBytesPerSectorForPerformance + // Using logical size here. + (void) smb_mbc_encodef(&sr->raw_data, "l", lbps); + + // FileSystemEffectivePhysicalBytesPerSectorForAtomicity + (void) smb_mbc_encodef(&sr->raw_data, "l", pbps); + + // Flags + // We include "no seek penalty" because our files are + // always ZFS-backed, which can reorder things on disk. + // Leaving out SSINFO_FLAGS_TRIM_ENABLED for now. + flags = SSINFO_FLAGS_ALIGNED_DEVICE | + SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE | + SSINFO_FLAGS_NO_SEEK_PENALTY; + (void) smb_mbc_encodef(&sr->raw_data, "l", flags); + + // ByteOffsetForSectorAlignment + // ByteOffsetForPartitionAlignment + // Just say "unknown" for these two. + (void) smb_mbc_encodef( + &sr->raw_data, "l", + SSINFO_OFFSET_UNKNOWN, + SSINFO_OFFSET_UNKNOWN); + + return (0); +} diff --git a/usr/src/uts/common/fs/smbsrv/smb2_read.c b/usr/src/uts/common/fs/smbsrv/smb2_read.c index 623a5b1141..9ef2aa57c4 100644 --- a/usr/src/uts/common/fs/smbsrv/smb2_read.c +++ b/usr/src/uts/common/fs/smbsrv/smb2_read.c @@ -115,7 +115,8 @@ smb2_read(smb_request_t *sr) break; } } - rc = smb_fsop_read(sr, of->f_cr, of->f_node, &vdb->vdb_uio); + rc = smb_fsop_read(sr, of->f_cr, of->f_node, of, + &vdb->vdb_uio); break; case STYPE_IPC: rc = smb_opipe_read(sr, &vdb->vdb_uio); diff --git a/usr/src/uts/common/fs/smbsrv/smb2_setinfo_file.c b/usr/src/uts/common/fs/smbsrv/smb2_setinfo_file.c index 37ec81366f..18b2ce6b24 100644 --- a/usr/src/uts/common/fs/smbsrv/smb2_setinfo_file.c +++ b/usr/src/uts/common/fs/smbsrv/smb2_setinfo_file.c @@ -10,7 +10,7 @@ */ /* - * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 Nexenta Systems, Inc. All rights reserved. */ /* @@ -263,7 +263,11 @@ smb2_setf_valid_len(smb_request_t *sr, smb_setinfo_t *si) if (smb_mbc_decodef(&si->si_data, "q", &eod) != 0) return (NT_STATUS_INFO_LENGTH_MISMATCH); - rc = smb_fsop_set_data_length(sr, of->f_cr, of->f_node, eod); + /* + * Zero out data from EoD to end of file. + * (Passing len=0 covers to end of file) + */ + rc = smb_fsop_freesp(sr, of->f_cr, of, eod, 0); if (rc != 0) return (smb_errno2status(rc)); diff --git a/usr/src/uts/common/fs/smbsrv/smb2_write.c b/usr/src/uts/common/fs/smbsrv/smb2_write.c index 2f4f40bc4b..9e0795e21f 100644 --- a/usr/src/uts/common/fs/smbsrv/smb2_write.c +++ b/usr/src/uts/common/fs/smbsrv/smb2_write.c @@ -127,7 +127,7 @@ smb2_write(smb_request_t *sr) (of->f_node->flags & NODE_FLAGS_WRITE_THROUGH)) { stability = FSYNC; } - rc = smb_fsop_write(sr, of->f_cr, of->f_node, + rc = smb_fsop_write(sr, of->f_cr, of->f_node, of, &vdb->vdb_uio, &XferCount, stability); if (rc) break; diff --git a/usr/src/uts/common/fs/smbsrv/smb_common_transact.c b/usr/src/uts/common/fs/smbsrv/smb_common_transact.c index 708ccf741e..d0d0c445f6 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_common_transact.c +++ b/usr/src/uts/common/fs/smbsrv/smb_common_transact.c @@ -1432,7 +1432,7 @@ smb_trans_nmpipe(smb_request_t *sr, smb_xa_t *xa) fsctl.in_mbc = &xa->req_data_mb; /* write from here */ fsctl.out_mbc = &xa->rep_data_mb; /* read into here */ - status = smb_opipe_fsctl(sr, &fsctl); + status = smb_opipe_transceive(sr, &fsctl); if (status) { smbsr_status(sr, status, 0, 0); if (NT_SC_SEVERITY(status) == NT_STATUS_SEVERITY_ERROR) diff --git a/usr/src/uts/common/fs/smbsrv/smb_dfs.c b/usr/src/uts/common/fs/smbsrv/smb_dfs.c index 03c565e9e4..b308ebf080 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_dfs.c +++ b/usr/src/uts/common/fs/smbsrv/smb_dfs.c @@ -84,6 +84,30 @@ static void smb_dfs_referrals_free(dfs_referral_response_t *); static uint16_t smb_dfs_referrals_unclen(dfs_info_t *, uint16_t); /* + * Handle device type FILE_DEVICE_DFS + * for smb2_ioctl + */ +uint32_t +smb_dfs_fsctl(smb_request_t *sr, smb_fsctl_t *fsctl) +{ + uint32_t status; + + if (!STYPE_ISIPC(sr->tid_tree->t_res_type)) + return (NT_STATUS_INVALID_DEVICE_REQUEST); + + switch (fsctl->CtlCode) { + case FSCTL_DFS_GET_REFERRALS: + status = smb_dfs_get_referrals(sr, fsctl); + break; + case FSCTL_DFS_GET_REFERRALS_EX: /* XXX - todo */ + default: + status = NT_STATUS_NOT_SUPPORTED; + } + + return (status); +} + +/* * Note: SMB1 callers in smb_trans2_dfs.c * smb_com_trans2_report_dfs_inconsistency * smb_com_trans2_get_dfs_referral @@ -91,6 +115,7 @@ static uint16_t smb_dfs_referrals_unclen(dfs_info_t *, uint16_t); /* * See [MS-DFSC] for details about this command + * Handles FSCTL_DFS_GET_REFERRALS (only) */ uint32_t smb_dfs_get_referrals(smb_request_t *sr, smb_fsctl_t *fsctl) @@ -117,21 +142,14 @@ smb_dfs_get_referrals(smb_request_t *sr, smb_fsctl_t *fsctl) * allow all this decoding/encoding to happen at user-level. * (and most of this file would go away. :-) */ - switch (fsctl->CtlCode) { - case FSCTL_DFS_GET_REFERRALS: - /* - * Input data is (w) MaxReferralLevel, (U) path - */ - rc = smb_mbc_decodef(fsctl->in_mbc, "%wu", - sr, &maxver, &path); - if (rc != 0) - return (NT_STATUS_INVALID_PARAMETER); - break; - case FSCTL_DFS_GET_REFERRALS_EX: /* XXX - todo */ - default: - return (NT_STATUS_NOT_SUPPORTED); - } + /* + * Input data is (w) MaxReferralLevel, (U) path + */ + rc = smb_mbc_decodef(fsctl->in_mbc, "%wu", + sr, &maxver, &path); + if (rc != 0) + return (NT_STATUS_INVALID_PARAMETER); reftype = smb_dfs_get_reftype((const char *)path); switch (reftype) { diff --git a/usr/src/uts/common/fs/smbsrv/smb_fsops.c b/usr/src/uts/common/fs/smbsrv/smb_fsops.c index abe69a9017..6aa4074221 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_fsops.c +++ b/usr/src/uts/common/fs/smbsrv/smb_fsops.c @@ -29,6 +29,7 @@ #include <smbsrv/smb_kproto.h> #include <acl/acl_common.h> #include <sys/fcntl.h> +#include <sys/filio.h> #include <sys/flock.h> #include <fs/fs_subr.h> @@ -1299,21 +1300,18 @@ smb_fsop_setattr( /* * Support for SMB2 setinfo FileValidDataLengthInformation. - * Free data from the specified offset to EoF. - * - * This can effectively truncate data. It truncates the data - * leaving the file size as it was, leaving zeros after the - * offset specified here. That is effectively modifying the - * file content, so for access control this is a write. + * Free (zero out) data in the range off, off+len */ int -smb_fsop_set_data_length( +smb_fsop_freesp( smb_request_t *sr, cred_t *cr, - smb_node_t *node, - offset_t end_of_data) + smb_ofile_t *ofile, + off64_t off, + off64_t len) { flock64_t flk; + smb_node_t *node = ofile->f_node; uint32_t status; uint32_t access = FILE_WRITE_DATA; int rc; @@ -1346,7 +1344,8 @@ smb_fsop_set_data_length( return (EACCES); bzero(&flk, sizeof (flk)); - flk.l_start = end_of_data; + flk.l_start = off; + flk.l_len = len; rc = smb_vop_space(node->vp, F_FREESP, &flk, FWRITE, 0LL, cr); return (rc); @@ -1361,12 +1360,15 @@ smb_fsop_set_data_length( * for avoiding this wrapper. * * It is assumed that a reference exists on snode coming into this routine. + * Note that ofile may be different from sr->fid_ofile, or may be NULL. */ int -smb_fsop_read(smb_request_t *sr, cred_t *cr, smb_node_t *snode, uio_t *uio) +smb_fsop_read(smb_request_t *sr, cred_t *cr, smb_node_t *snode, + smb_ofile_t *ofile, uio_t *uio) { caller_context_t ct; cred_t *kcr = zone_kcred(); + uint32_t amask; int svmand; int rc; @@ -1376,18 +1378,26 @@ smb_fsop_read(smb_request_t *sr, cred_t *cr, smb_node_t *snode, uio_t *uio) ASSERT(snode->n_state != SMB_NODE_STATE_DESTROYING); ASSERT(sr); - ASSERT(sr->fid_ofile); - - if (SMB_TREE_HAS_ACCESS(sr, ACE_READ_DATA) == 0) - return (EACCES); - rc = smb_ofile_access(sr->fid_ofile, cr, FILE_READ_DATA); - if ((rc != NT_STATUS_SUCCESS) && - (sr->smb_flg2 & SMB_FLAGS2_READ_IF_EXECUTE)) - rc = smb_ofile_access(sr->fid_ofile, cr, FILE_EXECUTE); + if (ofile != NULL) { + /* + * Check tree access. Not SMB_TREE_HAS_ACCESS + * because we need to use ofile->f_tree + */ + if ((ofile->f_tree->t_access & ACE_READ_DATA) == 0) + return (EACCES); - if (rc != NT_STATUS_SUCCESS) - return (EACCES); + /* + * Check ofile access. Use in-line smb_ofile_access + * so we can check both amask bits at the same time. + * If any bit in amask is granted, allow this read. + */ + amask = FILE_READ_DATA; + if (sr->smb_flg2 & SMB_FLAGS2_READ_IF_EXECUTE) + amask |= FILE_EXECUTE; + if (cr != kcr && (ofile->f_granted_access & amask) == 0) + return (EACCES); + } /* * Streams permission are checked against the unnamed stream, @@ -1413,7 +1423,8 @@ smb_fsop_read(smb_request_t *sr, cred_t *cr, smb_node_t *snode, uio_t *uio) */ if (uio->uio_resid > 0) { ct = smb_ct; - ct.cc_pid = sr->fid_ofile->f_uniqid; + if (ofile != NULL) + ct.cc_pid = ofile->f_uniqid; rc = nbl_lock_conflict(snode->vp, NBL_READ, uio->uio_loffset, uio->uio_resid, svmand, &ct); if (rc != 0) { @@ -1431,26 +1442,26 @@ smb_fsop_read(smb_request_t *sr, cred_t *cr, smb_node_t *snode, uio_t *uio) /* * smb_fsop_write * - * This is a wrapper function used for smb_write and smb_write_raw operations. - * * It is assumed that a reference exists on snode coming into this routine. + * Note that ofile may be different from sr->fid_ofile, or may be NULL. */ int smb_fsop_write( smb_request_t *sr, cred_t *cr, smb_node_t *snode, + smb_ofile_t *ofile, uio_t *uio, uint32_t *lcount, int ioflag) { caller_context_t ct; smb_attr_t attr; + cred_t *kcr = zone_kcred(); smb_node_t *u_node; vnode_t *u_vp = NULL; - smb_ofile_t *of; vnode_t *vp; - cred_t *kcr = zone_kcred(); + uint32_t amask; int svmand; int rc; @@ -1460,20 +1471,21 @@ smb_fsop_write( ASSERT(snode->n_state != SMB_NODE_STATE_DESTROYING); ASSERT(sr); - ASSERT(sr->tid_tree); - of = sr->fid_ofile; vp = snode->vp; - if (SMB_TREE_IS_READONLY(sr)) - return (EROFS); + if (ofile != NULL) { + amask = FILE_WRITE_DATA | FILE_APPEND_DATA; - if (SMB_TREE_HAS_ACCESS(sr, ACE_WRITE_DATA | ACE_APPEND_DATA) == 0) - return (EACCES); + /* Check tree access. */ + if ((ofile->f_tree->t_access & amask) == 0) + return (EROFS); - rc = smb_ofile_access(of, cr, FILE_WRITE_DATA); - if (rc != NT_STATUS_SUCCESS) { - rc = smb_ofile_access(of, cr, FILE_APPEND_DATA); - if (rc != NT_STATUS_SUCCESS) + /* + * Check ofile access. Use in-line smb_ofile_access + * so we can check both amask bits at the same time. + * If any bit in amask is granted, allow this write. + */ + if (cr != kcr && (ofile->f_granted_access & amask) == 0) return (EACCES); } @@ -1506,7 +1518,8 @@ smb_fsop_write( */ if (uio->uio_resid > 0) { ct = smb_ct; - ct.cc_pid = of->f_uniqid; + if (ofile != NULL) + ct.cc_pid = ofile->f_uniqid; rc = nbl_lock_conflict(vp, NBL_WRITE, uio->uio_loffset, uio->uio_resid, svmand, &ct); if (rc != 0) { @@ -1528,8 +1541,9 @@ smb_fsop_write( * behavior by re-setting the mtime after writes on a * handle where the mtime has been set. */ - if (of->f_pending_attr.sa_mask & SMB_AT_MTIME) { - bcopy(&of->f_pending_attr, &attr, sizeof (attr)); + if (ofile != NULL && + (ofile->f_pending_attr.sa_mask & SMB_AT_MTIME) != 0) { + bcopy(&ofile->f_pending_attr, &attr, sizeof (attr)); attr.sa_mask = SMB_AT_MTIME; (void) smb_vop_setattr(vp, u_vp, &attr, 0, kcr); } @@ -1540,6 +1554,30 @@ smb_fsop_write( } /* + * Find the next allocated range starting at or after + * the offset (*datap), returning the start/end of + * that range in (*datap, *holep) + */ +int +smb_fsop_next_alloc_range( + cred_t *cr, + smb_node_t *node, + off64_t *datap, + off64_t *holep) +{ + int err; + + err = smb_vop_ioctl(node->vp, _FIO_SEEK_DATA, datap, cr); + if (err != 0) + return (err); + + *holep = *datap; + err = smb_vop_ioctl(node->vp, _FIO_SEEK_HOLE, holep, cr); + + return (err); +} + +/* * smb_fsop_statfs * * This is a wrapper function used for stat operations. diff --git a/usr/src/uts/common/fs/smbsrv/smb_opipe.c b/usr/src/uts/common/fs/smbsrv/smb_opipe.c index 83b74ee075..6742a5c052 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_opipe.c +++ b/usr/src/uts/common/fs/smbsrv/smb_opipe.c @@ -37,8 +37,6 @@ #include <smbsrv/smb_xdr.h> #include <smb/winioctl.h> -static uint32_t smb_opipe_transceive(smb_request_t *, smb_fsctl_t *); - /* * Allocate a new opipe and return it, or NULL, in which case * the caller will report "internal error". @@ -557,7 +555,8 @@ smb_opipe_getname(smb_ofile_t *of, char *buf, size_t buflen) } /* - * Handler for smb2_ioctl + * Handle device type FILE_DEVICE_NAMED_PIPE + * for smb2_ioctl */ /* ARGSUSED */ uint32_t @@ -565,6 +564,9 @@ smb_opipe_fsctl(smb_request_t *sr, smb_fsctl_t *fsctl) { uint32_t status; + if (!STYPE_ISIPC(sr->tid_tree->t_res_type)) + return (NT_STATUS_INVALID_DEVICE_REQUEST); + switch (fsctl->CtlCode) { case FSCTL_PIPE_TRANSCEIVE: status = smb_opipe_transceive(sr, fsctl); @@ -585,7 +587,7 @@ smb_opipe_fsctl(smb_request_t *sr, smb_fsctl_t *fsctl) return (status); } -static uint32_t +uint32_t smb_opipe_transceive(smb_request_t *sr, smb_fsctl_t *fsctl) { smb_vdb_t vdb; diff --git a/usr/src/uts/common/fs/smbsrv/smb_read.c b/usr/src/uts/common/fs/smbsrv/smb_read.c index 70ad0a8b4b..1cd046a1eb 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_read.c +++ b/usr/src/uts/common/fs/smbsrv/smb_read.c @@ -437,7 +437,8 @@ smb_common_read(smb_request_t *sr, smb_rw_param_t *param) sr->raw_data.max_bytes = vdb->vdb_uio.uio_resid; top = smb_mbuf_allocate(&vdb->vdb_uio); - rc = smb_fsop_read(sr, sr->user_cr, node, &vdb->vdb_uio); + rc = smb_fsop_read(sr, sr->user_cr, node, ofile, + &vdb->vdb_uio); sr->raw_data.max_bytes -= vdb->vdb_uio.uio_resid; smb_mbuf_trim(top, sr->raw_data.max_bytes); diff --git a/usr/src/uts/common/fs/smbsrv/smb_tree.c b/usr/src/uts/common/fs/smbsrv/smb_tree.c index acdfb66eb9..5020dec794 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_tree.c +++ b/usr/src/uts/common/fs/smbsrv/smb_tree.c @@ -1174,6 +1174,10 @@ smb_tree_get_flags(const smb_kshare_t *si, vfs_t *vfsp, smb_tree_t *tree) } smb_mtype_t; static smb_mtype_t smb_mtype[] = { +#ifdef _FAKE_KERNEL + /* See libfksmbsrv:fake_vfs.c */ + { "fake", 3, SMB_TREE_SPARSE}, +#endif /* _FAKE_KERNEL */ { "zfs", 3, SMB_TREE_QUOTA | SMB_TREE_SPARSE}, { "ufs", 3, 0 }, { "nfs", 3, SMB_TREE_NFS_MOUNTED }, diff --git a/usr/src/uts/common/fs/smbsrv/smb_vops.c b/usr/src/uts/common/fs/smbsrv/smb_vops.c index f90c2d837d..d2f0fd7085 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_vops.c +++ b/usr/src/uts/common/fs/smbsrv/smb_vops.c @@ -279,6 +279,23 @@ smb_vop_write(vnode_t *vp, uio_t *uiop, int ioflag, uint32_t *lcount, return (error); } +int +smb_vop_ioctl(vnode_t *vp, int cmd, void *arg, cred_t *cr) +{ + int error, rval = 0; + uint_t flags = 0; + +#ifdef FKIOCTL + flags |= FKIOCTL; +#endif + error = VOP_IOCTL(vp, cmd, (intptr_t)arg, (int)flags, cr, + &rval, &smb_ct); + if (error != 0) + rval = error; + + return (rval); +} + /* * smb_vop_getattr() * diff --git a/usr/src/uts/common/fs/smbsrv/smb_write.c b/usr/src/uts/common/fs/smbsrv/smb_write.c index ad8f2b2b2b..6db8cc9e1a 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_write.c +++ b/usr/src/uts/common/fs/smbsrv/smb_write.c @@ -511,7 +511,7 @@ smb_common_write(smb_request_t *sr, smb_rw_param_t *param) stability = FSYNC; } - rc = smb_fsop_write(sr, sr->user_cr, node, + rc = smb_fsop_write(sr, sr->user_cr, node, ofile, ¶m->rw_vdb.vdb_uio, &lcount, stability); if (rc) diff --git a/usr/src/uts/common/smb/winioctl.h b/usr/src/uts/common/smb/winioctl.h index a18d7853ce..0f322cc4ef 100644 --- a/usr/src/uts/common/smb/winioctl.h +++ b/usr/src/uts/common/smb/winioctl.h @@ -480,6 +480,8 @@ extern "C" { #define FSCTL_SET_INTEGRITY_INFORMATION \ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 160, METHOD_BUFFERED, \ FILE_READ_ACCESS | FILE_WRITE_ACCESS) +#define FSCTL_QUERY_FILE_REGIONS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 161, METHOD_BUFFERED, FILE_ANY_ACCESS) /* FILE_DEVICE_NETWORK_FILE_SYSTEM */ /* Read the snapshot info for Volume Shadow Copy Services */ diff --git a/usr/src/uts/common/smbsrv/ntifs.h b/usr/src/uts/common/smbsrv/ntifs.h index ca5570823d..7c1d837c08 100644 --- a/usr/src/uts/common/smbsrv/ntifs.h +++ b/usr/src/uts/common/smbsrv/ntifs.h @@ -289,7 +289,9 @@ typedef enum _FILE_FS_INFORMATION_CLASS { FileFsControlInformation, /* 6 */ FileFsFullSizeInformation, /* 7 */ FileFsObjectIdInformation, /* 8 */ - FileFsDriverPathInformation /* 9 */ + FileFsDriverPathInformation, /* 9 */ + FileFsVolumeFlagsInformation, /* A */ + FileFsSectorSizeInformation /* B */ } FILE_FS_INFORMATION_CLASS; /* diff --git a/usr/src/uts/common/smbsrv/smb2_kproto.h b/usr/src/uts/common/smbsrv/smb2_kproto.h index cd397768d9..97b13af868 100644 --- a/usr/src/uts/common/smbsrv/smb2_kproto.h +++ b/usr/src/uts/common/smbsrv/smb2_kproto.h @@ -67,8 +67,24 @@ int smb3_encrypt_sr(smb_request_t *, struct mbuf_chain *, struct mbuf_chain *); int smb3_decrypt_sr(smb_request_t *); int smb3_encrypt_init_mech(smb_session_t *s); -uint32_t smb2_fsctl_resiliency(smb_request_t *, smb_fsctl_t *); -uint32_t smb2_fsctl_vneginfo(smb_request_t *, smb_fsctl_t *); +uint32_t smb2_fsctl_fs(smb_request_t *, smb_fsctl_t *); +uint32_t smb2_fsctl_netfs(smb_request_t *, smb_fsctl_t *); +uint32_t smb2_fsctl_copychunk(smb_request_t *, smb_fsctl_t *); +uint32_t smb2_fsctl_odx_read(smb_request_t *, smb_fsctl_t *); +uint32_t smb2_fsctl_odx_write(smb_request_t *, smb_fsctl_t *); +uint32_t smb2_fsctl_set_resilient(smb_request_t *, smb_fsctl_t *); + +/* smb2_fsctl_sparse.c */ +uint32_t smb2_fsctl_set_sparse(smb_request_t *, smb_fsctl_t *); +uint32_t smb2_fsctl_set_zero_data(smb_request_t *, smb_fsctl_t *); +uint32_t smb2_fsctl_query_alloc_ranges(smb_request_t *, smb_fsctl_t *); +uint32_t smb2_fsctl_query_file_regions(smb_request_t *, smb_fsctl_t *); +uint32_t smb2_sparse_copy(smb_request_t *sr, + smb_ofile_t *src_ofile, smb_ofile_t *dst_ofile, + off64_t src_off, off64_t dst_off, uint32_t *residp, + void *buffer, size_t bufsize); + +uint32_t smb2_nego_validate(smb_request_t *, smb_fsctl_t *); smb_sdrc_t smb2_negotiate(smb_request_t *); smb_sdrc_t smb2_session_setup(smb_request_t *); diff --git a/usr/src/uts/common/smbsrv/smb_fsops.h b/usr/src/uts/common/smbsrv/smb_fsops.h index 377dfe257a..22cbd665bf 100644 --- a/usr/src/uts/common/smbsrv/smb_fsops.h +++ b/usr/src/uts/common/smbsrv/smb_fsops.h @@ -73,13 +73,17 @@ int smb_fsop_rename(smb_request_t *, cred_t *, smb_node_t *, char *, smb_node_t *, char *); int smb_fsop_setattr(smb_request_t *, cred_t *, smb_node_t *, smb_attr_t *); -int smb_fsop_set_data_length(smb_request_t *sr, cred_t *cr, smb_node_t *, - offset_t); -int smb_fsop_read(smb_request_t *, cred_t *, smb_node_t *, uio_t *); +int smb_fsop_freesp(smb_request_t *sr, cred_t *cr, smb_ofile_t *, + off64_t, off64_t); -int smb_fsop_write(smb_request_t *, cred_t *, smb_node_t *, uio_t *, - uint32_t *, int); +int smb_fsop_read(smb_request_t *, cred_t *, smb_node_t *, smb_ofile_t *, + uio_t *); + +int smb_fsop_write(smb_request_t *, cred_t *, smb_node_t *, smb_ofile_t *, + uio_t *, uint32_t *, int); + +int smb_fsop_next_alloc_range(cred_t *, smb_node_t *, off64_t *, off64_t *); int smb_fsop_statfs(cred_t *, smb_node_t *, struct statvfs64 *); diff --git a/usr/src/uts/common/smbsrv/smb_kproto.h b/usr/src/uts/common/smbsrv/smb_kproto.h index 8f84b7abb4..d18ff80d5e 100644 --- a/usr/src/uts/common/smbsrv/smb_kproto.h +++ b/usr/src/uts/common/smbsrv/smb_kproto.h @@ -231,6 +231,7 @@ void smb_quota_free_quotas(list_t *); void smb_query_shortname(smb_node_t *, smb_queryinfo_t *); +uint32_t smb_dfs_fsctl(smb_request_t *, smb_fsctl_t *); uint32_t smb_dfs_get_referrals(smb_request_t *, smb_fsctl_t *); int smb1_newrq_negotiate(smb_request_t *); @@ -420,6 +421,7 @@ int smb_opipe_write(smb_request_t *, struct uio *); int smb_opipe_getattr(smb_ofile_t *, smb_attr_t *); int smb_opipe_getname(smb_ofile_t *, char *, size_t); uint32_t smb_opipe_fsctl(smb_request_t *, smb_fsctl_t *); +uint32_t smb_opipe_transceive(smb_request_t *, smb_fsctl_t *); void smb_kdoor_init(smb_server_t *); void smb_kdoor_fini(smb_server_t *); diff --git a/usr/src/uts/common/smbsrv/smb_ktypes.h b/usr/src/uts/common/smbsrv/smb_ktypes.h index 00a4652b69..7011ac6dbe 100644 --- a/usr/src/uts/common/smbsrv/smb_ktypes.h +++ b/usr/src/uts/common/smbsrv/smb_ktypes.h @@ -1899,6 +1899,7 @@ typedef struct smb_request { smb_arg_olbrk_t olbrk; /* for async oplock break */ smb_rw_param_t *rw; int32_t timestamp; + void *other; } arg; } smb_request_t; diff --git a/usr/src/uts/common/smbsrv/smb_vops.h b/usr/src/uts/common/smbsrv/smb_vops.h index 2f78f63bae..4c869de38c 100644 --- a/usr/src/uts/common/smbsrv/smb_vops.h +++ b/usr/src/uts/common/smbsrv/smb_vops.h @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 Nexenta Systems, Inc. All rights reserved. */ #ifndef _SMBSRV_SMB_VOPS_H @@ -127,6 +127,7 @@ int smb_vop_open(vnode_t **, int, cred_t *); void smb_vop_close(vnode_t *, int, cred_t *); int smb_vop_read(vnode_t *, uio_t *, cred_t *); int smb_vop_write(vnode_t *, uio_t *, int, uint32_t *, cred_t *); +int smb_vop_ioctl(vnode_t *, int, void *, cred_t *); int smb_vop_getattr(vnode_t *, vnode_t *, smb_attr_t *, int, cred_t *); int smb_vop_setattr(vnode_t *, vnode_t *, smb_attr_t *, int, cred_t *); int smb_vop_space(vnode_t *, int, flock64_t *, int, offset_t, cred_t *); diff --git a/usr/src/uts/i86pc/os/mp_machdep.c b/usr/src/uts/i86pc/os/mp_machdep.c index 1c6b26d34f..bb25cc26fc 100644 --- a/usr/src/uts/i86pc/os/mp_machdep.c +++ b/usr/src/uts/i86pc/os/mp_machdep.c @@ -1134,6 +1134,14 @@ mach_smpinit(void) if (pops->psm_enable_intr) psm_enable_intr = pops->psm_enable_intr; + /* + * Set this vector so it can be used by vmbus (for Hyper-V) + * Need this even for single-CPU systems. This works for + * "pcplusmp" and "apix" platforms, but not "uppc" (because + * "Uni-processor PC" does not provide a _get_ipivect). + */ + psm_get_ipivect = pops->psm_get_ipivect; + /* check for multiple CPUs */ if (cnt < 2 && plat_dr_support_cpu() == B_FALSE) return; @@ -1156,7 +1164,6 @@ mach_smpinit(void) #endif } - psm_get_ipivect = pops->psm_get_ipivect; psm_get_pir_ipivect = pops->psm_get_pir_ipivect; psm_send_pir_ipi = pops->psm_send_pir_ipi; psm_cmci_setup = pops->psm_cmci_setup; diff --git a/usr/src/uts/sun4u/sys/fctest.h b/usr/src/uts/sun4u/sys/fctest.h deleted file mode 100644 index 82067a4a84..0000000000 --- a/usr/src/uts/sun4u/sys/fctest.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _SYS_FCTEST_H -#define _SYS_FCTEST_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * /dev/fctest ioctls ... this is not part of the efcode project. - * This is a prototype test driver, used to drive the prototype - * only, and is not needed with hot-plug hardware and real hot-plug - * capable code. - */ - -#define FCTIOC (0xfd<<8) - -/* - * FCT_SET_DEBUG_LVL: 'arg' is an intptr_t. - * Set fcode_debug to the value in intptr_t 'arg'. - */ -#define FCT_SET_DEBUG_LVL (FCTIOC | 1) - -/* - * FCT_SET_DEVICE: 'arg' is a pointer to a string. The string - * is taken as the pathname of the device to be configured. - * The driver attempts to locate the device in the device tree, - * and uses the parent of the device as the attachment point. - * The device has to exist in the firmware's device tree. - */ -#define FCT_SET_DEVICE (FCTIOC | 2) - -/* - * FCT_UNCONFIGURE: 'arg' is ignored. Unconfigures the device - * given in the FCT_SET_DEVICE ioctl. - */ -#define FCT_UNCONFIGURE (FCTIOC | 3) -#define FCT_CONFIGURE (FCTIOC | 4) - - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_FCTEST_H */ diff --git a/usr/src/uts/sun4u/sys/gptwo_pci.h b/usr/src/uts/sun4u/sys/gptwo_pci.h deleted file mode 100644 index cdac06411b..0000000000 --- a/usr/src/uts/sun4u/sys/gptwo_pci.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright 2000 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_GPTWO_PCI_H -#define _SYS_GPTWO_PCI_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Header file for the PCI/Schizo component to the - * Safari Configurator (gptwo_cpu). - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/safari_pcd.h> - -gptwocfg_ops_cookie_t gptwocfg_alloc_pci_ops(int, int); -gptwo_new_nodes_t *gptwo_configure_pci(dev_info_t *, spcd_t *, uint_t); -dev_info_t *gptwo_unconfigure_pci(dev_info_t *); - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_GPTWO_PCI_H */ diff --git a/usr/src/uts/sun4u/sys/i2c/clients/hpc3130_impl.h b/usr/src/uts/sun4u/sys/i2c/clients/hpc3130_impl.h deleted file mode 100644 index e7091ae525..0000000000 --- a/usr/src/uts/sun4u/sys/i2c/clients/hpc3130_impl.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _HPC3130_IMPL_H -#define _HPC3130_IMPL_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/i2c/clients/i2c_client.h> - -struct hpc3130_unit { - kmutex_t hpc3130_mutex; - uint8_t hpc3130_flags; - int hpc3130_oflag; - i2c_client_hdl_t hpc3130_hdl; - char hpc3130_name[24]; -}; - -#ifdef DEBUG - -static int hpc3130debug = 0; -#define D1CMN_ERR(ARGS) if (hpc3130debug & 0x1) cmn_err ARGS; -#define D2CMN_ERR(ARGS) if (hpc3130debug & 0x2) cmn_err ARGS; - -#else - -#define D1CMN_ERR(ARGS) -#define D2CMN_ERR(ARGS) - -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _HPC3130_IMPL_H */ |
