View | Details | Raw Unified | Return to bug 23335
Collapse All | Expand All

(-)tunefs.c (-98 / +114 lines)
Line 94 Link Here
94
	int Aflag = 0, active = 0;
94
	int Aflag = 0, pflag = 0, active = 0;
95
--
95
	int aflag = 0, dflag = 0, eflag = 0, mflag = 0, nflag = 0, oflag = 0;
96
	char *aopt, *dopt, *eopt, *mopt, *nopt, *oopt;
Line 103 Link Here
105
	found_arg = 0; /* at least one arg is required */
106
	while ((ch = getopt(argc, argv, "Aa:d:e:m:n:o:p")) != -1)
107
	  switch (ch) {
108
	  case 'A':
109
		found_arg = 1;
110
		Aflag++;
111
		break;
112
	  case 'a':
113
		found_arg = 1;
114
		aflag = 1;
115
		aopt = optarg;
116
		break;
117
	  case 'd':
118
		found_arg = 1;
119
		dflag = 1;
120
		dopt = optarg;
121
		break;
122
	  case 'e':
123
		found_arg = 1;
124
		eflag = 1;
125
		eopt = optarg;
126
		break;
127
	  case 'm':
128
		found_arg = 1;
129
		mflag = 1;
130
		mopt = optarg;
131
		break;
132
	  case 'n':
133
		found_arg = 1;
134
		nflag = 1;
135
		nopt = optarg;
136
 		break;
137
	  case 'o':
138
		found_arg = 1;
139
		oflag = 1;
140
		oopt = optarg;
141
		break;
142
	  case 'p':
143
		found_arg = 1;
144
		pflag = 1;
145
		break;
146
	  default:
147
		usage();
148
	  }
149
	argc -= optind;
150
	argv += optind;
151
152
	if (found_arg == 0 || argc != 1)
153
	  usage();
154
Lines 128-136 Link Here
128
	found_arg = 0; /* at least one arg is required */
180
	if (pflag) {
129
	while ((ch = getopt(argc, argv, "Aa:d:e:m:n:o:p")) != -1)
181
		printfs();
130
	  switch (ch) {
182
		exit(0);
131
	  case 'A':
183
	}
132
		found_arg = 1;
184
133
		Aflag++;
185
	if (aflag) {
134
		break;
135
	  case 'a':
136
		found_arg = 1;
137
--
Line 138 Link Here
138
		i = atoi(optarg);
187
		i = atoi(aopt);
139
--
Line 140 Link Here
140
			errx(10, "%s must be >= 1 (was %s)", name, optarg);
189
			errx(10, "%s must be >= 1 (was %s)", name, aopt);
141
--
Line 143 Link Here
143
			break;
192
		} else {
144
--
193
			warnx("%s changes from %d to %d",
194
					 name, sblock.fs_maxcontig, i);
195
			sblock.fs_maxcontig = i;
Lines 145-149 Link Here
145
		warnx("%s changes from %d to %d", name, sblock.fs_maxcontig, i);
197
	}
146
		sblock.fs_maxcontig = i;
198
147
		break;
199
	if (dflag) {
148
	  case 'd':
149
		found_arg = 1;
150
--
Line 151 Link Here
151
		i = atoi(optarg);
201
		i = atoi(dopt);
152
--
Lines 154-156 Link Here
154
			break;
204
		} else {
155
		}
205
			warnx("%s changes from %dms to %dms",
156
		warnx("%s changes from %dms to %dms",
157
--
Lines 158-161 Link Here
158
		sblock.fs_rotdelay = i;
207
			sblock.fs_rotdelay = i;
159
		break;
208
		}
160
	  case 'e':
209
	}
161
		found_arg = 1;
210
162
--
211
	if (eflag) {
Line 163 Link Here
163
		i = atoi(optarg);
213
		i = atoi(eopt);
164
--
Line 165 Link Here
165
			errx(10, "%s must be >= 1 (was %s)", name, optarg);
215
			errx(10, "%s must be >= 1 (was %s)", name, eopt);
166
--
Line 168 Link Here
168
			break;
218
		} else {
169
--
219
			warnx("%s changes from %d to %d",
220
					 name, sblock.fs_maxbpg, i);
221
			sblock.fs_maxbpg = i;
Lines 170-174 Link Here
170
		warnx("%s changes from %d to %d", name, sblock.fs_maxbpg, i);
223
	}
171
		sblock.fs_maxbpg = i;
224
172
		break;
225
	if (mflag) {
173
	  case 'm':
174
		found_arg = 1;
175
--
Line 176 Link Here
176
		i = atoi(optarg);
227
		i = atoi(mopt);
177
--
Line 178 Link Here
178
			errx(10, "bad %s (%s)", name, optarg);
229
			errx(10, "bad %s (%s)", name, mopt);
179
--
Lines 181-183 Link Here
181
			break;
232
		} else {
182
		}
233
			warnx("%s changes from %d%% to %d%%",
183
		warnx("%s changes from %d%% to %d%%",
184
--
Lines 185-192 Link Here
185
		sblock.fs_minfree = i;
235
			sblock.fs_minfree = i;
186
		if (i >= MINFREE && sblock.fs_optim == FS_OPTSPACE)
236
			if (i >= MINFREE && sblock.fs_optim == FS_OPTSPACE)
187
			warnx(OPTWARN, "time", ">=", MINFREE);
237
				warnx(OPTWARN, "time", ">=", MINFREE);
188
		if (i < MINFREE && sblock.fs_optim == FS_OPTTIME)
238
			if (i < MINFREE && sblock.fs_optim == FS_OPTTIME)
189
			warnx(OPTWARN, "space", "<", MINFREE);
239
				warnx(OPTWARN, "space", "<", MINFREE);
190
		break;
240
		}
191
	  case 'n':
241
	}
192
		found_arg = 1;
242
193
--
243
	if (nflag) {
Line 194 Link Here
194
 		if (strcmp(optarg, "enable") == 0) {
245
 		if (strcmp(nopt, "enable") == 0) {
195
--
Line 197 Link Here
197
 		} else if (strcmp(optarg, "disable") == 0) {
248
 		} else if (strcmp(nopt, "disable") == 0) {
198
--
Lines 205-207 Link Here
205
 		break;
256
	}
206
	  case 'o':
257
207
		found_arg = 1;
258
	if (oflag) {
208
--
Line 211 Link Here
211
		if (strcmp(optarg, chg[FS_OPTSPACE]) == 0)
262
		if (strcmp(oopt, chg[FS_OPTSPACE]) == 0)
212
--
Line 213 Link Here
213
		else if (strcmp(optarg, chg[FS_OPTTIME]) == 0)
264
		else if (strcmp(oopt, chg[FS_OPTTIME]) == 0)
214
--
Lines 220-222 Link Here
220
			break;
271
		} else {
221
		}
272
			warnx("%s changes from %s to %s",
222
		warnx("%s changes from %s to %s",
223
--
Lines 224-240 Link Here
224
		sblock.fs_optim = i;
274
			sblock.fs_optim = i;
225
		if (sblock.fs_minfree >= MINFREE && i == FS_OPTSPACE)
275
			if (sblock.fs_minfree >= MINFREE && i == FS_OPTSPACE)
226
			warnx(OPTWARN, "time", ">=", MINFREE);
276
				warnx(OPTWARN, "time", ">=", MINFREE);
227
		if (sblock.fs_minfree < MINFREE && i == FS_OPTTIME)
277
			if (sblock.fs_minfree < MINFREE && i == FS_OPTTIME)
228
			warnx(OPTWARN, "space", "<", MINFREE);
278
				warnx(OPTWARN, "space", "<", MINFREE);
229
		break;
279
		}
230
	  case 'p':
280
	}
231
		printfs();
232
		exit(0);
233
	  default:
234
		usage();
235
	  }
236
	argc -= optind;
237
	argv += optind;
238
239
	if (found_arg == 0 || argc != 1)
240
	  usage();
241
--

Return to bug 23335