5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License, Version 1.0 only
7 * (the "License"). You may not use this file except in compliance
10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 * or http://www.opensolaris.org/os/licensing.
12 * See the License for the specific language governing permissions
13 * and limitations under the License.
15 * When distributing Covered Code, include this CDDL HEADER in each
16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 * If applicable, add the following below this CDDL HEADER, with the
18 * fields enclosed by brackets "[]" replaced with your own identifying
19 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1999-2000 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <sys/param.h>
32 #include <sys/fs/udf_volume.h>
34 char shell_name
[128] = "/bin/sh";
36 extern
uint16_t ricb_prn
;
37 extern
uint32_t ricb_loc
;
38 extern
int32_t bsize
, bmask
, l2d
, l2b
;
53 uint32_t i_number
= 0;
55 int error_override
= 0;
57 int register_array
[256];
58 char cwd
[MAXPATHLEN
] = "/";
68 #define FIND_INODE 0x4
82 %token BASE BLOCK CD DIRECTORY TFILE FIND FILL
83 %token INODE LS OVERRIDE PROMPT PWD QUIT TAG BANG
85 %token AVD MVDS RVDS INTS FSDS ROOT
86 %token ATTZ ATYE ATMO ATDA ATHO ATMI ATSE ATCE ATHU ATMIC
87 %token CTTZ CTYE CTMO CTDA CTHO CTMI CTSE CTCE CTHU CTMIC
88 %token MTTZ MTYE MTMO MTDA MTHO MTMI MTSE MTCE MTHU MTMIC
89 %token GID LN MD MAJ MIO NM SZ UID UNIQ
103 session
: statement_list
105 statement_list
: /* empty */ { print_prompt
(); }
106 | statement_list statement
112 statement
: empty_statement
115 | base | block | cd | directory | file | find | fill
116 | inode | ls | override | nprompt | pwd | quit | tag | shell
117 | avd | mvds | rvds | ints | fsds | root
118 | at | ct | gid | ln | mt | md
119 | maj | min | nm | sz | uid | uniq
121 |
error { yyclearin; yyerrok; }
133 if
(last_op_type
== TYPE_INODE
) {
134 print_inode
(i_number
<< l2b
);
135 } else if
(last_op_type
== TYPE_DIRENT
) {
136 print_dent
(i_number
<< l2b
, d_entry
);
139 gettext
("%x\n"), value
);
146 if
((strlen
((caddr_t
)$2) == 1) &&
151 value
= register_array
[$2[0]];
154 gettext
("Registers can"
155 " be only a-z or A-Z\n"));
160 if
((strlen
((caddr_t
)$2) == 1) &&
165 register_array
[$2[0]] = value
;
168 gettext
("Registers can"
169 " be only a-z or A-Z\n"));
176 if
(($3 == 8) ||
($3 == 10) ||
($3 == 16)) {
180 gettext
("Requested %x Only"
182 " Hex are Supported\n"), $3);
188 gettext
("Current Base in Decimal"
195 last_op_type
= TYPE_NONE
;
196 value
= value
* DEV_BSIZE
;
204 char temp_cwd
[MAXPATHLEN
];
206 strcpy
(temp_cwd
, cwd
);
207 if
(strcmp
((caddr_t
)$3, "..") == 0) {
208 if
(strlen
(temp_cwd
) == 1) {
209 if
(temp_cwd
[0] != '/') {
211 gettext
("cwd is invalid"
213 strcpy
(temp_cwd
, "/");
221 len
= strlen
(temp_cwd
);
222 if
(temp_cwd
[len
- 1] != '/') {
224 temp_cwd
[len
+ 1] = '\0';
226 strcat
(temp_cwd
, (caddr_t
)$3);
228 if
(inode_from_path
(temp_cwd
, &temp
,
231 gettext
("Could not locate inode"
232 " for path %s\n"), temp_cwd
);
233 strcpy
(temp_cwd
, "/");
234 if
((temp
= ud_xlate_to_daddr
(ricb_prn
,
237 gettext
("Failed to translate"
242 if
((fl
& FID_DIR
) == 0) {
244 gettext
("%s is not a"
245 " directory\n"), temp_cwd
);
247 strcpy
(cwd
, temp_cwd
);
249 last_op_type
= TYPE_CD
;
258 (void) strcpy
(cwd
, "/");
260 * set current value to root icb
262 if
((block
= ud_xlate_to_daddr
(ricb_prn
,
265 gettext
("Failed to translate "
269 value
= block
<< l2b
;
270 last_op_type
= TYPE_CD
;
276 directory
: DIRECTORY
278 if
(verify_dent
(i_number
<< l2b
, value
) == 0) {
279 last_op_type
= TYPE_DIRENT
;
292 if
((find_flags
& (FIND_NAME | FIND_INODE
)) &&
293 (find_flags
& FIND_DONE
)) {
294 if
(find_dir
[0] != '/') {
297 strcpy
(buf
, find_dir
);
298 if
((strlen
(cwd
) == 1) &&
300 strcpy
(find_dir
, "/");
302 strcpy
(find_dir
, cwd
);
303 strcat
(find_dir
, "/");
305 strcat
(find_dir
, buf
);
307 find_it
(find_dir
, find_name
, find_in
,
308 (find_flags
& (FIND_NAME | FIND_INODE
)));
319 strcpy
(find_dir
, (char *)$2);
320 find_flags
= FIND_DIR
;
324 if
(find_flags
== FIND_DIR
) {
325 if
(strcmp
((char *)$3, "-name") == 0) {
326 find_flags
= FIND_NAME
;
327 } else if
(strcmp
((char *)$3, "-inum")
329 find_flags
= FIND_INODE
;
332 gettext
("find dir-name {-name n | -inum n}\n"));
334 } else if
(find_flags
== FIND_NAME
) {
335 strcpy
(find_name
, (char *)$3);
336 find_flags |
= FIND_DONE
;
337 } else if
(find_flags
== FIND_INODE
) {
340 if
(check_and_get_int
($3, &temp
) ==
343 find_flags |
= FIND_DONE
;
346 gettext
("find dir-name {-name n | -inum n}\n"));
350 gettext
("find dir-name {-name n | -inum n}\n"));
355 if
(find_flags
== FIND_INODE
) {
357 find_flags |
= FIND_DONE
;
360 gettext
("find dir-name {-name n | -inum n}\n"));
368 fill_pattern
(value
, count
, $3);
376 if
(last_op_type
== TYPE_CD
) {
381 last_op_type
= TYPE_INODE
;
382 if
(verify_inode
(temp
, 0) != 0) {
383 i_number
= temp
>> l2b
;
391 if
(ls_flags
& LIST_LS
) {
392 list
(".", i_number
, ls_flags
);
404 if
(strcmp
((caddr_t
)$3, "-l") == 0) {
405 ls_flags |
= LONG_LIST
;
406 } else if
(strcmp
((caddr_t
)$3, "-R") == 0) {
407 ls_flags |
= RECU_LIST
;
408 } else if
((strcmp
((caddr_t
)$3, "-lR") == 0) ||
409 (strcmp
((caddr_t
)$3, "-Rl") == 0)) {
410 ls_flags |
= LONG_LIST | RECU_LIST
;
412 list
(".", i_number
, ls_flags
);
413 ls_flags
&= ~LIST_LS
;
420 if
(error_override
== 0) {
422 (void) fprintf
(stdout
,
423 gettext
("error checking on\n"));
426 (void) fprintf
(stdout
,
427 gettext
("error checking off\n"));
432 nprompt
: PROMPT
'=' WORD
434 (void) strcpy
(prompt
, (caddr_t
)$3);
440 fprintf
(stdout
, gettext
("%s\n"), cwd
);
452 print_desc
(value
, 0);
462 avd
: AVD
{ print_desc
(NULL
, AVD
); }
464 mvds
: MVDS
{ print_desc
(NULL
, MVDS
); }
466 rvds
: RVDS
{ print_desc
(NULL
, RVDS
); }
468 ints
: INTS
{ print_desc
(NULL
, INTS
); }
470 fsds
: FSDS
{ print_desc
(NULL
, FSDS
); }
472 root
: ROOT
{ print_desc
(NULL
, ROOT
); }
475 at
: ATTZ
'=' expr
{ set_file
(ATTZ
, i_number
<< l2b
, $3); }
476 | ATYE
'=' expr
{ set_file
(ATYE
, i_number
<< l2b
, $3); }
477 | ATMO
'=' expr
{ set_file
(ATMO
, i_number
<< l2b
, $3); }
478 | ATDA
'=' expr
{ set_file
(ATDA
, i_number
<< l2b
, $3); }
479 | ATHO
'=' expr
{ set_file
(ATHO
, i_number
<< l2b
, $3); }
480 | ATMI
'=' expr
{ set_file
(ATMI
, i_number
<< l2b
, $3); }
481 | ATSE
'=' expr
{ set_file
(ATSE
, i_number
<< l2b
, $3); }
482 | ATCE
'=' expr
{ set_file
(ATCE
, i_number
<< l2b
, $3); }
483 | ATHU
'=' expr
{ set_file
(ATHU
, i_number
<< l2b
, $3); }
486 set_file
(ATMIC
, i_number
<< l2b
, $3);
490 ct
: CTTZ
'=' expr
{ set_file
(CTTZ
, i_number
<< l2b
, $3); }
491 | CTYE
'=' expr
{ set_file
(CTYE
, i_number
<< l2b
, $3); }
492 | CTMO
'=' expr
{ set_file
(CTMO
, i_number
<< l2b
, $3); }
493 | CTDA
'=' expr
{ set_file
(CTDA
, i_number
<< l2b
, $3); }
494 | CTHO
'=' expr
{ set_file
(CTHO
, i_number
<< l2b
, $3); }
495 | CTMI
'=' expr
{ set_file
(CTMI
, i_number
<< l2b
, $3); }
496 | CTSE
'=' expr
{ set_file
(CTSE
, i_number
<< l2b
, $3); }
497 | CTCE
'=' expr
{ set_file
(CTCE
, i_number
<< l2b
, $3); }
498 | CTHU
'=' expr
{ set_file
(CTHU
, i_number
<< l2b
, $3); }
501 set_file
(CTMIC
, i_number
<< l2b
, $3);
505 mt
: MTTZ
'=' expr
{ set_file
(MTTZ
, i_number
<< l2b
, $3); }
506 | MTYE
'=' expr
{ set_file
(MTYE
, i_number
<< l2b
, $3); }
507 | MTMO
'=' expr
{ set_file
(MTMO
, i_number
<< l2b
, $3); }
508 | MTDA
'=' expr
{ set_file
(MTDA
, i_number
<< l2b
, $3); }
509 | MTHO
'=' expr
{ set_file
(MTHO
, i_number
<< l2b
, $3); }
510 | MTMI
'=' expr
{ set_file
(MTMI
, i_number
<< l2b
, $3); }
511 | MTSE
'=' expr
{ set_file
(MTSE
, i_number
<< l2b
, $3); }
512 | MTCE
'=' expr
{ set_file
(MTCE
, i_number
<< l2b
, $3); }
513 | MTHU
'=' expr
{ set_file
(MTHU
, i_number
<< l2b
, $3); }
516 set_file
(MTMIC
, i_number
<< l2b
, $3);
521 gid
: GID
'=' expr
{ set_file
(GID
, i_number
<< l2b
, $3); }
524 ln
: LN
'=' expr
{ set_file
(LN
, i_number
<< l2b
, $3); }
527 md
: MD
'=' expr
{ set_file
(MD
, i_number
<< l2b
, $3); }
530 maj
: MAJ
'=' expr
{ set_file
(MAJ
, i_number
<< l2b
, $3); }
533 min
: MIO
'=' expr
{ set_file
(MIO
, i_number
<< l2b
, $3); }
536 nm
: NM
'=' expr
{ set_file
(NM
, i_number
<< l2b
, $3); }
539 sz
: SZ
'=' expr
{ set_file
(SZ
, i_number
<< l2b
, $3); }
542 uid
: UID
'=' expr
{ set_file
(UID
, i_number
<< l2b
, $3); }
545 uniq
: UNIQ
'=' expr
{ set_file
(UNIQ
, i_number
<< l2b
, $3); }
550 if
(strlen
((char *)$2) != 1) {
552 gettext
("Invalid command\n"));
554 dump_disk
(value
, count
, $2);
559 if
(strcmp
((char *)$2, "i") == 0) {
560 if
(verify_inode
(value
<< l2b
,
562 print_inode
(value
<< l2b
);
564 last_op_type
== TYPE_INODE
;
566 } else if
(strcmp
((char *)$2, "d") == 0) {
567 if
(verify_dent
(i_number
<< l2b
,
569 print_dent
(i_number
<< l2b
,
572 last_op_type
== TYPE_DIRENT
;
576 gettext
("Invalid command\n"));
595 if
(last_op_type
== TYPE_INODE
) {
596 if
(verify_inode
((i_number
+ 1) << l2b
,
599 print_inode
(i_number
<< l2b
);
600 $$
= i_number
<< l2b
;
602 } else if
(last_op_type
== TYPE_DIRENT
) {
603 if
(verify_dent
(i_number
<< l2b
,
606 print_dent
(i_number
<< l2b
,
610 count
= 0; $$
= value
++;
615 if
(last_op_type
== TYPE_INODE
) {
616 if
(verify_inode
((i_number
- 1) << l2b
,
619 print_inode
(i_number
<< l2b
);
620 $$
= i_number
<< l2b
;
622 } else if
(last_op_type
== TYPE_DIRENT
) {
623 if
(verify_dent
(i_number
<< l2b
,
626 print_dent
(i_number
<< l2b
,
630 count
= 0; $$
= value
--;
637 if
(check_and_get_int
($2, &number
) == 0) {
646 if
(check_and_get_int
($2, &number
) == 0) {
655 if
(check_and_get_int
($2, &number
) == 0) {
664 if
(check_and_get_int
($2, &number
) == 0) {
667 gettext
("Divide by zero ?\n"));
674 | expr
'-' expr
{ count
= 0; $$
= $1 - $3; }
675 | expr
'+' expr
{ count
= 0; $$
= $1 + $3; }
676 | expr
'*' expr
{ count
= 0; $$
= $1 * $3; }
681 gettext
("Divide by zero ?\n"));
692 if
(check_and_get_int
($1, &number
) == 0) {
701 check_and_get_int
(uint8_t *str
, uint64_t *value
)
703 int32_t length
, cbase
, index
, cvalue
;
706 length
= strlen
((caddr_t
)str
);
708 * Decide on what base to be used
709 * and strip off the base specifier
711 if
((str
[0] == '0') && (str
[1] == 'x')) {
714 } else if
((str
[0] == '0') && (str
[1] == 't')) {
717 } else if
(str
[0] == '0') {
726 * Verify if the string is integer
727 * and convert to a binary value
729 for
( ; index
< length
; index
++) {
731 if
((str
[index
] < '0') ||
732 (str
[index
] > '7')) {
734 gettext
("Invalid Octal Number %s\n"),
738 cvalue
= str
[index
] - '0';
739 } else if
(cbase
== 0xa) {
740 if
((str
[index
] < '0') ||
741 (str
[index
] > '9' )) {
743 gettext
("Invalid Decimal Number %s\n"),
747 cvalue
= str
[index
] - '0';
749 if
((str
[index
] >= '0') &&
750 (str
[index
] <= '9')) {
751 cvalue
= str
[index
] - '0';
752 } else if
((str
[index
] >= 'a') &&
753 (str
[index
] <= 'f')) {
754 cvalue
= str
[index
] - 'a' + 10;
755 } else if
((str
[index
] >= 'A') &&
756 (str
[index
] <= 'F')) {
757 cvalue
= str
[index
] - 'A' + 10;
760 gettext
("Invalid Hex Number %s\n"),
765 *value
= *value
* cbase
+ cvalue
;
776 fprintf
(stdout
, gettext
("%s"), prompt
);